Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Jan Hoeckesfeld
Snakemake Ngs Spa Typing
Commits
7b196446
Commit
7b196446
authored
Oct 19, 2020
by
Jan Hoeckesfeld
Browse files
added proper spatype.txt corruption errormessage
parent
49b482e9
Changes
1
Hide whitespace changes
Inline
Side-by-side
scripts/spaTypesToSequences.py
View file @
7b196446
from
Bio
import
SeqIO
import
re
from
Bio
import
SeqIO
regSpaTypes
=
re
.
compile
(
r
'((t[0-9]+,)([0-9][0-9])+(-[0-9])*)'
)
#Load repeat sequences in fasta format
repeats
=
SeqIO
.
parse
(
snakemake
.
input
[
'repeats'
],
'fasta'
)
#
Load repeat sequences in fasta format
repeats
=
SeqIO
.
parse
(
snakemake
.
input
[
'repeats'
],
'fasta'
)
repeatsDict
=
{}
filterList
=
[]
#Pre-Process Repeats
#
Pre-Process Repeats
if
'filterList'
in
snakemake
.
input
:
with
open
(
snakemake
.
input
[
'filterList'
],
'r'
)
as
infile
:
filterList
=
infile
.
read
().
split
(
','
)
with
open
(
snakemake
.
input
[
'filterList'
],
'r'
)
as
infile
:
filterList
=
infile
.
read
().
split
(
','
)
for
repeat
in
repeats
:
repeatsDict
[
repeat
.
id
[
1
:]]
=
str
(
repeat
.
seq
)
with
open
(
snakemake
.
input
[
'types'
],
'r'
)
as
infile
,
open
(
snakemake
.
output
[
'out'
],
'w'
)
as
outfile
:
spaTypes
=
infile
.
read
().
splitlines
()
spaTypesExtended
=
[]
for
line
,
spaType
in
enumerate
(
spaTypes
):
if
not
regSpaTypes
.
match
(
spaType
):
print
(
"spaType in spatypes"
+
" does not fit into the pattern: "
+
spaType
+
"in line "
+
str
(
line
+
1
))
split
=
spaType
.
split
(
','
)
name
=
split
[
0
]
if
len
(
filterList
)
>
0
:
if
not
name
in
filterList
:
continue
value
=
split
[
1
]
sptRepeats
=
value
.
split
(
'-'
)
if
not
sptRepeats
:
continue
sequence
=
''
for
repeat
in
sptRepeats
:
if
repeat
not
in
repeatsDict
:
print
(
"Unrecoginized repeat in spatype "
+
repeat
+
", found in line "
+
str
(
line
+
1
))
sequence
+=
repeatsDict
[
repeat
]
outfile
.
write
(
'>'
+
name
+
'
\n
'
+
sequence
+
'
\n
'
)
repeatsDict
[
repeat
.
id
[
1
:]]
=
str
(
repeat
.
seq
)
with
open
(
snakemake
.
input
[
'types'
],
'r'
)
as
infile
,
open
(
snakemake
.
output
[
'out'
],
'w'
)
as
outfile
:
spaTypes
=
infile
.
read
().
splitlines
()
spaTypesExtended
=
[]
for
line
,
spaType
in
enumerate
(
spaTypes
):
if
not
regSpaTypes
.
match
(
spaType
):
print
(
"spaType in spatypes"
+
" does not fit into the pattern: "
+
spaType
+
"in line "
+
str
(
line
+
1
))
split
=
spaType
.
split
(
','
)
name
=
split
[
0
]
if
len
(
filterList
)
>
0
:
if
not
name
in
filterList
:
continue
value
=
split
[
1
]
sptRepeats
=
value
.
split
(
'-'
)
if
not
sptRepeats
:
continue
sequence
=
''
for
repeat
in
sptRepeats
:
if
repeat
not
in
repeatsDict
:
print
(
"Unrecoginized repeat in spatype "
+
repeat
+
", found in line "
+
str
(
line
+
1
))
sequence
+=
repeatsDict
[
repeat
]
outfile
.
write
(
'>'
+
name
+
'
\n
'
+
sequence
+
'
\n
'
)
Write
Preview
Supports
Markdown
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