Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MRG: update sourmash and snakemake dependencies #239

Open
wants to merge 9 commits into
base: latest
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:

strategy:
matrix:
python: [3.9]
python: ["3.10"]

name: Python ${{ matrix.python }}

Expand Down
4 changes: 2 additions & 2 deletions charcoal/Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# --configfile must be specified on command line.
#
# CTB TODO: bring CLI improvements from grist over (@toplevel, etc.)
import csv, sys, os, json
import csv, sys, os, json, urllib
from snakemake.workflow import srcdir
from charcoal.utils import CSV_DictHelper

Expand Down Expand Up @@ -217,7 +217,7 @@ class Checkpoint_HitListPairs:
###

wildcard_constraints:
size="\d+",
size="\\d+",
g='[a-zA-Z0-9._-]+' # should be everything but /

# default rule: build report index
Expand Down
16 changes: 5 additions & 11 deletions charcoal/compare_taxonomy.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

import sourmash
from sourmash.lca.command_index import load_taxonomy_assignments
from sourmash.lca import LCA_Database, LineagePair
from sourmash.lca import LCA_Database
from sourmash.tax.tax_utils import LineagePair

from . import utils
from .lineage_db import LineageDB
Expand Down Expand Up @@ -124,16 +125,9 @@ def get_genome_taxonomy(matches_filename, database_list,
genome_sig_filename, provided_lineage,
tax_assign, match_rank, min_f_ident, min_f_major):
# load the matches from prefetch as a picklist
picklist = sourmash.picklist.SignaturePicklist('prefetch')
try:
picklist.load(matches_filename, picklist.column_name)
except ValueError:
with open(matches_filename, 'rt') as fp:
contents = fp.read()
if not len(contents): # empty is ok.
picklist = None
else:
raise
picklist = sourmash.picklist.SignaturePicklist('prefetch',
pickfile=matches_filename)
picklist.load(allow_empty=True)

# load all of the matches in the database, as found by prefetch;
# select on them; and then aggregate into MultiIndex.
Expand Down
4 changes: 2 additions & 2 deletions charcoal/conf/env-reporting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ channels:
- bioconda
- defaults
dependencies:
- python>=3.8
- python>=3.10
- papermill>=2.1.2,<3
- notebook>=6,<7
- matplotlib=3.5.2
- plotly>=4.9.0,<5
- ipykernel
- sourmash>=4.4.3,<5
- sourmash>=4.8.4,<5
- pip
- pip:
- git+https://github.com/dib-lab/charcoal.git
Expand Down
3 changes: 1 addition & 2 deletions charcoal/conf/env-sourmash.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ channels:
- bioconda
- defaults
dependencies:
- python>=3.7,<3.10
- pytest>6,<7
- pytest-dependency>=0.5.1
- pyyaml>5.3,<6
- sourmash>=4.4.3,<5
- sourmash>=4.8.4,<5
- pip
- pip:
- git+https://github.com/dib-lab/charcoal.git
Expand Down
10 changes: 7 additions & 3 deletions charcoal/contigs_list_contaminants.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ def main(args):
genome_sig = sourmash.load_one_signature(args.genome_sig)

# load the matches from prefetch as a picklist
picklist = sourmash.picklist.SignaturePicklist('prefetch')
picklist.load(args.matches_csv, picklist.column_name)
picklist = sourmash.picklist.SignaturePicklist('prefetch',
pickfile=args.matches_csv)
picklist.load()

# load all of the matches in the database, as found by prefetch;
# select on them; and then aggregate into MultiIndex.
Expand Down Expand Up @@ -130,7 +131,10 @@ def main(args):
ident = get_ident(ss)
lineage = tax_assign[ident]

lca_db.insert(ss, ident=ident)
try:
lca_db.insert(ss, ident=ident)
except ValueError:
continue
lin_db.insert(ident, lineage)

print(f'loaded {len(siglist)} signatures & created LCA Database')
Expand Down
13 changes: 3 additions & 10 deletions charcoal/contigs_search_taxonomy.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,9 @@ def main(args):
genome_sig = sourmash.load_one_signature(args.genome_sig)

# load the matches from prefetch as a picklist
picklist = sourmash.picklist.SignaturePicklist('prefetch')
try:
picklist.load(args.matches_csv, picklist.column_name)
except ValueError:
with open(args.matches_csv, 'rt') as fp:
contents = fp.read()
if not len(contents): # empty is ok.
picklist = None
else:
raise
picklist = sourmash.picklist.SignaturePicklist('prefetch',
pickfile=args.matches_csv)
picklist.load(allow_empty=True)

# load all of the matches in the database, as found by prefetch;
# select on them; and then aggregate into MultiIndex.
Expand Down
3 changes: 2 additions & 1 deletion charcoal/figs/sourmash_sankey.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from charcoal import utils
import sourmash
from sourmash.lca import taxlist, LineagePair
from sourmash.lca import taxlist
from sourmash.tax.tax_utils import LineagePair
import collections

import plotly.graph_objects as go
Expand Down
3 changes: 2 additions & 1 deletion charcoal/just_taxonomy.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@

import sourmash
from sourmash.lca.command_index import load_taxonomy_assignments
from sourmash.lca import LCA_Database, LineagePair
from sourmash.lca import LCA_Database
from sourmash.tax.tax_utils import LineagePair

from . import utils
from . import lineage_db
Expand Down
4 changes: 2 additions & 2 deletions charcoal/lineage_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import functools
import pytest

from sourmash.lca import LineagePair
from sourmash.tax.tax_utils import LineagePair


def cached_property(fun):
Expand Down Expand Up @@ -85,7 +85,7 @@ def __repr__(self):
@classmethod
def load(cls, db_name):
"Load LCA_Database from a JSON file."
from .lca_utils import taxlist, LineagePair
from .lca_utils import taxlist

xopen = open
if db_name.endswith('.gz'):
Expand Down
4 changes: 2 additions & 2 deletions charcoal/notebooks/report-genome.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"\n",
"import plotly.graph_objects as go\n",
"\n",
"import sourmash\n",
"import sourmash, sourmash.lca.lca_utils\n",
"from charcoal import utils\n",
"from charcoal.figs.sourmash_sankey import GenomeSankeyFlow"
]
Expand Down Expand Up @@ -335,7 +335,7 @@
" if genome_lineage[-1].rank != 'genus':\n",
" genome_lineage = list(genome_lineage)\n",
" for rank in taxlist[len(genome_lineage):]:\n",
" genome_lineage.append(sourmash.lca.LineagePair(rank=rank, name='unassigned'))\n",
" genome_lineage.append(sourmash.lca.lca_utils.LineagePair(rank=rank, name='unassigned'))\n",
" \n",
" # set the color of the main lineage\n",
" genome_lineage = tuple(genome_lineage)\n",
Expand Down
8 changes: 5 additions & 3 deletions charcoal/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
import csv

import sourmash
from sourmash.lca import lca_utils, LineagePair, taxlist, display_lineage
from sourmash.lca import lca_utils, taxlist, display_lineage
from sourmash.tax.tax_utils import LineagePair
from sourmash.lca.lca_utils import (is_lineage_match, pop_to_rank,
make_lineage)

Expand Down Expand Up @@ -246,8 +247,9 @@ def load_contamination_summary(fp):
for k, items in x.items():
z = []
for source, target, count in items:
source = tuple([ LineagePair(rank, name) for rank, name in source ])
target = tuple([ LineagePair(rank, name) for rank, name in target ])
# get rank, name for each
source = tuple([ LineagePair(x[0], x[1]) for x in source ])
target = tuple([ LineagePair(x[0], x[1]) for x in target ])
z.append((source, target, count))
contam_d[k] = z

Expand Down
1 change: 1 addition & 0 deletions charcoal/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version = "0.1-dev"
Loading
Loading