Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
magatt
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
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
UMR GDEC
magatt
Commits
62df6545
Commit
62df6545
authored
4 years ago
by
Helene Rimbert
Browse files
Options
Downloads
Patches
Plain Diff
correction of gff attribute modification in bin/reformatGmapWGGFF.py
parent
fade4647
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
bin/reformatGmapWGGFF.py
+20
-7
20 additions, 7 deletions
bin/reformatGmapWGGFF.py
with
20 additions
and
7 deletions
bin/reformatGmapWGGFF.py
+
20
−
7
View file @
62df6545
#!/usr/bin/env python3
#!/usr/bin/env python3
.5
# coding: utf-8
import
os.path
from
os
import
path
...
...
@@ -23,6 +23,7 @@ class reformatGmapGff (object):
def
main
(
self
):
self
.
getOptions
()
self
.
checkInputs
()
self
.
regexlcl
=
re
.
compile
(
r
'
lcl\|
'
)
# load inputs
self
.
loadChromosomeMap
()
...
...
@@ -74,6 +75,9 @@ class reformatGmapGff (object):
print
(
"
\t
"
.
join
(
map
(
str
,
feature
)),
file
=
self
.
errorFH
)
def
reformatGff
(
self
):
lastmrna
=
''
featureindex
=
{
'
CDS
'
:
1
,
'
exon
'
:
1
}
with
open
(
self
.
options
.
input
)
as
mygff
:
for
line
in
mygff
.
readlines
():
if
not
line
.
startswith
(
'
#
'
):
...
...
@@ -84,6 +88,7 @@ class reformatGmapGff (object):
if
featuretype
==
'
gene
'
:
# get only the gene name because here the ID corresponds to the mrna isoform which has been mapped
geneId
=
featureId
.
split
(
'
.
'
)[
0
]
lastmrna
=
''
if
geneId
not
in
self
.
knownGenes
:
self
.
knownGenes
.
append
(
geneId
)
...
...
@@ -100,11 +105,13 @@ class reformatGmapGff (object):
'
attributes
'
:
gff_array
[
8
]}
elif
featuretype
==
'
mRNA
'
:
mrna
=
self
.
getFeatureAttribute
(
gff
=
line
,
attribute
=
'
ID
'
)
mrna
=
self
.
getFeatureAttribute
(
gff
=
line
,
attribute
=
'
Name
'
)
lastmrna
=
mrna
featureindex
=
{
'
CDS
'
:
1
,
'
exon
'
:
1
}
self
.
knownMrna
.
append
(
mrna
)
parent
=
mrna
.
split
(
'
.
'
)[
0
]
self
.
geneIsoforms
[
parent
].
append
(
mrna
)
gff_array
[
8
]
=
self
.
setGffAttributes
(
attributes
=
gff_array
[
8
],
new
=
{
'
Parent
'
:
parent
})
gff_array
[
8
]
=
self
.
setGffAttributes
(
attributes
=
gff_array
[
8
],
new
=
{
'
Parent
'
:
parent
,
'
ID
'
:
mrna
,
'
Name
'
:
mrna
})
self
.
mrnaFeatures
[
mrna
]
=
[
gff_array
]
# check if this new mrna has start or stop different from the gene feature
...
...
@@ -118,9 +125,13 @@ class reformatGmapGff (object):
sys
.
stderr
.
write
(
"
New gene length: {}
\n
"
.
format
(
int
(
gff_array
[
4
])
-
int
(
gff_array
[
3
])
+
1
))
else
:
featureId
=
self
.
getFeatureAttribute
(
gff
=
line
,
attribute
=
'
ID
'
)
featureParent
=
self
.
getFeatureAttribute
(
gff
=
line
,
attribute
=
'
Parent
'
)
self
.
mrnaFeatures
[
featureParent
].
append
(
line
.
rstrip
(
'
\n
'
).
split
(
'
\t
'
))
featureId
=
lastmrna
+
'
.
'
+
featuretype
.
lower
()
+
str
(
featureindex
[
featuretype
])
featureParent
=
lastmrna
gff_array
[
8
]
=
self
.
setGffAttributes
(
attributes
=
gff_array
[
8
],
new
=
{
'
ID
'
:
featureId
,
'
Parent
'
:
featureParent
,
'
Name
'
:
featureId
})
self
.
mrnaFeatures
[
featureParent
].
append
(
gff_array
)
featureindex
[
featuretype
]
+=
1
numgenes
=
len
(
self
.
knownGenes
)
nummrna
=
len
(
self
.
knownMrna
)
...
...
@@ -154,6 +165,8 @@ class reformatGmapGff (object):
(
key
,
val
)
=
attr
.
split
(
'
=
'
)
attr_dict
[
key
]
=
val
if
attribute
in
attr_dict
.
keys
():
if
self
.
regexlcl
.
search
(
attr_dict
[
attribute
])
and
attribute
in
[
'
ID
'
,
'
Parent
'
,
'
Name
'
]:
attr_dict
[
attribute
]
=
self
.
regexlcl
.
sub
(
''
,
attr_dict
[
attribute
])
return
attr_dict
[
attribute
]
else
:
sys
.
stderr
.
write
(
'
ERROR: no attribute {} in gff record {}
'
.
format
(
attribute
,
gff
))
...
...
@@ -196,4 +209,4 @@ class reformatGmapGff (object):
if
__name__
==
"
__main__
"
:
run
=
reformatGmapGff
()
run
.
main
()
\ No newline at end of file
run
.
main
()
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