Skip to content

Commit

Permalink
test: fix for static code analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
deliaBlue committed Jul 28, 2024
1 parent 84b9abe commit 97b5637
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions scripts/mirna_quantification.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,17 +242,18 @@ def collapsed_nh_contribution(aln: pysam.AlignedSegment) -> float:
The contribution is computed as the ratio of the number of reads collapsed
in the alignment and the NH value. It is assumed that the alignment query
name contians the number of collapsed reads as well as the NH value in the
name contains the number of collapsed reads as well as the NH value in the
format NAME-COUNT_NH.
Args:
aln:
Alignment to which the overall contribution is calculated
Returns:
the conrtibution of the alignment to the overall count
the contribution of the alignment to the overall count
"""
name = str(aln.query_name)
values = []
try:
if val := re.search(r"\d+_\d+$", name):
values = val.group().split("_")
Expand All @@ -274,17 +275,18 @@ def collapsed_contribution(aln: pysam.AlignedSegment) -> float:
The contribution is computed as the ratio of the number of reads collapsed
in the alignment and the value stored in the NH tag. If the tag is missing,
the NH value is 1. It is assumed that the alignment query name contians
the NH value is 1. It is assumed that the alignment query name contains
the number of collapsed reads in the format NAME-COUNT.
Args:
aln:
Alignment to which the overall contribution is calculated
Returns:
the conrtibution of the alignment to the overall count
the contribution of the alignment to the overall count
"""
name = str(aln.query_name)
collapsed = 0.0
try:
if coll := re.search(r"\d+$", name):
collapsed = float(coll.group())
Expand Down Expand Up @@ -312,17 +314,18 @@ def nh_contribution(aln: pysam.AlignedSegment) -> float:
The contribution is computed as the ratio of the number of reads collapsed
in the alignment and the value stored in the NH tag. If the tag is missing,
the NH value is 1. It is assumed that the alignment query name contians the
the NH value is 1. It is assumed that the alignment query name contains the
NH value in the format NAME_NH.
Args:
aln:
Alignment to which the overall contribution is calculated
Returns:
the conrtibution of the alignment to the overall count
the contribution of the alignment to the overall count
"""
name = str(aln.query_name)
nh_val = 0.0
try:
if cont := re.search(r"\d+$", name):
nh_val = float(cont.group())
Expand Down Expand Up @@ -352,7 +355,7 @@ def contribution(aln: pysam.AlignedSegment) -> float:
Alignment to which the overall contribution is calculated
Returns:
the conrtibution of the alignment to the overall count
the contribution of the alignment to the overall count
"""
try:
return 1 / float(aln.get_tag("NH"))
Expand All @@ -362,7 +365,7 @@ def contribution(aln: pysam.AlignedSegment) -> float:


def get_name(pre_name: str) -> list[str]:
"""Get the final name for the spieces name.
"""Get the final name for the species name.
Take a string and processes it to obtain the final name for the species
and the type of miRNA the string belongs to. Only the feat_name is
Expand Down

0 comments on commit 97b5637

Please sign in to comment.