mgnify-pipelines-toolkit 0.0.7__tar.gz → 0.0.9__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of mgnify-pipelines-toolkit might be problematic. Click here for more details.
- {mgnify_pipelines_toolkit-0.0.7 → mgnify_pipelines_toolkit-0.0.9}/PKG-INFO +1 -1
- {mgnify_pipelines_toolkit-0.0.7 → mgnify_pipelines_toolkit-0.0.9}/mgnify_pipelines_toolkit/analysis/amplicon/classify_var_regions.py +2 -2
- {mgnify_pipelines_toolkit-0.0.7 → mgnify_pipelines_toolkit-0.0.9}/mgnify_pipelines_toolkit/analysis/amplicon/make_asv_count_table.py +24 -11
- {mgnify_pipelines_toolkit-0.0.7 → mgnify_pipelines_toolkit-0.0.9}/mgnify_pipelines_toolkit/analysis/amplicon/remove_ambiguous_reads.py +23 -13
- {mgnify_pipelines_toolkit-0.0.7 → mgnify_pipelines_toolkit-0.0.9}/mgnify_pipelines_toolkit/analysis/amplicon/rev_comp_se_primers.py +4 -5
- {mgnify_pipelines_toolkit-0.0.7 → mgnify_pipelines_toolkit-0.0.9}/mgnify_pipelines_toolkit/analysis/shared/mapseq2biom.py +1 -1
- mgnify_pipelines_toolkit-0.0.9/mgnify_pipelines_toolkit/constants/tax_ranks.py +18 -0
- {mgnify_pipelines_toolkit-0.0.7 → mgnify_pipelines_toolkit-0.0.9}/mgnify_pipelines_toolkit.egg-info/PKG-INFO +1 -1
- {mgnify_pipelines_toolkit-0.0.7 → mgnify_pipelines_toolkit-0.0.9}/mgnify_pipelines_toolkit.egg-info/SOURCES.txt +2 -1
- {mgnify_pipelines_toolkit-0.0.7 → mgnify_pipelines_toolkit-0.0.9}/pyproject.toml +1 -1
- {mgnify_pipelines_toolkit-0.0.7 → mgnify_pipelines_toolkit-0.0.9}/LICENSE +0 -0
- {mgnify_pipelines_toolkit-0.0.7 → mgnify_pipelines_toolkit-0.0.9}/README.md +0 -0
- {mgnify_pipelines_toolkit-0.0.7 → mgnify_pipelines_toolkit-0.0.9}/mgnify_pipelines_toolkit/__init__.py +0 -0
- {mgnify_pipelines_toolkit-0.0.7 → mgnify_pipelines_toolkit-0.0.9}/mgnify_pipelines_toolkit/analysis/__init__.py +0 -0
- {mgnify_pipelines_toolkit-0.0.7 → mgnify_pipelines_toolkit-0.0.9}/mgnify_pipelines_toolkit/analysis/amplicon/amplicon_utils.py +0 -0
- {mgnify_pipelines_toolkit-0.0.7 → mgnify_pipelines_toolkit-0.0.9}/mgnify_pipelines_toolkit/analysis/amplicon/are_there_primers.py +0 -0
- {mgnify_pipelines_toolkit-0.0.7 → mgnify_pipelines_toolkit-0.0.9}/mgnify_pipelines_toolkit/analysis/amplicon/assess_inflection_point_mcp.py +0 -0
- {mgnify_pipelines_toolkit-0.0.7 → mgnify_pipelines_toolkit-0.0.9}/mgnify_pipelines_toolkit/analysis/amplicon/assess_mcp_proportions.py +0 -0
- {mgnify_pipelines_toolkit-0.0.7 → mgnify_pipelines_toolkit-0.0.9}/mgnify_pipelines_toolkit/analysis/amplicon/find_mcp_inflection_points.py +0 -0
- {mgnify_pipelines_toolkit-0.0.7 → mgnify_pipelines_toolkit-0.0.9}/mgnify_pipelines_toolkit/analysis/amplicon/standard_primer_matching.py +0 -0
- {mgnify_pipelines_toolkit-0.0.7 → mgnify_pipelines_toolkit-0.0.9}/mgnify_pipelines_toolkit/analysis/shared/__init__.py +0 -0
- {mgnify_pipelines_toolkit-0.0.7 → mgnify_pipelines_toolkit-0.0.9}/mgnify_pipelines_toolkit/analysis/shared/get_subunits.py +0 -0
- {mgnify_pipelines_toolkit-0.0.7 → mgnify_pipelines_toolkit-0.0.9}/mgnify_pipelines_toolkit/analysis/shared/get_subunits_coords.py +0 -0
- {mgnify_pipelines_toolkit-0.0.7 → mgnify_pipelines_toolkit-0.0.9}/mgnify_pipelines_toolkit/constants/regex_ambiguous_bases.py +0 -0
- {mgnify_pipelines_toolkit-0.0.7 → mgnify_pipelines_toolkit-0.0.9}/mgnify_pipelines_toolkit.egg-info/dependency_links.txt +0 -0
- {mgnify_pipelines_toolkit-0.0.7 → mgnify_pipelines_toolkit-0.0.9}/mgnify_pipelines_toolkit.egg-info/entry_points.txt +0 -0
- {mgnify_pipelines_toolkit-0.0.7 → mgnify_pipelines_toolkit-0.0.9}/mgnify_pipelines_toolkit.egg-info/requires.txt +0 -0
- {mgnify_pipelines_toolkit-0.0.7 → mgnify_pipelines_toolkit-0.0.9}/mgnify_pipelines_toolkit.egg-info/top_level.txt +0 -0
- {mgnify_pipelines_toolkit-0.0.7 → mgnify_pipelines_toolkit-0.0.9}/setup.cfg +0 -0
|
@@ -449,7 +449,7 @@ def parse_args(argv):
|
|
|
449
449
|
return parser.parse_args(argv)
|
|
450
450
|
|
|
451
451
|
|
|
452
|
-
def main(argv):
|
|
452
|
+
def main(argv=None):
|
|
453
453
|
t_start = time.perf_counter() # time the run
|
|
454
454
|
args = parse_args(argv)
|
|
455
455
|
if not os.path.isdir(args.output_dir):
|
|
@@ -481,7 +481,7 @@ def main(argv):
|
|
|
481
481
|
|
|
482
482
|
|
|
483
483
|
if __name__ == '__main__':
|
|
484
|
-
main(
|
|
484
|
+
main()
|
|
485
485
|
|
|
486
486
|
# don't print json
|
|
487
487
|
# name the tsv file better
|
|
@@ -16,8 +16,14 @@
|
|
|
16
16
|
|
|
17
17
|
import argparse
|
|
18
18
|
from collections import defaultdict
|
|
19
|
+
import logging
|
|
20
|
+
|
|
19
21
|
import pandas as pd
|
|
20
22
|
|
|
23
|
+
from mgnify_pipelines_toolkit.constants.tax_ranks import _SILVA_TAX_RANKS, _PR2_TAX_RANKS
|
|
24
|
+
|
|
25
|
+
logging.basicConfig(level=logging.DEBUG)
|
|
26
|
+
|
|
21
27
|
def parse_args():
|
|
22
28
|
|
|
23
29
|
parser = argparse.ArgumentParser()
|
|
@@ -43,10 +49,13 @@ def parse_args():
|
|
|
43
49
|
|
|
44
50
|
def order_df(taxa_df):
|
|
45
51
|
|
|
46
|
-
if len(taxa_df.columns) ==
|
|
47
|
-
taxa_df = taxa_df.sort_values(
|
|
52
|
+
if len(taxa_df.columns) == 8:
|
|
53
|
+
taxa_df = taxa_df.sort_values(_SILVA_TAX_RANKS, ascending=True)
|
|
48
54
|
elif len(taxa_df.columns) == 10:
|
|
49
|
-
taxa_df = taxa_df.sort_values(
|
|
55
|
+
taxa_df = taxa_df.sort_values(_PR2_TAX_RANKS, ascending=True)
|
|
56
|
+
else:
|
|
57
|
+
logging.error("Data frame not the right size, something wrong.")
|
|
58
|
+
exit(1)
|
|
50
59
|
|
|
51
60
|
return taxa_df
|
|
52
61
|
|
|
@@ -68,6 +77,7 @@ def make_tax_assignment_dict_silva(taxa_df, asv_dict):
|
|
|
68
77
|
o = taxa_df.loc[sorted_index, "Order"]
|
|
69
78
|
f = taxa_df.loc[sorted_index, "Family"]
|
|
70
79
|
g = taxa_df.loc[sorted_index, "Genus"]
|
|
80
|
+
s = taxa_df.loc[sorted_index, "Species"]
|
|
71
81
|
|
|
72
82
|
tax_assignment = ""
|
|
73
83
|
|
|
@@ -109,6 +119,11 @@ def make_tax_assignment_dict_silva(taxa_df, asv_dict):
|
|
|
109
119
|
if g != "0":
|
|
110
120
|
g = "_".join(g.split(" "))
|
|
111
121
|
tax_assignment += f"\tg__{g}"
|
|
122
|
+
else:
|
|
123
|
+
break
|
|
124
|
+
if s != "0":
|
|
125
|
+
s = "_".join(s.split(" "))
|
|
126
|
+
tax_assignment += f"\ts__{s}"
|
|
112
127
|
break
|
|
113
128
|
|
|
114
129
|
if tax_assignment == "":
|
|
@@ -147,10 +162,6 @@ def make_tax_assignment_dict_pr2(taxa_df, asv_dict):
|
|
|
147
162
|
if d != "0":
|
|
148
163
|
d = "_".join(d.split(" "))
|
|
149
164
|
tax_assignment += f"d__{d}"
|
|
150
|
-
# if d == "Archaea" or d == "Bacteria":
|
|
151
|
-
# tax_assignment += f"d__{d}"
|
|
152
|
-
# elif d == "Eukaryota":
|
|
153
|
-
# tax_assignment += f"d__Eukaryota"
|
|
154
165
|
else:
|
|
155
166
|
break
|
|
156
167
|
|
|
@@ -159,7 +170,6 @@ def make_tax_assignment_dict_pr2(taxa_df, asv_dict):
|
|
|
159
170
|
tax_assignment += f"\tsg__{sg}"
|
|
160
171
|
else:
|
|
161
172
|
break
|
|
162
|
-
|
|
163
173
|
if dv != "0":
|
|
164
174
|
dv = "_".join(dv.split(" "))
|
|
165
175
|
tax_assignment += f"\tdv__{dv}"
|
|
@@ -167,7 +177,6 @@ def make_tax_assignment_dict_pr2(taxa_df, asv_dict):
|
|
|
167
177
|
if sdv != "0":
|
|
168
178
|
sdv = "_".join(sdv.split(" "))
|
|
169
179
|
tax_assignment += f"\tsdv__{sdv}"
|
|
170
|
-
|
|
171
180
|
if c != "0":
|
|
172
181
|
c = "_".join(c.split(" "))
|
|
173
182
|
tax_assignment += f"\tc__{c}"
|
|
@@ -250,12 +259,16 @@ def main():
|
|
|
250
259
|
if paired_end:
|
|
251
260
|
rev_fr.close()
|
|
252
261
|
|
|
253
|
-
|
|
262
|
+
ref_db = ""
|
|
263
|
+
|
|
264
|
+
if len(taxa_df.columns) == 8:
|
|
254
265
|
tax_assignment_dict = make_tax_assignment_dict_silva(taxa_df, asv_dict)
|
|
266
|
+
ref_db = "silva"
|
|
255
267
|
elif len(taxa_df.columns) == 10:
|
|
256
268
|
tax_assignment_dict = make_tax_assignment_dict_pr2(taxa_df, asv_dict)
|
|
269
|
+
ref_db = "pr2"
|
|
257
270
|
|
|
258
|
-
with open(f"./{_SAMPLE}_{amp_region}_asv_krona_counts.txt", "w") as fw:
|
|
271
|
+
with open(f"./{_SAMPLE}_{amp_region}_{ref_db}_asv_krona_counts.txt", "w") as fw:
|
|
259
272
|
for tax_assignment, count in tax_assignment_dict.items():
|
|
260
273
|
fw.write(f"{count}\t{tax_assignment}\n")
|
|
261
274
|
|
|
@@ -21,14 +21,14 @@ import gzip
|
|
|
21
21
|
|
|
22
22
|
from Bio import SeqIO, bgzf
|
|
23
23
|
|
|
24
|
-
def parse_args(
|
|
24
|
+
def parse_args():
|
|
25
25
|
|
|
26
26
|
parser = argparse.ArgumentParser()
|
|
27
27
|
|
|
28
28
|
parser.add_argument("-f", "--fwd", required=True, type=str, help="Path to forward (or single-end) fastq file")
|
|
29
29
|
parser.add_argument("-r", "--rev", required=False, type=str, help="Path to reverse fastq file")
|
|
30
30
|
parser.add_argument("-s", "--sample", required=True, type=str, help="Sample ID")
|
|
31
|
-
args = parser.parse_args(
|
|
31
|
+
args = parser.parse_args()
|
|
32
32
|
|
|
33
33
|
_FWD = args.fwd
|
|
34
34
|
_REV = args.rev
|
|
@@ -37,9 +37,9 @@ def parse_args(argv=None):
|
|
|
37
37
|
return _FWD, _REV, _SAMPLE
|
|
38
38
|
|
|
39
39
|
|
|
40
|
-
def main(
|
|
40
|
+
def main():
|
|
41
41
|
|
|
42
|
-
_FWD, _REV, _SAMPLE = parse_args(
|
|
42
|
+
_FWD, _REV, _SAMPLE = parse_args()
|
|
43
43
|
|
|
44
44
|
fwd_handle = gzip.open(_FWD, "rt")
|
|
45
45
|
fwd_reads = SeqIO.to_dict(SeqIO.parse(fwd_handle, "fastq"))
|
|
@@ -54,25 +54,35 @@ def main(argv=None):
|
|
|
54
54
|
rev_reads = SeqIO.to_dict(SeqIO.parse(rev_handle, "fastq"))
|
|
55
55
|
rev_handle.close()
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
remove_set = set()
|
|
58
58
|
|
|
59
59
|
for read_id in fwd_reads.keys():
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
fwd_read_seq = str(fwd_reads[read_id].seq)
|
|
62
|
+
if len(fwd_read_seq) < 100:
|
|
63
|
+
remove_set.add(read_id)
|
|
64
64
|
continue
|
|
65
|
-
elif
|
|
65
|
+
elif "N" in fwd_read_seq:
|
|
66
66
|
print(read_id)
|
|
67
|
-
|
|
67
|
+
remove_set.add(read_id)
|
|
68
68
|
continue
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
if paired_end:
|
|
71
|
+
rev_read_seq = str(rev_reads[read_id].seq)
|
|
72
|
+
if len(rev_read_seq) < 100:
|
|
73
|
+
print(read_id)
|
|
74
|
+
remove_set.add(read_id)
|
|
75
|
+
continue
|
|
76
|
+
elif "N" in rev_read_seq:
|
|
77
|
+
print(read_id)
|
|
78
|
+
remove_set.add(read_id)
|
|
79
|
+
continue
|
|
80
|
+
|
|
81
|
+
[ fwd_reads.pop(read_id) for read_id in remove_set ]
|
|
71
82
|
if paired_end:
|
|
72
|
-
[ rev_reads.pop(read_id) for read_id in
|
|
83
|
+
[ rev_reads.pop(read_id) for read_id in remove_set ]
|
|
73
84
|
|
|
74
85
|
if paired_end:
|
|
75
|
-
|
|
76
86
|
fwd_handle = bgzf.BgzfWriter(f"./{_SAMPLE}_noambig_1.fastq.gz", "wb")
|
|
77
87
|
rev_handle = bgzf.BgzfWriter(f"./{_SAMPLE}_noambig_2.fastq.gz", "wb")
|
|
78
88
|
|
|
@@ -15,18 +15,17 @@
|
|
|
15
15
|
# limitations under the License.
|
|
16
16
|
|
|
17
17
|
import argparse
|
|
18
|
-
import sys
|
|
19
18
|
|
|
20
19
|
from Bio import Seq, SeqIO
|
|
21
20
|
|
|
22
|
-
def parse_args(
|
|
21
|
+
def parse_args():
|
|
23
22
|
|
|
24
23
|
parser = argparse.ArgumentParser()
|
|
25
24
|
|
|
26
25
|
parser.add_argument("-i", "--input", required=True, type=str, help="Path to finalised primer list fasta file")
|
|
27
26
|
parser.add_argument("-s", "--sample", required=True, type=str, help="Sample ID")
|
|
28
27
|
parser.add_argument("-o", "--output", required=True, type=str, help="Output path")
|
|
29
|
-
args = parser.parse_args(
|
|
28
|
+
args = parser.parse_args()
|
|
30
29
|
|
|
31
30
|
_INPUT = args.input
|
|
32
31
|
_SAMPLE = args.sample
|
|
@@ -34,9 +33,9 @@ def parse_args(argv=None):
|
|
|
34
33
|
|
|
35
34
|
return _INPUT, _SAMPLE, _OUTPUT
|
|
36
35
|
|
|
37
|
-
def main(
|
|
36
|
+
def main():
|
|
38
37
|
|
|
39
|
-
_INPUT, _SAMPLE, _OUTPUT = parse_args(
|
|
38
|
+
_INPUT, _SAMPLE, _OUTPUT = parse_args()
|
|
40
39
|
|
|
41
40
|
primers_dict = SeqIO.to_dict(SeqIO.parse(_INPUT, "fasta"))
|
|
42
41
|
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
|
|
4
|
+
# Copyright 2024 EMBL - European Bioinformatics Institute
|
|
5
|
+
#
|
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
# you may not use this file except in compliance with the License.
|
|
8
|
+
# You may obtain a copy of the License at
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
|
|
17
|
+
_SILVA_TAX_RANKS = ["Kingdom", "Phylum", "Class", "Order", "Family", "Genus", "Species"]
|
|
18
|
+
_PR2_TAX_RANKS = ["Domain", "Supergroup", "Division", "Subdivision", "Class", "Order", "Family", "Genus", "Species"]
|
|
@@ -23,4 +23,5 @@ mgnify_pipelines_toolkit/analysis/shared/__init__.py
|
|
|
23
23
|
mgnify_pipelines_toolkit/analysis/shared/get_subunits.py
|
|
24
24
|
mgnify_pipelines_toolkit/analysis/shared/get_subunits_coords.py
|
|
25
25
|
mgnify_pipelines_toolkit/analysis/shared/mapseq2biom.py
|
|
26
|
-
mgnify_pipelines_toolkit/constants/regex_ambiguous_bases.py
|
|
26
|
+
mgnify_pipelines_toolkit/constants/regex_ambiguous_bases.py
|
|
27
|
+
mgnify_pipelines_toolkit/constants/tax_ranks.py
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|