Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
plit-genome
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor 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
zoology
plit-genome
Commits
dc923a70
Commit
dc923a70
authored
4 months ago
by
Niko (Nikolaos) Papadopoulos
Browse files
Options
Downloads
Patches
Plain Diff
build mRNA kill list for AGAT
parent
c33f2ad0
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
08-submission/gff-03-build_kill_list.py
+62
-0
62 additions, 0 deletions
08-submission/gff-03-build_kill_list.py
with
62 additions
and
0 deletions
08-submission/gff-03-build_kill_list.py
0 → 100644
+
62
−
0
View file @
dc923a70
#!/usr/bin/env python
# go through a list of short introns produced by agat_sp_list_short_introns.pl
# and find the corresponding mRNA titles
import
argparse
import
re
def
build_regex
(
input_file
):
regex_list
=
[]
# open the input file
with
open
(
input_file
,
'
r
'
)
as
f
:
# the first 3 lines are headers
f
.
readline
()
f
.
readline
()
f
.
readline
()
# read the file line by line
for
line
in
f
:
# if the line is empty, we have reached the end
if
line
==
"
\n
"
:
break
# split the line by tab
line
=
line
.
strip
().
split
(
'
\t
'
)
_locus
,
locus_id
,
position
,
_intron_length
=
line
# build the regex
regex
=
re
.
compile
(
f
"
{
int
(
position
)
-
1
}
.*
{
locus_id
.
upper
()
}
"
)
regex_list
.
append
(
regex
)
return
regex_list
def
grep
(
regex_list
,
target
):
to_fix
=
set
()
# grep the target file for the regex
with
open
(
target
,
'
r
'
)
as
f
:
for
line
in
f
:
for
regex
in
regex_list
:
if
re
.
search
(
regex
,
line
):
attributes
=
line
.
strip
().
split
(
'
\t
'
)[
-
1
]
attr_dict
=
{}
for
attr
in
attributes
.
split
(
'
;
'
):
key
,
value
=
attr
.
split
(
'
=
'
)
attr_dict
[
key
]
=
value
to_fix
.
add
(
attr_dict
[
'
Parent
'
])
return
list
(
to_fix
)
def
main
(
input_file
,
target
):
short_introns
=
build_regex
(
input_file
)
ids
=
grep
(
short_introns
,
target
)
for
i
in
ids
:
print
(
i
)
if
__name__
==
"
__main__
"
:
# argument parser that will receive the input file
parser
=
argparse
.
ArgumentParser
(
description
=
'
Get the mRNA titles of the short introns (agat_sp_list_short_introns.pl output file)
'
)
parser
.
add_argument
(
'
input_file
'
,
type
=
str
,
help
=
'
The input file containing the short introns
'
)
parser
.
add_argument
(
'
target_file
'
,
type
=
str
,
help
=
'
The target GFF file.
'
)
args
=
parser
.
parse_args
()
input_file
=
args
.
input_file
target
=
args
.
target_file
main
(
input_file
,
target
)
\ No newline at end of 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