Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Transcript sequence extractor
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 sequence extractor
Merge requests
!50
Prebedtools script to sort exons per strand type
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Prebedtools script to sort exons per strand type
prebedtools
into
master
Overview
0
Commits
1
Pipelines
0
Changes
1
Merged
Gina Boot
requested to merge
prebedtools
into
master
2 years ago
Overview
0
Commits
1
Pipelines
0
Changes
1
Expand
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
98bc811b
1 commit,
2 years ago
1 file
+
28
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
sequence_extractor/preBedtools_new.py
0 → 100644
+
28
−
0
Options
import
pandas
as
pd
from
gtfparse
import
read_gtf
"""
This script defines a BED from exon annotation in a GTF, to get sequences with transcript ID as header after usage in bedtools.
For each transcript, take exons only and sort exons by start position (reverse order for -ve strand)
Input: GTF file
Columns needed for BED: chr, start, end, transcript_id, score, strand, gene_id
...
:
returns
:
BED
file
format
:
rtype
:
dataframe
"""
gtf
=
read_gtf
(
'
../scrna-seq-simulation-main/inputs/ref_annotation.gtf
'
)
gtf_exons
=
gtf
[
gtf
[
"
feature
"
]
==
"
exon
"
]
gtf_exons
=
gtf_exons
[[
"
seqname
"
,
"
start
"
,
"
end
"
,
"
transcript_id
"
,
"
score
"
,
"
strand
"
,
"
gene_id
"
]]
gtf_df_neg
=
gtf_exons
[
gtf_exons
[
"
strand
"
]
==
"
-
"
]
gtf_df_neg
=
gtf_df_neg
.
sort_values
([
'
transcript_id
'
,
'
start
'
],
ascending
=
False
).
groupby
(
'
transcript_id
'
).
head
(
len
(
gtf_df_neg
.
transcript_id
))
gtf_df_pos
=
gtf_exons
[
gtf_exons
[
"
strand
"
]
==
"
+
"
]
gtf_df_pos
=
gtf_df_pos
.
sort_values
([
'
transcript_id
'
,
'
start
'
],
ascending
=
True
).
groupby
(
'
transcript_id
'
).
head
(
len
(
gtf_df_pos
.
transcript_id
))
pd
.
concat
([
gtf_df_pos
,
gtf_df_neg
]).
to_csv
(
"
bed_file.bed
"
,
sep
=
"
\t
"
,
index
=
False
)
#gtf_df_pos and gtf_df_neg must be dataframes
Loading