Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Transcript sampler
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
zavolan_group
tools
Transcript sampler
Commits
e41b7a53
Commit
e41b7a53
authored
2 years ago
by
Laura Urbanska
Browse files
Options
Downloads
Patches
Plain Diff
Deleted writegtf.py (now included in find representative transcript)
parent
c5778ccf
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/writegtf.py
+0
-64
0 additions, 64 deletions
scripts/writegtf.py
with
0 additions
and
64 deletions
scripts/writegtf.py
deleted
100644 → 0
+
0
−
64
View file @
c5778ccf
### Called Packages ###
import
pandas
as
pd
import
numpy
as
np
import
argparse
import
re
import
transcript_extractor
as
te
python_version
=
"
3.7.13
"
module_list
=
[
pd
,
np
,
argparse
,
re
]
modul_name_list
=
[
"
pd
"
,
"
np
"
,
"
argparse
"
,
"
re
"
]
### Functions ###
def
transcript_ID_finder
(
entry
):
index_transcript_id
=
entry
.
find
(
"
transcript_id
"
)
find_transcript_id_name
=
re
.
compile
(
"
\"
\S{1,25}
\"
"
)
sub_entry
=
entry
[
index_transcript_id
:]
try_find_transcript_id_name
=
find_transcript_id_name
.
search
(
sub_entry
)
try
:
transcript_ID
=
try_find_transcript_id_name
[
0
].
replace
(
"
\"
"
,
""
)
except
:
transcript_ID
=
""
return
(
transcript_ID
)
'''
gtf_file_writer takes as input the original gtf file and the csv file containing relevant transcripts.
It produces a gtf file containing only the transcript entries of those contained in the csv file
based on id
'''
def
gtf_file_writer
(
original_file
,
csv_file
,
output_file
):
output
=
[]
df
=
pd
.
read_csv
(
csv_file
)
listoftranscripts
=
df
[
'
id
'
].
tolist
()
if
df
[
'
id
'
].
empty
:
print
(
'
Error.
\'
id
\'
column needed in input csv file.
'
)
with
open
(
original_file
,
'
r
'
)
as
f
:
for
entry
in
f
:
if
"
\t
transcript
\t
"
in
entry
:
transcript_id
=
transcript_ID_finder
(
entry
)
if
transcript_id
in
listoftranscripts
:
output
.
append
(
entry
)
with
open
(
output_file
,
'
w
'
)
as
last_file
:
for
line
in
output
:
# I had to add this loop because I had an error about you cannot write list in directly in a file
last_file
.
write
(
line
)
if
__name__
==
'
__main__
'
:
te
.
version_control
(
module_list
,
modul_name_list
,
python_version
)
parser
=
argparse
.
ArgumentParser
(
description
=
"
gtf output file writer
"
,
formatter_class
=
argparse
.
ArgumentDefaultsHelpFormatter
)
parser
.
add_argument
(
"
--annotation
"
,
required
=
True
,
help
=
"
gtf file with genome annotation
"
)
parser
.
add_argument
(
"
--output_gtf
"
,
required
=
True
,
help
=
"
output gtf file
"
)
parser
.
add_argument
(
"
--input_csv
"
,
required
=
True
,
help
=
"
input csv file
"
)
args
=
parser
.
parse_args
()
gtf_file_writer
(
args
.
annotation
,
args
.
input_csv
,
args
.
output_gtf
)
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