Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cDNA generator
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
cDNA generator
Commits
aba597a1
Commit
aba597a1
authored
2 years ago
by
Eric Boittier
Browse files
Options
Downloads
Patches
Plain Diff
reformatted with black
parent
96e8c8aa
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
cdna/cdna.py
+22
-28
22 additions, 28 deletions
cdna/cdna.py
with
22 additions
and
28 deletions
cdna/cdna.py
+
22
−
28
View file @
aba597a1
import
sys
import
sys
def
translate
(
res
):
def
translate
(
res
):
translate_dict
=
{
"
A
"
:
"
T
"
,
"
U
"
:
"
A
"
,
"
G
"
:
"
C
"
,
"
C
"
:
"
G
"
}
translate_dict
=
{
"
A
"
:
"
T
"
,
"
U
"
:
"
A
"
,
"
G
"
:
"
C
"
,
"
C
"
:
"
G
"
}
if
res
not
in
translate_dict
.
keys
():
if
res
not
in
translate_dict
.
keys
():
print
(
"
cDNA residue not A,T,U or G
"
)
print
(
"
cDNA residue not A,T,U or G
"
)
sys
.
exit
(
1
)
sys
.
exit
(
1
)
return
translate_dict
[
res
]
return
translate_dict
[
res
]
class
cDNA_Gen
:
class
cDNA_Gen
:
def
__init__
(
self
,
def
__init__
(
fasta
,
self
,
fasta
,
gtf
,
cpn
,
output_fasta
=
"
cDNA.fasta
"
,
output_csv
=
"
cDNA.csv
"
gtf
,
):
cpn
,
output_fasta
=
"
cDNA.fasta
"
,
output_csv
=
"
cDNA.csv
"
):
# inputs
# inputs
self
.
fasta
=
fasta
self
.
fasta
=
fasta
self
.
gtf
=
gtf
self
.
gtf
=
gtf
...
@@ -26,27 +24,25 @@ class cDNA_Gen:
...
@@ -26,27 +24,25 @@ class cDNA_Gen:
self
.
fasta_seq
=
""
self
.
fasta_seq
=
""
self
.
fasta_id
=
""
self
.
fasta_id
=
""
self
.
copy_numbers
=
{}
self
.
copy_numbers
=
{}
self
.
run
()
self
.
run
()
def
run
(
self
):
def
run
(
self
):
self
.
read_fasta
()
self
.
read_fasta
()
self
.
read_gtf
()
self
.
read_gtf
()
def
order_priming_sites
(
self
):
def
order_priming_sites
(
self
):
pass
pass
def
generate_cdna
(
self
):
def
generate_cdna
(
self
):
pass
pass
def
read_fasta
(
self
):
def
read_fasta
(
self
):
fasta
=
open
(
self
.
fasta
).
readlines
()
fasta
=
open
(
self
.
fasta
).
readlines
()
self
.
fasta_id
=
fasta
[
0
]
self
.
fasta_id
=
fasta
[
0
]
print
(
fasta
[
0
])
print
(
fasta
[
0
])
self
.
fasta_seq
=
""
.
join
([
_
.
rstrip
()
for
_
in
fasta
[
1
:]])
self
.
fasta_seq
=
""
.
join
([
_
.
rstrip
()
for
_
in
fasta
[
1
:]])
def
read_gtf
(
self
):
def
read_gtf
(
self
):
with
open
(
self
.
gtf
)
as
gtf_file
:
with
open
(
self
.
gtf
)
as
gtf_file
:
gtf_lines
=
gtf_file
.
readlines
()
gtf_lines
=
gtf_file
.
readlines
()
...
@@ -58,7 +54,7 @@ class cDNA_Gen:
...
@@ -58,7 +54,7 @@ class cDNA_Gen:
def
write_fasta
(
self
):
def
write_fasta
(
self
):
pass
pass
def
read_copy_numbers
(
self
):
def
read_copy_numbers
(
self
):
with
open
(
self
.
cpn
)
as
cpn_file
:
with
open
(
self
.
cpn
)
as
cpn_file
:
cpn_lines
=
cpn_file
.
readlines
()
cpn_lines
=
cpn_file
.
readlines
()
...
@@ -69,11 +65,10 @@ class cDNA_Gen:
...
@@ -69,11 +65,10 @@ class cDNA_Gen:
gene_id
=
csv
[
1
]
gene_id
=
csv
[
1
]
count
=
csv
[
2
]
count
=
csv
[
2
]
self
.
copy_numbers
[
gene_id
]
=
count
self
.
copy_numbers
[
gene_id
]
=
count
def
return_output
(
self
):
def
return_output
(
self
):
return
self
.
output_fasta
,
self
.
output_csv
return
self
.
output_fasta
,
self
.
output_csv
class
GTF_entry
:
class
GTF_entry
:
def
__init__
(
self
,
string
):
def
__init__
(
self
,
string
):
...
@@ -82,19 +77,18 @@ class GTF_entry:
...
@@ -82,19 +77,18 @@ class GTF_entry:
self
.
id
=
self
.
values
[
0
]
self
.
id
=
self
.
values
[
0
]
self
.
start
=
int
(
self
.
values
[
3
])
self
.
start
=
int
(
self
.
values
[
3
])
self
.
end
=
int
(
self
.
values
[
4
])
self
.
end
=
int
(
self
.
values
[
4
])
self
.
score
=
float
(
0.5
)
#
self.values[5]
self
.
score
=
float
(
0.5
)
#
self.values[5]
self
.
sequence
=
"
no sequence set
"
self
.
sequence
=
"
no sequence set
"
self
.
length
=
self
.
end
-
self
.
start
self
.
length
=
self
.
end
-
self
.
start
def
__repr__
(
self
):
def
__repr__
(
self
):
return
self
.
sequence
[:
10
]
+
"
...
"
+
f
"
len=
{
self
.
length
}
score=
{
self
.
score
}
"
return
self
.
sequence
[:
10
]
+
"
...
"
+
f
"
len=
{
self
.
length
}
score=
{
self
.
score
}
"
def
set_sequence
(
self
,
full_sequence
):
def
set_sequence
(
self
,
full_sequence
):
self
.
sequence
=
full_sequence
[
self
.
start
:
self
.
end
]
self
.
sequence
=
full_sequence
[
self
.
start
:
self
.
end
]
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
import
argparse
import
argparse
pass
pass
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