develop: bug fixed at GenomeMongoDBAdaptor. Shall not raise NPE if genome info cannot be retrieved from the database
@@ -106,22 +106,28 @@ public class GenomeMongoDBAdaptor extends MongoDBAdaptor implements GenomeDBAdap
}
private Document getOneChromosomeInfo(String chromosome) {
- for (Document document : (List<Document>) getGenomeInfoVariable().get(CHROMOSOMES)) {
+ Document genomeInfoVariable = getGenomeInfoVariable();
+ if (genomeInfoVariable != null) {
+ for (Document document : (List<Document>) genomeInfoVariable.get(CHROMOSOMES)) {
if (document.get(NAME).equals(chromosome)) {
return document;
}
}
+ }
return null;
}
private Document getGenomeInfoVariable() {
if (genomeInfo == null) {
+ QueryResult<Document> queryResult = genomeInfoMongoDBCollection.find(new Document(), null);
+ if (queryResult.getNumResults() > 0) {
genomeInfo = genomeInfoMongoDBCollection.find(new Document(), null).getResult().get(0);
for (Document chromosomeDocument : (List<Document>) genomeInfo.get(CHROMOSOMES)) {
((List<Document>) chromosomeDocument.get(CYTOBANDS))
.sort((c1, c2) -> Integer.compare((int) c1.get(START), (int) c2.get(START)));
}
}
+ }
return genomeInfo;
}
