Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scRNA-seq-simulation
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
pipelines
scRNA-seq-simulation
Merge requests
!8
feat: function to generate poly(A) tail sequence
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
feat: function to generate poly(A) tail sequence
polyAtail
into
main
Overview
0
Commits
9
Pipelines
4
Changes
5
Merged
MihaelaZavolan
requested to merge
polyAtail
into
main
3 years ago
Overview
0
Commits
9
Pipelines
4
Changes
5
Expand
0
0
Merge request reports
Compare
main
version 3
5fe33163
3 years ago
version 2
f8873896
3 years ago
version 1
9f2d55a3
3 years ago
main (base)
and
latest version
latest version
b5b2471f
9 commits,
3 years ago
version 3
5fe33163
8 commits,
3 years ago
version 2
f8873896
7 commits,
3 years ago
version 1
9f2d55a3
6 commits,
3 years ago
5 files
+
134
−
13
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
5
Search (e.g. *.vue) (Ctrl+P)
src/poly_a.py
0 → 100644
+
67
−
0
Options
"""
Generate a poly(A) tail.
"""
from
random
import
choices
from
typing
import
(
List
,
Tuple
)
def
generate_poly_a
(
length
:
int
=
100
,
weights
:
Tuple
[
float
,
float
,
float
,
float
]
=
(
0.914
,
0.028
,
0.025
,
0.033
)
)
->
str
:
"""
Generate a poly(A) tail of specified length and composition.
This function generates a nucleotide sequence that has compositional
statistics resembling those of poly(A) tails.
Args:
length: Length of the desired tail.
weights: Tuple of relative `A`, `C`, `G` and `U` frequencies in
the tail.
Returns:
The generated poly(A) tail.
Raises:
ValueError: The provided length is not a positive `int` or is
too large (maximum length = 200).
ValueError: One or more of the provided `weights` are not
positive or all weights are zero.
"""
max_len
:
int
=
200
bases
:
Tuple
[
str
,
str
,
str
,
str
]
=
(
'
A
'
,
'
C
'
,
'
G
'
,
'
U
'
)
# check parameters
if
not
isinstance
(
length
,
int
):
raise
ValueError
(
f
"
The provided length is not an integer:
{
length
}
"
)
if
not
1
<=
int
(
length
)
<=
max_len
:
raise
ValueError
(
"
The provided length is outside of the accepted range
"
f
"
(1-
{
max_len
}
):
{
length
}
"
)
if
len
(
weights
)
!=
len
(
bases
):
raise
ValueError
(
"
There is not a weight provided for each of the bases
'
{bases}
'
:
"
"
{weights}
"
)
try
:
sum
(
weights
)
except
TypeError
:
raise
ValueError
(
"
At least one of the provided weights is not a number: {weights}
"
)
if
any
(
w
<
0
for
w
in
weights
):
raise
ValueError
(
"
At least one of the provided weights is negative: {weights}
"
)
if
all
(
w
==
0
for
w
in
weights
):
raise
ValueError
(
f
"
All weights are zero:
{
weights
}
"
)
# ensure that the values are normalized
s
:
float
=
float
(
sum
(
weights
))
norm_weights
:
List
[
float
]
=
[
freq
/
s
for
freq
in
weights
]
tail_bases
:
List
[
str
]
=
choices
(
bases
,
weights
=
norm_weights
,
k
=
length
)
return
""
.
join
(
tail_bases
)
Loading