Skip to content

Commit

Permalink
Fix #40 & bump version.
Browse files Browse the repository at this point in the history
  • Loading branch information
j-andrews7 committed Aug 16, 2019
1 parent d6efd88 commit efcfc6b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 28 additions & 1 deletion renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,12 @@ function renderProtein(data) {
targ.innerHTML = 'No data available for this protein.';
return;
};

//Snag only first Uniprot ID if multiple in array.
if (Array.isArray(data)) {
data = data[0]
};

var instance = new ProtVista({
el: targ,
uniprotacc: data
Expand Down Expand Up @@ -893,7 +899,7 @@ function parseGeneData(data) {
undefined) {
uniprot = {
db: 'http://www.uniprot.org/uniprot/',
ident: data.uniprot['Swiss-Prot']
ident: checkArray(data.uniprot['Swiss-Prot'])
};
uniprotSum = getUniprotSummary(data.uniprot['Swiss-Prot']);
protein = data.uniprot['Swiss-Prot'];
Expand Down Expand Up @@ -982,13 +988,34 @@ function parseGeneData(data) {
});
};

// Check if ID is an array. If so, return first element.
function checkArray(id) {
return new Promise(function(resolve, reject) {
if (!id) {
reject();
}

// Necessary for edge cases where multiple IDs are returned.
if (Array.isArray(id)) {
id = id[0];
}

resolve(id);
});
}

// Fetch the function summary for given protein from UniprotKB.
function getUniprotSummary(id) {
return new Promise(function(resolve, reject) {
if (!id) {
reject();
}

// Necessary for edge cases where multiple IDs are returned.
if (Array.isArray(id)) {
id = id[0];
}

var summary;

fetch('https://www.uniprot.org/uniprot/' + id + '.xml').then(
Expand Down

0 comments on commit efcfc6b

Please # to comment.