Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
bioinfo_utils
Manage
Activity
Members
Labels
Plan
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
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
Blaise LI
bioinfo_utils
Commits
4b4fb422
Commit
4b4fb422
authored
2 years ago
by
Blaise Li
Browse files
Options
Downloads
Patches
Plain Diff
Use transcript_id as gene_id for miRNA.
The goal is to have distinct counts for -5p and -3p miRNAs.
parent
9154ba5c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Genome_preparation/extract_info_from_gtf.py
+13
-7
13 additions, 7 deletions
Genome_preparation/extract_info_from_gtf.py
with
13 additions
and
7 deletions
Genome_preparation/extract_info_from_gtf.py
+
13
−
7
View file @
4b4fb422
...
@@ -30,9 +30,8 @@ base, ext = splitext(in_gtf)
...
@@ -30,9 +30,8 @@ base, ext = splitext(in_gtf)
biotype_counter
=
defaultdict
(
int
)
biotype_counter
=
defaultdict
(
int
)
biotypes2id
=
{
biotypes2id
=
{
"
rRNA
"
:
"
gene_id
"
,
"
rRNA
"
:
"
gene_id
"
,
# TODO: use "transcript_id" to have distinct 3p and 5p entries
# Use "transcript_id" to have distinct 3p and 5p entries
# "miRNA": "transcript_id",
"
miRNA
"
:
"
transcript_id
"
,
"
miRNA
"
:
"
gene_id
"
,
"
piRNA
"
:
"
gene_id
"
,
"
piRNA
"
:
"
gene_id
"
,
"
snRNA
"
:
"
gene_id
"
,
"
snRNA
"
:
"
gene_id
"
,
"
lincRNA
"
:
"
gene_id
"
,
"
lincRNA
"
:
"
gene_id
"
,
...
@@ -43,8 +42,7 @@ biotypes2id = {
...
@@ -43,8 +42,7 @@ biotypes2id = {
"
ncRNA
"
:
"
gene_id
"
,
"
ncRNA
"
:
"
gene_id
"
,
"
pseudogene
"
:
"
gene_id
"
}
"
pseudogene
"
:
"
gene_id
"
}
gene_name_getters
=
{
gene_name_getters
=
{
# TODO: use this
"
miRNA
"
:
mir_name_getter
# "miRNA": mir_name_getter
}
}
# Mapping gene_id to gene_name
# Mapping gene_id to gene_name
...
@@ -73,10 +71,9 @@ with ExitStack() as stack, open(in_gtf, "r") as gtf:
...
@@ -73,10 +71,9 @@ with ExitStack() as stack, open(in_gtf, "r") as gtf:
if
fields
[
2
]
==
"
transcript
"
:
if
fields
[
2
]
==
"
transcript
"
:
annots
=
dict
([
annots
=
dict
([
(
k
,
v
.
strip
(
'"'
))
for
(
k
,
v
)
(
k
,
v
.
strip
(
'"'
))
for
(
k
,
v
)
in
[
f
.
split
(
"
"
)
for
f
in
fields
[
8
].
split
(
"
;
"
)
[:
-
1
]
]])
in
[
f
.
split
(
"
"
)
for
f
in
fields
[
8
].
rstrip
(
"
;
"
).
split
(
"
;
"
)]])
if
"
exon_number
"
not
in
annots
:
if
"
exon_number
"
not
in
annots
:
biotype
=
annots
[
"
gene_biotype
"
]
biotype
=
annots
[
"
gene_biotype
"
]
dest_files
[
biotype
].
write
(
line
)
biotype_counter
[
biotype
]
+=
1
biotype_counter
[
biotype
]
+=
1
end
=
int
(
fields
[
4
])
end
=
int
(
fields
[
4
])
length
=
end
+
1
-
start
length
=
end
+
1
-
start
...
@@ -88,6 +85,15 @@ with ExitStack() as stack, open(in_gtf, "r") as gtf:
...
@@ -88,6 +85,15 @@ with ExitStack() as stack, open(in_gtf, "r") as gtf:
post_process_name
=
gene_name_getters
.
get
(
post_process_name
=
gene_name_getters
.
get
(
biotype
,
default_gene_name_getter
)
biotype
,
default_gene_name_getter
)
id2name
[
gene_id
]
=
post_process_name
(
annots
,
gene_id
)
id2name
[
gene_id
]
=
post_process_name
(
annots
,
gene_id
)
# We want miRNA gene_id and gene_name modified
# dest_files[biotype].write(line)
annots
[
"
gene_id
"
]
=
gene_id
annots
[
"
gene_name
"
]
=
id2name
[
gene_id
]
fields
[
8
]
=
"
;
"
.
join
([
f
"
{
k
}
\"
{
v
}
\"
"
for
(
k
,
v
)
in
annots
.
items
()
])
+
"
;
"
dest_files
[
biotype
].
write
(
"
\t
"
.
join
(
fields
)
+
"
\n
"
)
with
open
(
f
"
{
base
}
_id2name.pickle
"
,
"
wb
"
)
as
pickle_file
:
with
open
(
f
"
{
base
}
_id2name.pickle
"
,
"
wb
"
)
as
pickle_file
:
print
(
f
"
Storing id2name in
{
pickle_file
.
name
}
"
)
print
(
f
"
Storing id2name in
{
pickle_file
.
name
}
"
)
...
...
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