Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
panacota
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
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
Amandine PERRIN
panacota
Commits
8cdec6cf
Commit
8cdec6cf
authored
4 years ago
by
Amandine PERRIN
Browse files
Options
Downloads
Patches
Plain Diff
Test for generation of new contig names -> corrected error in logs
parent
aa9771bb
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
PanACoTA/utils.py
+6
-1
6 additions, 1 deletion
PanACoTA/utils.py
test/test_unit/test_utils.py
+44
-0
44 additions, 0 deletions
test/test_unit/test_utils.py
with
50 additions
and
1 deletion
PanACoTA/utils.py
+
6
−
1
View file @
8cdec6cf
...
...
@@ -1150,6 +1150,10 @@ def get_genome_contigs_and_rename(gembase_name, gpath, outfile, logger):
prevcont_nohead
=
prev_cont
.
split
(
"
>
"
)[
1
]
prev_orig_name_nohead
=
prev_orig_name
.
split
(
"
>
"
)[
1
]
if
prev_orig_name_nohead
:
if
prev_orig_name_nohead
in
contigs
:
logger
.
error
(
f
"
several contigs have the same name
"
f
"
{
prev_orig_name_nohead
}
in
{
gpath
}
.
"
)
return
False
,
False
sizes
[
prevcont_nohead
]
=
cont_size
contigs
[
prev_orig_name_nohead
]
=
prevcont_nohead
grf
.
write
(
cont
)
...
...
@@ -1170,7 +1174,8 @@ def get_genome_contigs_and_rename(gembase_name, gpath, outfile, logger):
prev_orig_name_nohead
=
prev_orig_name
.
split
(
"
>
"
)[
1
]
if
prev_orig_name_nohead
:
if
prev_orig_name_nohead
in
contigs
:
logger
.
error
(
f
"
several contigs have the same name
{
prev_cont
}
in
{
gpath
}
.
"
)
logger
.
error
(
f
"
several contigs have the same name
{
prev_orig_name_nohead
}
"
f
"
in
{
gpath
}
.
"
)
return
False
,
False
contigs
[
prev_orig_name_nohead
]
=
prevcont_nohead
sizes
[
prevcont_nohead
]
=
cont_size
...
...
This diff is collapsed.
Click to expand it.
test/test_unit/test_utils.py
+
44
−
0
View file @
8cdec6cf
...
...
@@ -918,6 +918,50 @@ def test_rename_contigs():
assert
utilities
.
compare_order_content
(
outfile
,
exp_file
)
def
test_rename_contigs_duplicate
(
caplog
):
"""
From a given sequence, there are 2 contigs named
"
contig2
"
. Stops and returns false
"""
logger
=
logging
.
getLogger
(
"
default
"
)
gpath
=
os
.
path
.
join
(
DATA_DIR
,
"
genomes
"
,
"
genome-duplicated-header.fasta
"
)
gembase_name
=
"
ESCO.0216.00005
"
outfile
=
os
.
path
.
join
(
GENEPATH
,
"
genome_dup_error.fna
"
)
exp_file
=
os
.
path
.
join
(
DATA_DIR
,
"
exp_files
"
,
"
res_H299_H561-ESCO00005.fna
"
)
contigs
,
sizes
=
utils
.
get_genome_contigs_and_rename
(
gembase_name
,
gpath
,
outfile
,
logger
)
assert
not
contigs
assert
not
sizes
with
open
(
outfile
,
"
r
"
)
as
of
:
assert
of
.
readline
().
startswith
(
"
>ESCO.0216.00005.0001
"
)
of
.
readline
()
# skip sequence
assert
of
.
readline
().
startswith
(
"
>ESCO.0216.00005.0002
"
)
of
.
readline
()
# skip sequence
assert
of
.
readline
().
startswith
(
"
>ESCO.0216.00005.0003
"
)
assert
(
"
several contigs have the same name contig2 in test/data/annotate/genomes/
"
"
genome-duplicated-header.fasta.
"
)
in
caplog
.
text
def
test_rename_contigs_duplicate_last
(
caplog
):
"""
The last contig of the sequence has the same name as a previous contig. Stops and returns false
"""
logger
=
logging
.
getLogger
(
"
default
"
)
gpath
=
os
.
path
.
join
(
DATA_DIR
,
"
genomes
"
,
"
genome-duplicated-header-last.fasta
"
)
gembase_name
=
"
ESCO.0216.00005
"
outfile
=
os
.
path
.
join
(
GENEPATH
,
"
genome_dup_error.fna
"
)
exp_file
=
os
.
path
.
join
(
DATA_DIR
,
"
exp_files
"
,
"
res_H299_H561-ESCO00005.fna
"
)
contigs
,
sizes
=
utils
.
get_genome_contigs_and_rename
(
gembase_name
,
gpath
,
outfile
,
logger
)
assert
not
contigs
assert
not
sizes
with
open
(
outfile
,
"
r
"
)
as
of
:
assert
of
.
readline
().
startswith
(
"
>ESCO.0216.00005.0001
"
)
of
.
readline
()
# skip sequence
assert
of
.
readline
().
startswith
(
"
>ESCO.0216.00005.0002
"
)
of
.
readline
()
# skip sequence
assert
of
.
readline
().
startswith
(
"
>ESCO.0216.00005.0003
"
)
assert
(
"
several contigs have the same name contig2 in test/data/annotate/genomes/
"
"
genome-duplicated-header-last.fasta.
"
)
in
caplog
.
text
def
test_cat_nobar
():
"""
Check that when cat is called on a list of several files, the output file
...
...
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