@@ -74,7 +74,7 @@ public class Genome {
74
74
private static final int MAX_WHOLE_GENOME_LONG = 100 ;
75
75
private static Logger log = LogManager .getLogger (Genome .class );
76
76
77
- GenomeConfig config ;
77
+
78
78
private String id ;
79
79
private String displayName ;
80
80
private List <String > chromosomeNames ;
@@ -98,9 +98,21 @@ public class Genome {
98
98
private String defaultPos ;
99
99
private String nameSet ;
100
100
private List <Hub > trackHubs ;
101
+ private GenomeConfig config ;
102
+
103
+
104
+ private static Genome nullGenome = null ;
105
+
106
+ public synchronized static Genome nullGenome () {
107
+ if (nullGenome == null ) {
108
+ nullGenome = new Genome ("None" , Arrays .asList (new Chromosome (0 , "" , 0 )));
109
+ }
110
+ return nullGenome ;
111
+ }
101
112
102
- public Genome (GenomeConfig config ) throws IOException {
103
113
114
+ public Genome (GenomeConfig config ) throws IOException {
115
+ this .config = config ;
104
116
id = config .getId ();
105
117
displayName = config .getName ();
106
118
nameSet = config .getNameSet ();
@@ -180,7 +192,7 @@ public Genome(GenomeConfig config) throws IOException {
180
192
}
181
193
} else {
182
194
// No chromosome list. Try to fetch chromosome names from the sequence
183
- if (this .chromosomeNames .isEmpty ()) {
195
+ if (this .chromosomeNames .isEmpty ()) {
184
196
this .chromosomeNames = sequence .getChromosomeNames ();
185
197
}
186
198
}
@@ -228,8 +240,8 @@ public Genome(GenomeConfig config) throws IOException {
228
240
// TODO -- no place to go
229
241
}
230
242
231
- if (config .getHubs () != null ) {
232
- for (String hubUrl : config .getHubs ()) {
243
+ if (config .getHubs () != null ) {
244
+ for (String hubUrl : config .getHubs ()) {
233
245
try {
234
246
trackHubs .add (HubParser .loadHub (hubUrl , getUCSCId ()));
235
247
} catch (Exception e ) {
@@ -315,7 +327,7 @@ public String getCanonicalChrName(String str) {
315
327
try {
316
328
ChromAlias aliasRecord = chromAliasSource .search (str );
317
329
318
- if (aliasRecord == null && !str .equals (str .toLowerCase ())) {
330
+ if (aliasRecord == null && !str .equals (str .toLowerCase ())) {
319
331
aliasRecord = chromAliasSource .search (str .toLowerCase ());
320
332
}
321
333
@@ -817,12 +829,21 @@ public List<Hub> getTrackHubs() {
817
829
return trackHubs ;
818
830
}
819
831
820
- public synchronized static Genome nullGenome () {
821
- if (nullGenome == null ) {
822
- nullGenome = new Genome ("None" , Arrays .asList (new Chromosome (0 , "" , 0 )));
832
+ public void addTrackHub (Hub hub ) {
833
+
834
+ if (!trackHubs .stream ().anyMatch (h -> h .getUrl ().equals (hub .getUrl ()))) {
835
+ trackHubs .add (hub );
836
+ if (config .isFromJson ()) {
837
+ config .addHub (hub .getUrl ());
838
+ }
823
839
}
824
- return nullGenome ;
825
840
}
826
841
827
- private static Genome nullGenome = null ;
842
+ public boolean isFromJson () {
843
+ return config != null && config .isFromJson ();
844
+ }
845
+
846
+ public GenomeConfig getConfig () {
847
+ return config ;
848
+ }
828
849
}
0 commit comments