Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libcodonusage
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
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
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
libcodonusage
Commits
de4b5e81
Commit
de4b5e81
authored
1 year ago
by
Blaise Li
Browse files
Options
Downloads
Patches
Plain Diff
Remove side effect of remove_codons.
parent
c8981ee9
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
libcodonusage/__init__.py
+1
-1
1 addition, 1 deletion
libcodonusage/__init__.py
libcodonusage/libcodonusage.py
+9
-41
9 additions, 41 deletions
libcodonusage/libcodonusage.py
with
10 additions
and
42 deletions
libcodonusage/__init__.py
+
1
−
1
View file @
de4b5e81
__copyright__
=
"
Copyright (C) 2022-2023 Blaise Li, Marie Anselmet
"
__licence__
=
"
GNU GPLv3
"
__version__
=
"
0.28.
4
"
__version__
=
"
0.28.
5
"
from
.libcodonusage
import
(
aa2colour
,
aa_usage
,
...
...
This diff is collapsed.
Click to expand it.
libcodonusage/libcodonusage.py
+
9
−
41
View file @
de4b5e81
...
...
@@ -442,7 +442,7 @@ SUZUKI_DOI = "10.1016/j.febslet.2005.10.032"
SUZUKI_LINK
=
f
"
[Suzuki et al (2005)](https://doi.org/
{
SUZUKI_DOI
}
)
"
def
remove_codons
(
codon_counts
,
codon_list
):
def
remove_codons
_old
(
codon_counts
,
codon_list
):
"""
Filter out codons in a table *codon_counts* based on codons
present in the list *codon_list* (like stop codons).
...
...
@@ -451,6 +451,14 @@ def remove_codons(codon_counts, codon_list):
return
codon_counts
def
remove_codons
(
codon_counts
,
codon_list
):
"""
Filter out codons in a table *codon_counts* based on codons
present in the list *codon_list* (like stop codons).
"""
return
codon_counts
.
drop
(
columns
=
codon_list
)
def
sum_codon_counts
(
row
,
codons
):
"""
Perform the row-wise sum of codon counts for the codons
...
...
@@ -477,46 +485,6 @@ def max_codon_counts(row, codons):
return
max
(
counts_codons
)
def
group_codons_by_class_old
(
codon_counts
,
group_name
,
dict_classes
,
mode
=
"
max
"
,
keep_only_groups
=
False
):
"""
Group codons given specific classes in *codon_counts* table.
*group_name* contains the name of the grouping, and plays the role
of aa names in the original codon counts table.
*dict_classes* contains the different classes under this grouping
as keys and the associated list of codons as values.
*mode* defines the way grouping is computed.
If mode is
"
max
"
, the maximum value of counts of codons belonging
to the same class is used for the grouped class.
Otherwise, the sum of counts values for all codons belonging to
the same class is used for the grouped class.
*keep_only_groups* is a boolean set to True if you want to filter out
other codons than the ones specified in dict_classes.
If set to False (default), the original codon_counts table
is returned with additional columns for the grouped_classes.
"""
list_classes_names
=
[]
# pylint issues the following warning:
# "W0640: Cell variable value defined in loop (cell-var-from-loop)"
# Since the lambda function is used immediately,
# this should not be an actual issue
# (see https://stackoverflow.com/q/25314547/1878788 and answers)
for
key
,
value
in
dict_classes
.
items
():
if
mode
==
"
max
"
:
codon_counts
[
group_name
,
key
]
=
codon_counts
.
apply
(
lambda
row
:
max_codon_counts
(
row
,
value
),
axis
=
1
)
else
:
codon_counts
[
group_name
,
key
]
=
codon_counts
.
apply
(
lambda
row
:
sum_codon_counts
(
row
,
value
),
axis
=
1
)
list_classes_names
.
append
(
key
)
if
keep_only_groups
:
return
codon_counts
.
loc
[:,
([
group_name
],
list_classes_names
)]
else
:
return
codon_counts
def
group_codons_by_class
(
codon_counts
,
group_name
,
dict_classes
,
mode
=
"
max
"
,
keep_only_groups
=
False
):
...
...
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