Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PanGeTools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alexis Mergez
PanGeTools
Commits
5067920a
Commit
5067920a
authored
4 months ago
by
Alexis Mergez
Browse files
Options
Downloads
Patches
Plain Diff
GFAvc v0.4.2
Sorting paths by name
parent
c78b2b80
No related branches found
Branches containing commit
Tags
v1.10.8
Tags containing commit
No related merge requests found
Pipeline
#257809
waiting for manual action
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
GFAvc.py
+25
-6
25 additions, 6 deletions
GFAvc.py
with
25 additions
and
6 deletions
GFAvc.py
+
25
−
6
View file @
5067920a
...
...
@@ -5,14 +5,14 @@ GFAvc: GFA version converter.
Convert GFA from v1.1 to v1.0 (Convert walk to paths) and vice versa.
@author: alexis.mergez@inrae.fr
@version: 0.4.
1
@version: 0.4.
2
"""
import
re
import
argparse
import
os
import
gzip
version
=
"
0.4.
1
"
version
=
"
0.4.
2
"
## Argument parser
arg_parser
=
argparse
.
ArgumentParser
(
description
=
'
GFAvc: GFA version converter
'
)
...
...
@@ -92,6 +92,9 @@ def gfa11_to_gfa10(gfa1_file = args.GFA1):
_
[
1
]
=
"
VN:Z:1.0
"
gfa
[
0
]
=
"
\t
"
.
join
(
_
)
# Used to store paths are order them at the end
paths_dict
=
{}
#% Iterating in reverse to put paths at the end.
for
lineID
in
sorted
(
range
(
len
(
gfa
)),
reverse
=
True
):
if
gfa
[
lineID
][
0
]
==
"
S
"
:
...
...
@@ -115,13 +118,19 @@ def gfa11_to_gfa10(gfa1_file = args.GFA1):
newLine
=
[
'
P
'
,
name
,
'
,
'
.
join
(
path
),
'
*
'
]
gfa
.
append
(
'
\t
'
.
join
(
newLine
))
paths_dict
[
name
]
=
'
\t
'
.
join
(
newLine
)
#gfa.append('\t'.join(newLine))
#% Moving path lines to the end
if
gfa
[
lineID
][
0
]
==
"
P
"
:
curLine
=
gfa
.
pop
(
lineID
)
gfa
.
append
(
curLine
)
name
=
curLine
.
split
(
'
\t
'
)[
1
]
paths_dict
[
name
]
=
'
\t
'
.
join
(
curLine
)
#gfa.append(curLine)
for
name
in
sorted
(
paths_dict
.
keys
()):
gfa
.
append
(
paths_dict
[
name
])
return
gfa
...
...
@@ -141,6 +150,9 @@ def gfa10_to_gfa11(gfa_file = args.GFA, index = index):
sign
=
{
"
+
"
:
"
>
"
,
"
-
"
:
"
<
"
}
samples
=
[]
# Used to store paths are order them at the end
paths_dict
=
{}
#% Iterating in reverse to put walks at the end.
for
lineID
in
sorted
(
range
(
len
(
gfa
)),
reverse
=
True
):
...
...
@@ -169,15 +181,22 @@ def gfa10_to_gfa11(gfa_file = args.GFA, index = index):
newLine
=
[
'
W
'
]
+
ID
+
RANGE
+
[
f
"
{
''
.
join
(
walk
)
}
"
]
samples
.
append
(
ID
[
0
])
gfa
.
append
(
'
\t
'
.
join
(
newLine
))
paths_dict
[
splittedID
[
0
]]
=
'
\t
'
.
join
(
newLine
)
#gfa.append('\t'.join(newLine))
#% Moving walk lines to the end
if
gfa
[
lineID
][
0
]
==
"
W
"
:
curLine
=
gfa
.
pop
(
lineID
)
gfa
.
append
(
curLine
)
name
=
'
#
'
.
join
(
curLine
.
split
(
'
\t
'
)[
1
:
4
])
paths_dict
[
name
]
=
'
\t
'
.
join
(
curLine
)
#gfa.append(curLine)
for
name
in
sorted
(
paths_dict
.
keys
()):
gfa
.
append
(
paths_dict
[
name
])
samples
=
list
(
set
(
samples
))
#% Changing version number in header
assert
gfa
[
0
].
split
(
'
\t
'
)[
1
]
==
"
VN:Z:1.0
"
_
=
gfa
[
0
].
split
(
'
\t
'
)
...
...
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