Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Maintenance - Mise à jour mensuelle Lundi 6 Février entre 7h00 et 9h00
Open sidebar
genotoul-bioinfo
D-GENIES
Commits
17f02c8a
Commit
17f02c8a
authored
Jan 25, 2018
by
Floreal Cabanettes
Browse files
Fix launch on cluster
parent
988f1c23
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/dgenies/bin/filter_contigs.py
View file @
17f02c8a
...
...
@@ -3,7 +3,10 @@
import
os
import
re
import
shutil
from
dgenies.lib.paf
import
Index
try
:
from
dgenies.bin.index
import
Index
except
ModuleNotFoundError
:
from
index
import
Index
from
Bio
import
SeqIO
...
...
src/dgenies/bin/
build_
index.py
→
src/dgenies/bin/index.py
View file @
17f02c8a
...
...
@@ -5,6 +5,54 @@ import re
import
gzip
class
Index
:
def
__init__
(
self
):
pass
@
staticmethod
def
load
(
index_file
,
merge_splits
=
False
):
with
open
(
index_file
,
"r"
)
as
idx_q_f
:
abs_start
=
{}
abs_current_start
=
0
c_len
=
0
name
=
idx_q_f
.
readline
().
strip
(
"
\n
"
)
order
=
[]
contigs
=
{}
reversed_c
=
{}
for
line
in
idx_q_f
:
parts
=
line
.
strip
(
"
\n
"
).
split
(
"
\t
"
)
id_c
=
parts
[
0
]
is_split
=
False
if
merge_splits
:
match
=
re
.
match
(
r
"(.+)_###_\d+"
,
id_c
)
if
match
is
not
None
:
id_c
=
match
.
group
(
1
)
is_split
=
True
len_c
=
int
(
parts
[
1
])
if
len
(
parts
)
>
2
:
reversed_c
[
id_c
]
=
parts
[
2
]
==
"1"
else
:
reversed_c
[
id_c
]
=
False
if
not
is_split
or
(
is_split
and
id_c
not
in
order
):
order
.
append
(
id_c
)
abs_start
[
id_c
]
=
abs_current_start
contigs
[
id_c
]
=
len_c
else
:
contigs
[
id_c
]
+=
len_c
c_len
+=
len_c
abs_current_start
+=
len_c
return
name
,
order
,
contigs
,
reversed_c
,
abs_start
,
c_len
@
staticmethod
def
save
(
index_file
,
name
,
contigs
,
order
,
reversed_c
):
with
open
(
index_file
,
"w"
)
as
idx
:
idx
.
write
(
name
+
"
\n
"
)
for
contig
in
order
:
idx
.
write
(
"
\t
"
.
join
([
contig
,
str
(
contigs
[
contig
]),
"1"
if
reversed_c
[
contig
]
else
"0"
])
+
"
\n
"
)
def
index_file
(
fasta_path
,
fasta_name
,
out
,
write_fa
=
None
):
has_header
=
False
next_header
=
False
# True if next line must be a header line
...
...
src/dgenies/lib/job_manager.py
View file @
17f02c8a
...
...
@@ -18,7 +18,7 @@ import traceback
from
pathlib
import
Path
from
urllib
import
request
,
parse
from
dgenies.bin.split_fa
import
Splitter
from
dgenies.bin.
build_
index
import
index_file
from
dgenies.bin.index
import
index_file
from
dgenies.bin.filter_contigs
import
Filter
from
dgenies.bin.merge_splitted_chrms
import
Merger
from
dgenies.bin.sort_paf
import
Sorter
...
...
src/dgenies/lib/paf.py
View file @
17f02c8a
...
...
@@ -11,54 +11,7 @@ mpl.use('Agg')
from
matplotlib
import
pyplot
as
plt
import
json
from
collections
import
Counter
class
Index
:
def
__init__
(
self
):
pass
@
staticmethod
def
load
(
index_file
,
merge_splits
=
False
):
with
open
(
index_file
,
"r"
)
as
idx_q_f
:
abs_start
=
{}
abs_current_start
=
0
c_len
=
0
name
=
idx_q_f
.
readline
().
strip
(
"
\n
"
)
order
=
[]
contigs
=
{}
reversed_c
=
{}
for
line
in
idx_q_f
:
parts
=
line
.
strip
(
"
\n
"
).
split
(
"
\t
"
)
id_c
=
parts
[
0
]
is_split
=
False
if
merge_splits
:
match
=
re
.
match
(
r
"(.+)_###_\d+"
,
id_c
)
if
match
is
not
None
:
id_c
=
match
.
group
(
1
)
is_split
=
True
len_c
=
int
(
parts
[
1
])
if
len
(
parts
)
>
2
:
reversed_c
[
id_c
]
=
parts
[
2
]
==
"1"
else
:
reversed_c
[
id_c
]
=
False
if
not
is_split
or
(
is_split
and
id_c
not
in
order
):
order
.
append
(
id_c
)
abs_start
[
id_c
]
=
abs_current_start
contigs
[
id_c
]
=
len_c
else
:
contigs
[
id_c
]
+=
len_c
c_len
+=
len_c
abs_current_start
+=
len_c
return
name
,
order
,
contigs
,
reversed_c
,
abs_start
,
c_len
@
staticmethod
def
save
(
index_file
,
name
,
contigs
,
order
,
reversed_c
):
with
open
(
index_file
,
"w"
)
as
idx
:
idx
.
write
(
name
+
"
\n
"
)
for
contig
in
order
:
idx
.
write
(
"
\t
"
.
join
([
contig
,
str
(
contigs
[
contig
]),
"1"
if
reversed_c
[
contig
]
else
"0"
])
+
"
\n
"
)
from
dgenies.bin.index
import
Index
class
Paf
:
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment