Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nested
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Matej Lexa
nested
Commits
c751af74
There was an error fetching the commit references. Please try again later.
Commit
c751af74
authored
7 years ago
by
rlapar
Browse files
Options
Downloads
Patches
Plain Diff
main exception handling
parent
493e3575
No related branches found
No related tags found
1 merge request
!6
Reengineering
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
main.py
+17
-10
17 additions, 10 deletions
main.py
python/sketch.py
+5
-1
5 additions, 1 deletion
python/sketch.py
with
22 additions
and
11 deletions
main.py
+
17
−
10
View file @
c751af74
...
...
@@ -4,6 +4,8 @@ import sys
import
os
import
shutil
import
click
from
datetime
import
datetime
from
subprocess
import
CalledProcessError
from
Bio
import
SeqIO
...
...
@@ -24,34 +26,39 @@ def cleanup():
@click.option
(
'
--input_fasta
'
,
'
-i
'
,
required
=
True
,
type
=
str
,
help
=
'
Input fasta file.
'
)
@click.option
(
'
--sketch_only
'
,
'
-s
'
,
is_flag
=
True
)
def
main
(
input_fasta
,
sketch_only
):
numberOfErrors
=
0
startTime
=
datetime
.
now
()
setup
()
#RUN
sequences
=
list
(
SeqIO
.
parse
(
open
(
input_fasta
),
'
fasta
'
))
for
sequence
in
sequences
:
seqStartTime
=
datetime
.
now
()
print
(
'
Processing {}...
'
.
format
(
sequence
.
id
),
end
=
'
\r
'
)
try
:
if
not
os
.
path
.
exists
(
'
data/{}
'
.
format
(
sequence
.
id
)):
os
.
makedirs
(
'
data/{}
'
.
format
(
sequence
.
id
))
if
not
os
.
path
.
exists
(
'
data/{}/TE
'
.
format
(
sequence
.
id
)):
os
.
makedirs
(
'
data/{}/TE
'
.
format
(
sequence
.
id
))
print
(
'
Running Nester for {}...
'
.
format
(
sequence
.
id
))
if
not
sketch_only
:
nester
=
Nester
(
sequence
)
#for a in nester.nestedList:
# print(a)
# for b in a.features['domains']:
# print('--------------------')
# print(b)
# print('##########################')
sketch
.
createGFF
(
sequence
.
id
,
sequence
.
seq
,
nester
.
nestedList
)
sketch
.
sketch
(
sequence
.
id
)
seqEndTime
=
datetime
.
now
()
print
(
'
Processing {}: done [{}]
'
.
format
(
sequence
.
id
,
seqEndTime
-
seqStartTime
))
except
KeyboardInterrupt
:
raise
#except:
# print('Unexpected error:', sys.exc_info()[0])
except
CalledProcessError
:
numberOfErrors
+=
1
print
(
'
Processing {}: SUBPROCESS ERROR
'
.
format
(
sequence
.
id
))
except
:
numberOfErrors
+=
1
print
(
'
Processing {}: UNEXPECTED ERROR:
'
.
format
(
sequence
.
id
),
sys
.
exc_info
()[
0
])
cleanup
()
endTime
=
datetime
.
now
()
print
(
'
Total time: {}
'
.
format
(
endTime
-
startTime
))
print
(
'
Number of errors: {}
'
.
format
(
numberOfErrors
))
if
__name__
==
'
__main__
'
:
main
()
\ No newline at end of file
This diff is collapsed.
Click to expand it.
python/sketch.py
+
5
−
1
View file @
c751af74
import
os
import
subprocess
from
Bio
import
SeqIO
...
...
@@ -83,5 +84,8 @@ def createGFF(id, sequence, nestedList):
GFF
.
write
([
rec
],
out_handle
)
def
sketch
(
id
):
process
=
subprocess
.
Popen
([
config
.
gt_sketch_path
]
+
config
.
gt_sketch_args
+
[
'
data/{}/{}.png
'
.
format
(
id
,
id
)]
+
[
'
data/{}/{}.gff
'
.
format
(
id
,
id
)])
null
=
open
(
os
.
devnull
,
'
w
'
)
process
=
subprocess
.
check_output
([
config
.
gt_sketch_path
]
+
config
.
gt_sketch_args
+
[
'
data/{}/{}.png
'
.
format
(
id
,
id
)]
+
[
'
data/{}/{}.gff
'
.
format
(
id
,
id
)],
stderr
=
null
)
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