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
O
OBITools3
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
23
Issues
23
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
OBITools
OBITools3
Commits
7a88ca61
Commit
7a88ca61
authored
Apr 15, 2016
by
Celine Mercier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
First obi import (doesn't import tags yet because NA values aren't
handled)
parent
eddd19a2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
133 additions
and
0 deletions
+133
-0
python/obitools3/commands/import.pyx
python/obitools3/commands/import.pyx
+133
-0
No files found.
python/obitools3/commands/import.pyx
0 → 100644
View file @
7a88ca61
from
obitools3.apps.progress
cimport
ProgressBar
# @UnresolvedImport
from
obitools3.files.universalopener
cimport
uopen
from
obitools3.parsers.fasta
import
fastaIterator
from
obitools3.parsers.fastq
import
fastqIterator
from
obitools3.obidms._obidms
import
OBIDMS
import
time
__title__
=
"Counts sequences in a sequence set"
default_config
=
{
'destview'
:
None
,
'skip'
:
0
,
'only'
:
None
,
'skiperror'
:
False
,
'seqinformat'
:
None
,
'moltype'
:
'nuc'
,
'filename'
:
None
}
def
addOptions
(
parser
):
parser
.
add_argument
(
dest
=
'import:filename'
,
metavar
=
'<FILENAME>'
,
nargs
=
'?'
,
default
=
None
,
help
=
'sequence file name to be imported'
)
group
=
parser
.
add_argument_group
(
'obi import specific options'
)
group
.
add_argument
(
'--default-dms'
,
'-d'
,
action
=
"store"
,
dest
=
"obi:defaultdms"
,
metavar
=
'<DMS NAME>'
,
default
=
None
,
type
=
str
,
help
=
"Name of the default DMS for reading and writing data"
)
group
.
add_argument
(
'--destination-view'
,
'-v'
,
action
=
"store"
,
dest
=
"import:destview"
,
metavar
=
'<VIEW NAME>'
,
default
=
None
,
type
=
str
,
required
=
True
,
help
=
"Name of the default DMS for reading and writing data"
)
group
=
parser
.
add_argument_group
(
'obi import specific options'
)
group
.
add_argument
(
'--skip'
,
action
=
"store"
,
dest
=
"import:skip"
,
metavar
=
'<N>'
,
default
=
None
,
type
=
int
,
help
=
"skip the N first sequences"
)
group
.
add_argument
(
'--only'
,
action
=
"store"
,
dest
=
"import:only"
,
metavar
=
'<N>'
,
default
=
None
,
type
=
int
,
help
=
"treat only N sequences"
)
group
.
add_argument
(
'--skip-on-error'
,
action
=
"store_true"
,
dest
=
"import:skiperror"
,
default
=
None
,
help
=
"Skip sequence entries with parse error"
)
group
.
add_argument
(
'--fasta'
,
action
=
"store_const"
,
dest
=
"import:seqinformat"
,
default
=
None
,
const
=
'fasta'
,
help
=
"Input file is in fasta nucleic format (including obitools fasta extentions)"
)
group
.
add_argument
(
'--fastq'
,
action
=
"store_const"
,
dest
=
"import:seqinformat"
,
default
=
None
,
const
=
'fastq'
,
help
=
"Input file is in sanger fastq nucleic format (standard fastq)"
)
group
.
add_argument
(
'--nuc'
,
action
=
"store_const"
,
dest
=
"import:moltype"
,
default
=
None
,
const
=
'nuc'
,
help
=
"Input file contains nucleic sequences"
)
group
.
add_argument
(
'--prot'
,
action
=
"store_const"
,
dest
=
"import:moltype"
,
default
=
None
,
const
=
'pep'
,
help
=
"Input file contains protein sequences"
)
def
run
(
config
):
#pb = ProgressBar(1000,config,seconde=1)
print
(
config
)
inputs
=
uopen
(
config
[
'import'
][
'filename'
])
if
config
[
'import'
][
'seqinformat'
]
==
'fasta'
:
iseq
=
fastaIterator
(
inputs
)
view_type
=
"NUC_SEQS_VIEW"
elif
config
[
'import'
][
'seqinformat'
]
==
'fastq'
:
iseq
=
fastqIterator
(
inputs
)
view_type
=
"NUC_SEQS_VIEW"
else
:
raise
RuntimeError
(
'No file format specified'
)
# Create DMS
d
=
OBIDMS
(
config
[
'obi'
][
'defaultdms'
])
# Create view
view
=
d
.
new_view
(
config
[
'import'
][
'destview'
],
view_type
=
view_type
)
i
=
0
for
seq
in
iseq
:
#pb(i)
view
[
i
].
set_id
(
seq
[
'id'
])
view
[
i
].
set_definition
(
seq
[
'definition'
])
view
[
i
].
set_sequence
(
seq
[
'sequence'
])
# for tag in seq['tags'] :
# print(tag, seq['tags'][tag])
# view[i][tag] = seq['tags'][tag]
i
+=
1
print
(
view
)
print
(
view
.
__repr__
())
view
.
save_and_close
()
d
.
close
()
\ No newline at end of file
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