Skip to content

Commit

Permalink
Support custom organisms
Browse files Browse the repository at this point in the history
  • Loading branch information
eweitz committed Apr 14, 2021
1 parent 05849a3 commit 76513cc
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
3 changes: 2 additions & 1 deletion examples/vanilla/custom-organism.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ <h1>Custom organism | Ideogram</h1>
<script type="text/javascript">

var ideogram = new Ideogram({
organism: 'custom'
organism: 'custom',
dataDir: 'https://raw.githubusercontent.com/eweitz/ideogram/05849a37242695d0d3dfb52059c4d0230842cda8/data/bands/native/'
});
</script>
</body>
Expand Down
3 changes: 2 additions & 1 deletion src/js/init/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,9 @@ function getBandFileNames(taxid, bandFileNames, ideo) {
}

bandFileName = getBandFileName(taxid, accession, ideo);
var isCustomOrganism = taxid === '-1';

if (taxid in ideo.organismsWithBands) {
if (taxid in ideo.organismsWithBands || isCustomOrganism) {
bandFileNames[taxid] = bandFileName;
}
return bandFileNames;
Expand Down
24 changes: 22 additions & 2 deletions src/js/services/organisms.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,18 @@ function getTaxidFromEutils(orgName, ideo) {
taxonomySearch = ideo.esearch + '&db=taxonomy&term=' + orgName;

return d3.json(taxonomySearch).then(function(data) {
taxid = data.esearchresult.idlist[0];
return [orgName, taxid];
var idlist = data.esearchresult.idlist;
if (idlist.length === 0) {
throw Error(
'Organism "' + orgName + '" is generally unknown; it was not found ' +
'in the NCBI Taxonomy database. If you did not intend to specify a ' +
'novel or custom taxon, then try using the organism\'s ' +
'scientific name, e.g. Homo sapiens or Arabidopsis thaliana.'
);
} else {
taxid = data.esearchresult.idlist[0];
return [orgName, taxid];
}
});
}

Expand Down Expand Up @@ -201,6 +211,16 @@ function populateNonNativeOrg(orgs, ideo) {
};

Object.assign(ideo.organisms, augmentedOrganismMetadata);
}, function(errorMessage) {
console.info(errorMessage);
var customMetadata = {
scientificName: org,
commonName: org,
assemblies: {default: ''}
};

ideo.organisms['-1'] = customMetadata;
augmentedOrganismMetadata['-1'] = customMetadata;
});
} else {
promise = new Promise(function(resolve) {
Expand Down

0 comments on commit 76513cc

Please sign in to comment.