Skip to content

Commit

Permalink
Merge pull request #529 from PoonLab/dev
Browse files Browse the repository at this point in the history
Minor: Bug fixes
  • Loading branch information
GopiGugan authored Jun 14, 2024
2 parents ca3379d + 170ad71 commit 0631f5e
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 9 deletions.
2 changes: 1 addition & 1 deletion batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def parse_args():
parser.add_argument('--mindate', type=str, default='2019-12-01',
help='option, earliest possible sample collection date (ISO format, default '
'2019-12-01')
parser.add_argument('--poisson-cutoff', type=float, default=0.001,
parser.add_argument('--poisson-cutoff', type=float, default=0,
help='option, filtering outlying genomes whose distance exceeds the upper '
'quantile of Poisson distribution (molecular clock). Default 0.001 '
'corresponds to 99.9%% cutoff.')
Expand Down
6 changes: 5 additions & 1 deletion covizu/utils/batch_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ def unpack_records(records):
# reconstitute the mutations defining this variant
diffs = []
for mutation in key.split(','):
typ, pos, alt = mutation.split('|')
try:
typ, pos, alt = mutation.split('|')
except ValueError:
# Handle case when there are no diffs
continue
if typ == '-':
alt = int(alt) # number of nucleotides in indel
diffs.append(tuple([typ, int(pos), alt]))
Expand Down
9 changes: 7 additions & 2 deletions covizu/utils/gisaid_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,10 @@ def filter_problematic(records, origin='2019-12-01', rate=0.0655, cutoff=0.005,
if not encoded:
record['diffs'] = filtered

# Exclude sequences with no mutations. See issue #530
if len(record['diffs']) == 0:
continue

# exclude genomes with excessive divergence from reference
coldate = record['covv_collection_date']
if qp.is_outlier(coldate, ndiffs):
Expand Down Expand Up @@ -332,8 +336,9 @@ def convert_json(infile, provision):
md = metadata.get(accn, None)
if md is None:
print("Failed to retrieve metadata for accession {}".format(accn))
sys.exit()
revised.append([name, accn, location, coldate, md['gender'], md['age'], md['status']])
revised.append([name, accn, location, coldate, 'N/A', 'N/A', 'N/A'])
else:
revised.append([name, accn, location, coldate, md['gender'], md['age'], md['status']])

# replace list of samples
cluster['nodes'][variant] = revised
Expand Down
4 changes: 4 additions & 0 deletions covizu/utils/seq_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ def lookup(self, time, timepoints):
return bisect.bisect(timepoints, time)

def is_outlier(self, coldate, ndiffs):
# Return False if cutoff = 0
if self.lowerq == 0:
return False

if type(coldate) is str:
coldate = fromisoformat(coldate)
dt = (coldate - self.origin).days
Expand Down
10 changes: 7 additions & 3 deletions js/beadplot.js
Original file line number Diff line number Diff line change
Expand Up @@ -1167,9 +1167,13 @@ function gen_details_table(obj) {
.style("opacity", 0.9);

let tooltipText = "";
tooltipText = `<b>${i18n_text.sample_orig_lab}:</b> ${gd.covv_orig_lab}<br/>`;
tooltipText += `<b>${i18n_text.sample_subm_lab}:</b> ${gd.covv_subm_lab}<br/>`;
tooltipText += `<b>${i18n_text.sample_authors}:</b> ${gd.covv_authors}`;
if (Object.keys(gd).length === 0) {
tooltipText = `GISAID API call did not return data for this accession number`;
} else {
tooltipText = `<b>${i18n_text.sample_orig_lab}:</b> ${gd.covv_orig_lab}<br/>`;
tooltipText += `<b>${i18n_text.sample_subm_lab}:</b> ${gd.covv_subm_lab}<br/>`;
tooltipText += `<b>${i18n_text.sample_authors}:</b> ${gd.covv_authors}`;
}

// Tooltip appears 10 pixels left of the cursor
cTooltip.html(tooltipText)
Expand Down
5 changes: 4 additions & 1 deletion js/gisaid/gisaid.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,10 @@ var gisaid = gisaid || (function () {
.then(ackData => {
this.ackCache[ackLink] = ackData ;
cb(ackData);
});
})
.catch(e => {
cb({});
});
} else {
cb(this.ackCache[ackLink]);
}
Expand Down
2 changes: 1 addition & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ app.get('/api/regionmap', (req, res) => {
})

app.get('/api/cid/:accession', (req, res) => {
dbManager.get_accession(req.params.accession).then(result=>{
dbManager.get_accession(req.params.accession.toUpperCase()).then(result=>{
res.send(result);
})
});
Expand Down

0 comments on commit 0631f5e

Please sign in to comment.