Skip to content

Commit

Permalink
Solve GI phase out and FutureDeprecation warning
Browse files Browse the repository at this point in the history
This was (presumably) the last piece of code to change to make the
whole pipeline work without GIs after their phase out. Further,
`sort_values` is used instead of `order` from `pandas`, thus squashing
the warning that appeared.

Fix #16 and fix #17.
  • Loading branch information
ozagord committed Apr 19, 2017
1 parent be2dc77 commit 76ec343
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions virmet/covplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@


def best_species(orgs_file, organism):
orgs_list = pd.read_csv(orgs_file, sep=',', header=0)
orgs_list = pd.read_csv(orgs_file, sep='\t', header=0)
# assert decreasing sorted
diff = orgs_list['0'] - orgs_list['0'].shift(1)
diff = orgs_list['reads'] - orgs_list['reads'].shift(1)
assert (diff > 0).sum() == 0, diff
# criterion is "startswith"
# criterion = orgs_list['sscinames'].map(lambda x: x.startswith(organism))
criterion = orgs_list.iloc[:, 0].str.startswith(organism).fillna(False)
matching_orgs = orgs_list[criterion]
# organism matching that given on command line with most reads is the first
# W.O. this assumes descending order of reads
return str(matching_orgs.iloc[0].sscinames)
return str(matching_orgs.iloc[0].organism)


def main(args):
Expand All @@ -37,10 +37,9 @@ def main(args):
blast_file = os.path.join(outdir, 'unique.tsv.gz')
unique = pd.read_csv(blast_file, sep='\t', header=0, compression='gzip')
matching_reads = unique[unique['sscinames'] == best_spec]
best_seqids = matching_reads.groupby('sseqid').size().order(ascending=False)
best_seqids = matching_reads.groupby('sseqid').size().sort_values(ascending=False)

# TODO: upgrade for NCBI outphase of GI
gi, dsc, acc = str(best_seqids.index.tolist()[0]).split('|')[1:4]
dsc, acc = str(best_seqids.index.tolist()[0]).split('|')[:2]

# copy single genome, index, align viral_reads
os.chdir(outdir)
Expand Down

0 comments on commit 76ec343

Please sign in to comment.