Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mutalyzer
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
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
Mirrors
mutalyzer
Commits
1b8ed5e9
Commit
1b8ed5e9
authored
9 years ago
by
Vermaat
Browse files
Options
Downloads
Patches
Plain Diff
Improve file type detection when reading DNA
parent
7f009cbd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mutalyzer/util.py
+18
-5
18 additions, 5 deletions
mutalyzer/util.py
with
18 additions
and
5 deletions
mutalyzer/util.py
+
18
−
5
View file @
1b8ed5e9
...
@@ -357,15 +357,28 @@ def guess_file_type(handle):
...
@@ -357,15 +357,28 @@ def guess_file_type(handle):
"""
"""
Guess the file type of an NGS data file.
Guess the file type of an NGS data file.
We assume that the stream is rewinded before use, after use, the input
:arg file handle: Open readable handle to an NGS data file.
stream will be rewinded.
:arg stream handle: Open readable handle to an NGS data file.
:returns unicode: Either
'
fasta
'
,
'
fastq
'
or
'
text
'
.
:returns unicode: Either
'
fasta
'
,
'
fastq
'
or
'
text
'
.
"""
"""
try
:
extension
=
getattr
(
handle
,
'
name
'
).
split
(
'
.
'
)[
-
1
]
except
AttributeError
:
pass
else
:
if
extension
in
(
'
fastq
'
,
'
fq
'
):
return
'
fastq
'
elif
extension
in
(
'
fasta
'
,
'
fa
'
):
return
'
fasta
'
try
:
position
=
handle
.
tell
()
handle
.
seek
(
0
)
except
IOError
:
return
'
text
'
token
=
handle
.
read
(
1
)
token
=
handle
.
read
(
1
)
handle
.
seek
(
0
)
handle
.
seek
(
position
)
if
token
==
'
>
'
:
if
token
==
'
>
'
:
return
'
fasta
'
return
'
fasta
'
...
...
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