Skip to content

Commit ac039ed

Browse files
authored
Merge pull request #13 from P2GX/develop
Develop
2 parents 497a205 + 28047cb commit ac039ed

30 files changed

+1520
-240
lines changed

.gitignore

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
hs_err_pid*
2424
replay_pid*
2525

26-
/.idea/
27-
/data/
28-
/target/
29-
/candidates.tsv
26+
.idea/
27+
data/
28+
target/
29+
candidates.*
3030
/candidates/
3131
.DS_Store

pom.xml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>org.monarchinitiative.hpotools</groupId>
66
<artifactId>hpotools</artifactId>
7-
<version>0.0.9</version>
7+
<version>0.1.5</version>
88
<packaging>jar</packaging>
99
<name>hpotools</name>
1010

@@ -162,6 +162,16 @@
162162
<version>5.11.4</version> <!-- Use the latest version available -->
163163
<scope>test</scope>
164164
</dependency>
165+
<dependency>
166+
<groupId>org.apache.commons</groupId>
167+
<artifactId>commons-math3</artifactId>
168+
<version>3.6.1</version>
169+
</dependency>
170+
<dependency>
171+
<groupId>com.google.protobuf</groupId>
172+
<artifactId>protobuf-java-util</artifactId>
173+
<version>3.21.12</version> <!-- or compatible version -->
174+
</dependency>
165175
</dependencies>
166176

167177
<build>

src/main/java/org/monarchinitiative/hpotools/Main.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@ public static void main(String[] args) {
1818
}
1919
LOGGER.trace("Starting HPO tools");
2020
CommandLine cline = new CommandLine(new Main())
21+
.addSubcommand("dist", new HpoDistCommand())
2122
.addSubcommand("download", new DownloadCommand())
2223
.addSubcommand("encoding", new EncodingCommand())
24+
.addSubcommand("maxo", new MaxoCommand())
2325
.addSubcommand("mondo", new MondoCommand())
2426
.addSubcommand("onset", new OnsetCommand())
25-
.addSubcommand("simhpo", new SimHpoCommand())
27+
.addSubcommand("sim", new SimHpoCommand())
2628
.addSubcommand("stats", new StatsCommand())
27-
.addSubcommand("translate", new DiseaseTranslateCommand())
2829
.addSubcommand("tsv", new Hpo2TsvCommand())
2930
.addSubcommand("word", new WordCommand())
3031
;

src/main/java/org/monarchinitiative/hpotools/analysis/HpoStats.java

Lines changed: 0 additions & 69 deletions
This file was deleted.
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
package org.monarchinitiative.hpotools.analysis.maxo;
2+
3+
4+
import org.monarchinitiative.phenol.base.PhenolRuntimeException;
5+
import org.monarchinitiative.phenol.ontology.data.TermId;
6+
7+
/**
8+
* disease_id
9+
* disease_name
10+
* citation
11+
* maxo_id
12+
* maxo_label
13+
* hpo_id
14+
* maxo_relation
15+
* evidence_code
16+
* extension_id
17+
* extension_label
18+
* attribute
19+
* creator
20+
* last_update
21+
* created_on
22+
*/
23+
public class MaxoAnnot {
24+
private final TermId diseaseId;
25+
private final String diseaseLabel;
26+
private final String citation;
27+
private final TermId maxoId;
28+
private final String maxoLabel;
29+
private final TermId hpoId;
30+
private final String maxoRelation;
31+
private final String evidenceCode;
32+
private final TermId extensionId;
33+
private final String extensionLabel;
34+
private final String attribute;
35+
private final String creator;
36+
private final String last_update;
37+
private final String created_on;
38+
39+
40+
private MaxoAnnot(TermId diseaseId,
41+
String diseaseLabel,
42+
String citation,
43+
TermId maxoId,
44+
String maxoLabel,
45+
TermId hpoId,
46+
String maxoRelation, String evidenceCode, TermId extensionId, String extensionLabel, String attribute, String creator, String lastUpdate, String createdOn) {
47+
this.diseaseId = diseaseId;
48+
this.diseaseLabel = diseaseLabel;
49+
this.citation = citation;
50+
this.maxoId = maxoId;
51+
this.maxoLabel = maxoLabel;
52+
this.hpoId = hpoId;
53+
this.maxoRelation = maxoRelation;
54+
this.evidenceCode = evidenceCode;
55+
this.extensionId = extensionId;
56+
this.extensionLabel = extensionLabel;
57+
this.attribute = attribute;
58+
this.creator = creator;
59+
this.last_update = lastUpdate;
60+
this.created_on = createdOn;
61+
}
62+
63+
64+
public static MaxoAnnot fromLine(String line) {
65+
String[] tokens = line.split("\t");
66+
if (tokens.length != 14) {
67+
throw new PhenolRuntimeException("Malformed MaxoAnnot: " + line);
68+
}
69+
TermId diseaseId = TermId.of(tokens[0]);
70+
String label = tokens[1];
71+
String citation = tokens[2];
72+
TermId maxoId = TermId.of(tokens[3]);
73+
String maxoLabel = tokens[4];
74+
TermId hpooId = TermId.of(tokens[5]);
75+
String maxoRelation = tokens[6];
76+
String evidenceCode = tokens[7];
77+
TermId extensionId = null;
78+
String extensionLabel = null;
79+
if (tokens[8] != null && tokens[8].length() > 3) {
80+
extensionId = TermId.of(tokens[8]);
81+
extensionLabel = tokens[9];
82+
}
83+
String attribute = tokens[10];
84+
String creator = tokens[11];
85+
String lastUpdate = tokens[12];
86+
String createdOn = tokens[13];
87+
88+
return new MaxoAnnot(diseaseId,
89+
label,
90+
citation,
91+
maxoId,
92+
maxoLabel,
93+
hpooId,
94+
maxoRelation,
95+
evidenceCode,
96+
extensionId,
97+
extensionLabel,
98+
attribute,
99+
creator,
100+
lastUpdate,
101+
createdOn);
102+
}
103+
104+
public TermId diseaseId() {
105+
return diseaseId;
106+
}
107+
108+
public String diseaseLabel() {
109+
return diseaseLabel;
110+
}
111+
112+
public String citation() {
113+
return citation;
114+
}
115+
116+
public TermId maxoId() {
117+
return maxoId;
118+
}
119+
120+
public String maxoLabel() {
121+
return maxoLabel;
122+
}
123+
124+
public TermId hpoId() {
125+
return hpoId;
126+
}
127+
128+
public String maxoRelation() {
129+
return maxoRelation;
130+
}
131+
132+
133+
public String evidenceCode() {
134+
return evidenceCode;
135+
}
136+
137+
public TermId extensionId() {
138+
return extensionId;
139+
}
140+
141+
public String extensionLabel() {
142+
return extensionLabel;
143+
}
144+
145+
public String attribute() {
146+
return attribute;
147+
}
148+
149+
public String creator() {
150+
return creator;
151+
}
152+
public String lastUpdate() {
153+
return last_update;
154+
}
155+
public String createdOn() {
156+
return created_on;
157+
}
158+
159+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
package org.monarchinitiative.hpotools.analysis.maxo;
2+
3+
import org.monarchinitiative.phenol.base.PhenolRuntimeException;
4+
import org.monarchinitiative.phenol.ontology.data.TermId;
5+
6+
/**
7+
* hpo_id hpo_label predicate_id maxo_id maxo_label creator_id
8+
*/
9+
public class MaxoDxAnnot {
10+
11+
private final TermId hpo_id;
12+
private final String hpo_label;
13+
private final String predicate;
14+
private final TermId maxo_id;
15+
private final String maxoLabel;
16+
private final String creator_id;
17+
18+
public MaxoDxAnnot(TermId hpoId,
19+
String hpoLabel,
20+
String predicateId,
21+
TermId maxoId,
22+
String maxoLabel,
23+
String creatorId) {
24+
this.hpo_id = hpoId;
25+
this.hpo_label = hpoLabel;
26+
this.predicate = predicateId;
27+
this.maxo_id = maxoId;
28+
this.maxoLabel = maxoLabel;
29+
this.creator_id = creatorId;
30+
}
31+
32+
33+
public static MaxoDxAnnot fromLine(String line) {
34+
String[] fields = line.split("\t");
35+
if (fields.length != 6) {
36+
String e = String.format("Invalid format with %d fields (expected 5): %s",
37+
fields.length, line);
38+
throw new PhenolRuntimeException(e);
39+
}
40+
TermId hpoId = TermId.of(fields[0]);
41+
String hpoLabel = fields[1];
42+
String predicate = fields[2];
43+
TermId maxoId = TermId.of(fields[3]);
44+
String maxoLabel = fields[4];
45+
String creatorId = fields[5];
46+
return new MaxoDxAnnot(hpoId,
47+
hpoLabel,
48+
predicate,
49+
maxoId,
50+
maxoLabel,
51+
creatorId);
52+
}
53+
54+
public TermId hpoId() {
55+
return hpo_id;
56+
}
57+
58+
public String hpoLabel() {
59+
return hpo_label;
60+
}
61+
62+
public String predicate() {
63+
return predicate;
64+
}
65+
66+
public TermId maxoId() {
67+
return maxo_id;
68+
}
69+
70+
public String maxoLabel() {
71+
return maxoLabel;
72+
}
73+
74+
public String creatorId() {
75+
return creator_id;
76+
}
77+
}

src/main/java/org/monarchinitiative/hpotools/analysis/simhpo/IProportionalSampler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
public interface IProportionalSampler<E> {
66

7-
public E sample();
7+
E sample();
88

9-
public List<E> sample(int n);
9+
List<E> sample(int n);
1010
}

src/main/java/org/monarchinitiative/hpotools/analysis/simhpo/ProportionalSamplerWithReplacement.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public E sample() {
2424
}
2525

2626
public List<E> sample(int n) {
27-
List<E> selectedElements = new ArrayList<E>();
27+
List<E> selectedElements = new ArrayList<>();
2828
for (int i = 0; i < n; i++) {
2929
selectedElements.add(sample());
3030
}

0 commit comments

Comments
 (0)