Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
genotoul-bioinfo
jflow
Commits
0a2d2ab2
Commit
0a2d2ab2
authored
Oct 08, 2013
by
Jerome Mariette
Browse files
No commit message
No commit message
parent
da8e5fd1
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/jflow/featureio.py
View file @
0a2d2ab2
...
...
@@ -20,7 +20,7 @@ import os
from
jflow.xopen
import
xopen
from
jflow.seqio
import
FormatError
from
jflow.seqio
import
UnknownFileType
import
re
def
boolify
(
s
):
return
{
'True'
:
True
,
'False'
:
False
}[
s
]
...
...
@@ -94,7 +94,9 @@ class GFF3Reader(_AbstractFeatureReader):
if
len
(
row
)
!=
9
:
raise
FormatError
(
'Invalid number of columns in your GFF3 file {0}'
.
format
(
len
(
row
)))
attributes
=
{}
if
row
[
8
]
and
row
[
8
]
!=
'.'
:
attributes
=
{
p
.
split
(
'='
)[
0
]
:
p
.
split
(
'='
)[
1
]
for
p
in
row
[
8
].
split
(
';'
)}
for
p
in
row
[
8
].
split
(
';'
)
:
if
p
!=
""
:
attributes
[
p
.
split
(
'='
)[
0
]]
=
p
.
split
(
'='
)[
1
]
return
Entry
(
**
{
'seqid'
:
row
[
0
],
'source'
:
row
[
1
],
'type'
:
row
[
2
],
'start'
:
int
(
row
[
3
]),
'end'
:
int
(
row
[
4
]),
'score'
:
row
[
5
],
'strand'
:
row
[
6
],
'phase'
:
row
[
7
],
'attributes'
:
attributes
})
...
...
@@ -251,12 +253,12 @@ class VCFReader(_AbstractFeatureReader):
if
row
[
7
]
!=
'.'
:
variation
.
addattr
(
'info'
,
{
p
.
split
(
'='
)[
0
]
:
autocast
(
p
.
split
(
'='
)[
1
])
for
p
in
row
[
7
].
split
(
';'
)
})
regexp_none
=
re
.
compile
(
"\.(\/\.)*"
)
format
=
row
[
8
].
split
(
':'
)
for
lib_infos
in
range
(
9
,
len
(
row
))
:
if
row
[
lib_infos
]
not
in
[
'.'
,
'./.'
]
:
if
not
regexp_none
.
match
(
row
[
lib_infos
])
:
sformat
=
row
[
lib_infos
].
split
(
':'
)
variation
.
samples
.
append
(
Entry
(
**
{
autocast
(
format
[
i
])
:
autocast
(
sformat
[
i
])
for
i
in
range
(
0
,
len
(
format
))
}
)
)
variation
.
samples
.
append
(
Entry
(
**
{
autocast
(
format
[
i
])
:
autocast
(
sformat
[
i
])
if
sformat
[
i
]
!=
'.'
else
None
for
i
in
range
(
0
,
len
(
format
))
}
)
)
else
:
variation
.
samples
.
append
(
Entry
(
**
{
autocast
(
format
[
i
])
:
None
for
i
in
range
(
0
,
len
(
format
))
})
)
return
variation
...
...
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