Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dom2BGC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tracanna, Vittorio
dom2BGC
Commits
f82bf36b
Commit
f82bf36b
authored
5 years ago
by
Tracanna, Vittorio
Browse files
Options
Downloads
Patches
Plain Diff
Replace amplicon_pipeline.py
parent
0a7646eb
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
amplicon_pipeline.py
+21
-18
21 additions, 18 deletions
amplicon_pipeline.py
with
21 additions
and
18 deletions
amplicon_pipeline.py
+
21
−
18
View file @
f82bf36b
...
@@ -71,14 +71,14 @@ def load_amplicons(feature_table_index, argOptions):
...
@@ -71,14 +71,14 @@ def load_amplicons(feature_table_index, argOptions):
amplicons_list
=
[[
x
.
split
(
'
\n
'
)[
0
],
x
.
split
(
'
\n
'
)[
1
]]
for
x
in
amplicons
.
split
(
'
>
'
)[
1
:]
if
x
.
split
(
'
\n
'
)[
0
]
in
feature_table_index
]
amplicons_list
=
[[
x
.
split
(
'
\n
'
)[
0
],
x
.
split
(
'
\n
'
)[
1
]]
for
x
in
amplicons
.
split
(
'
>
'
)[
1
:]
if
x
.
split
(
'
\n
'
)[
0
]
in
feature_table_index
]
mibig_amplicons
=
open
(
argOptions
[
'
MiBIGAmplicons
'
]).
read
()
mibig_amplicons
=
open
(
argOptions
[
'
MiBIGAmplicons
'
]).
read
()
mibig_amplicons_list
=
[[
x
.
split
(
'
\n
'
)[
0
],
x
.
split
(
'
\n
'
)[
1
]]
for
x
in
mibig_amplicons
.
split
(
'
>
'
)[
1
:]]
mibig_amplicons_list
=
[[
x
.
split
(
'
\n
'
)[
0
],
x
.
split
(
'
\n
'
)[
1
]]
for
x
in
mibig_amplicons
.
split
(
'
>
'
)[
1
:]]
antismasdb_amplicons
=
open
(
argOptions
[
'
antismashDBAmplicons
'
]).
read
()
antismas
h
db_amplicons
=
open
(
argOptions
[
'
antismashDBAmplicons
'
]).
read
()
a
=
[[
x
.
split
(
'
\n
'
)[
0
],
x
.
split
(
'
\n
'
)[
1
]]
for
x
in
antismasdb_amplicons
.
split
(
'
>
'
)[
1
:]]
a
ntismashdb_amplicons_list
=
[[
x
.
split
(
'
\n
'
)[
0
],
x
.
split
(
'
\n
'
)[
1
]]
for
x
in
antismas
h
db_amplicons
.
split
(
'
>
'
)[
1
:]]
if
argOptions
[
'
metagenomeAmplicons
'
]:
if
argOptions
[
'
metagenomeAmplicons
'
]:
metagenome_amplicons
=
open
(
argOptions
[
'
metagenomeAmplicons
'
]).
read
()
metagenome_amplicons
=
open
(
argOptions
[
'
metagenomeAmplicons
'
]).
read
()
metagenome_amplicons_list
=
[[
x
.
split
(
'
\n
'
)[
0
],
x
.
split
(
'
\n
'
)[
1
]]
for
x
in
metagenome_amplicons
.
split
(
'
>
'
)[
1
:]]
metagenome_amplicons_list
=
[[
x
.
split
(
'
\n
'
)[
0
],
x
.
split
(
'
\n
'
)[
1
]]
for
x
in
metagenome_amplicons
.
split
(
'
>
'
)[
1
:]]
else
:
else
:
metagenome_amplicons_list
=
[]
metagenome_amplicons_list
=
[]
return
amplicons_list
,
mibig_amplicons_list
,
antismashdb_amplicon_list
,
metagenome_amplicons_list
return
amplicons_list
,
mibig_amplicons_list
,
antismashdb_amplicon
s
_list
,
metagenome_amplicons_list
def
group_similar_amplicons
(
feature_table
,
amplicon_list
,
argOptions
):
def
group_similar_amplicons
(
feature_table
,
amplicon_list
,
argOptions
):
'''
'''
...
@@ -442,21 +442,24 @@ def parse_taxonomy(amp_taxonomy, outputFolder):
...
@@ -442,21 +442,24 @@ def parse_taxonomy(amp_taxonomy, outputFolder):
:param amp_taxonomy:
:param amp_taxonomy:
:return:
:return:
'''
'''
NCBI
=
NCBITaxa
()
if
not
os
.
path
.
isfile
(
'
{}antismashdb2_taxa_df.p
'
.
format
(
outputFolder
)):
canonical_groups
=
[
'
superkingdom
'
,
'
phylum
'
,
'
class
'
,
'
order
'
,
'
family
'
,
'
genus
'
,
'
species
'
]
NCBI
=
NCBITaxa
()
taxa_df
=
pd
.
DataFrame
(
0
,
index
=
amp_taxonomy
.
keys
(),
columns
=
canonical_groups
)
canonical_groups
=
[
'
superkingdom
'
,
'
phylum
'
,
'
class
'
,
'
order
'
,
'
family
'
,
'
genus
'
,
'
species
'
]
for
amp
in
amplicon_taxonomy
:
taxa_df
=
pd
.
DataFrame
(
0
,
index
=
amp_taxonomy
.
keys
(),
columns
=
canonical_groups
)
try
:
for
amp
in
amplicon_taxonomy
:
ptaxa
=
amplicon_taxonomy
[
amp
][
2
:
-
3
]
try
:
ancestors
=
NCBI
.
get_lineage
(
ptaxa
)
ptaxa
=
amplicon_taxonomy
[
amp
][
2
:
-
3
]
#names = NCBI.get_taxid_translator(ancestors)
ancestors
=
NCBI
.
get_lineage
(
ptaxa
)
ranks
=
NCBI
.
get_rank
(
ancestors
)
#names = NCBI.get_taxid_translator(ancestors)
inv_ranks
=
{
v
:
k
for
k
,
v
in
ranks
.
items
()}
ranks
=
NCBI
.
get_rank
(
ancestors
)
_canonical
=
[
x
for
x
in
canonical_groups
if
x
in
inv_ranks
.
keys
()]
inv_ranks
=
{
v
:
k
for
k
,
v
in
ranks
.
items
()}
taxa_df
.
loc
[
amp
,
_canonical
]
=
[
inv_ranks
[
x
]
for
x
in
_canonical
]
_canonical
=
[
x
for
x
in
canonical_groups
if
x
in
inv_ranks
.
keys
()]
except
(
TypeError
,
ValueError
)
as
error
:
taxa_df
.
loc
[
amp
,
_canonical
]
=
[
inv_ranks
[
x
]
for
x
in
_canonical
]
continue
except
(
TypeError
,
ValueError
)
as
error
:
pickle
.
dump
(
taxa_df
,
open
(
'
{}antismashdb2_taxa_df.p
'
.
format
(
outputFolder
),
'
wb
'
))
continue
pickle
.
dump
(
taxa_df
,
open
(
'
{}antismashdb2_taxa_df.p
'
.
format
(
outputFolder
),
'
wb
'
))
else
:
taxa_df
=
pickle
.
load
(
open
(
'
{}antismashdb2_taxa_df.p
'
.
format
(
outputFolder
),
'
rb
'
))
return
taxa_df
return
taxa_df
def
assign_taxonomy_to_amplicons
(
matches
,
taxa_df
,
outputFolder
):
def
assign_taxonomy_to_amplicons
(
matches
,
taxa_df
,
outputFolder
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment