Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
ecopcr
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
4
Issues
4
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OBITools
ecopcr
Commits
573bd5ba
Commit
573bd5ba
authored
Feb 06, 2017
by
Celine Mercier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed deprecated code in ecoPCRFormat
parent
17387dae
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
66 deletions
+7
-66
tools/ecoPCRFormat.py
tools/ecoPCRFormat.py
+7
-66
No files found.
tools/ecoPCRFormat.py
View file @
573bd5ba
#!/usr/bin/env python
#!/usr/bin/env python
2.7
import
re
import
gzip
...
...
@@ -7,11 +7,8 @@ import sys
import
time
import
getopt
try
:
import
psycopg2
_dbenable
=
True
except
ImportError
:
_dbenable
=
False
_dbenable
=
False
#####
#
...
...
@@ -221,56 +218,7 @@ def readTaxonomyDump(taxdir):
return
taxonomy
,
ranks
,
alternativeName
,
index
def
readTaxonomyDB
(
dbname
):
connection
=
psycopg2
.
connect
(
database
=
dbname
)
cursor
=
connection
.
cursor
()
cursor
.
execute
(
"select numid,rank,parent from ncbi_taxonomy.taxon"
)
taxonomy
=
[
list
(
x
)
for
x
in
cursor
]
cursor
.
execute
(
"select rank_class from ncbi_taxonomy.taxon_rank_class order by rank_class"
)
ranks
=
cursor
.
fetchall
()
ranks
=
dict
(
map
(
None
,(
x
[
0
]
for
x
in
ranks
),
xrange
(
len
(
ranks
))))
print
>>
sys
.
stderr
,
"Sorting taxons..."
taxonomy
.
sort
(
taxonCmp
)
print
>>
sys
.
stderr
,
"Indexing taxonomy..."
index
=
{}
for
t
in
taxonomy
:
index
[
t
[
0
]]
=
bsearchTaxon
(
taxonomy
,
t
[
0
])
print
>>
sys
.
stderr
,
"Indexing parent and rank..."
for
t
in
taxonomy
:
t
[
1
]
=
ranks
[
t
[
1
]]
try
:
t
[
2
]
=
index
[
t
[
2
]]
except
KeyError
,
e
:
if
t
[
2
]
is
None
and
t
[
0
]
==
1
:
t
[
2
]
=
index
[
t
[
0
]]
else
:
raise
e
cursor
.
execute
(
"select taxid,name,category from ncbi_taxonomy.name"
)
alternativeName
=
[]
for
taxid
,
name
,
classname
in
cursor
:
alternativeName
.
append
((
name
,
classname
,
index
[
taxid
]))
if
classname
==
'scientific name'
:
taxonomy
[
index
[
taxid
]].
append
(
name
)
cursor
.
execute
(
"select old_numid,current_numid from ncbi_taxonomy.taxon_id_alias"
)
print
>>
sys
.
stderr
,
"Adding taxid alias..."
for
taxid
,
current
in
cursor
:
if
current
is
not
None
:
index
[
taxid
]
=
index
[
current
]
else
:
index
[
taxid
]
=
None
return
taxonomy
,
ranks
,
alternativeName
,
index
#####
#
#
...
...
@@ -585,10 +533,9 @@ def ecoParseOptions(arguments):
}
o
,
filenames
=
getopt
.
getopt
(
arguments
,
'ht:
T:
n:gfe'
,
'ht:n:gfe'
,
[
'help'
,
'taxonomy='
,
'taxonomy_db='
,
'name='
,
'genbank'
,
'fasta'
,
...
...
@@ -601,9 +548,6 @@ def ecoParseOptions(arguments):
elif
name
in
(
'-t'
,
'--taxonomy'
):
opt
[
'taxmod'
]
=
'dump'
opt
[
'taxdir'
]
=
value
elif
name
in
(
'-T'
,
'--taxonomy_db'
):
opt
[
'taxmod'
]
=
'db'
opt
[
'taxdb'
]
=
value
elif
name
in
(
'-n'
,
'--name'
):
opt
[
'prefix'
]
=
value
elif
name
in
(
'-g'
,
'--genbank'
):
...
...
@@ -622,6 +566,7 @@ def ecoParseOptions(arguments):
return
opt
,
filenames
def
printHelp
():
print
"-----------------------------------"
print
" ecoPCRFormat.py"
...
...
@@ -641,11 +586,7 @@ if __name__ == '__main__':
opt
,
filenames
=
ecoParseOptions
(
sys
.
argv
[
1
:])
if
opt
[
'taxmod'
]
==
'dump'
:
taxonomy
=
readTaxonomyDump
(
opt
[
'taxdir'
])
elif
opt
[
'taxmod'
]
==
'db'
:
taxonomy
=
readTaxonomyDB
(
opt
[
'taxdb'
])
taxonomy
=
readTaxonomyDump
(
opt
[
'taxdir'
])
ecoDBWriter
(
opt
[
'prefix'
],
taxonomy
,
filenames
,
opt
[
'parser'
])
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment