• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Edinburgh-Genome-Foundry / DnaChisel / 14225166311

02 Apr 2025 04:53PM UTC coverage: 90.508% (+0.5%) from 90.054%
14225166311

push

github

veghp
Switch to Sphinx

2994 of 3308 relevant lines covered (90.51%)

0.91 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

91.67
/dnachisel/builtin_specifications/AvoidStopCodons.py
1
from ..biotools import translate
1✔
2
from ..Location import Location
1✔
3
from ..Specification import SpecEvaluation
1✔
4
from .CodonSpecification import CodonSpecification
1✔
5

6
from Bio.Data import CodonTable
1✔
7

8

9
class AvoidStopCodons(CodonSpecification):
1✔
10
    """Do not introduce any new stop codon in that frame.
11

12
    This can be used for research purposes, to avoid breaking a reading frame
13
    when editing it with quasi-synonymous mutations.
14
    """
15

16
    def __init__(self, genetic_table="Standard", location=None, boost=1.0):
1✔
17
        self.genetic_table = genetic_table
1✔
18
        self.boost = boost
1✔
19
        self.location = Location.from_data(location)
1✔
20

21
    def initialized_on_problem(self, problem, role):
1✔
22
        """Get translation from the sequence if it is not already set."""
23
        return self._copy_with_full_span_if_no_location(problem)
1✔
24

25
    def localized_on_window(self, new_location, start_codon, end_codon):
1✔
26
        return self.copy_with_changes(location=new_location)
1✔
27

28
    def evaluate(self, problem):
1✔
29
        location = (
1✔
30
            self.location
31
            if self.location is not None
32
            else Location(0, len(problem.sequence))
33
        )
34
        subsequence = location.extract_sequence(problem.sequence)
1✔
35
        translation = translate(subsequence, table=self.genetic_table)
1✔
36
        errors_locations = [
1✔
37
            self.codon_index_to_location(index)
38
            for index in range(len(translation))
39
            if translation[index] == "*"
40
        ]
41
        return SpecEvaluation(
1✔
42
            self,
43
            problem,
44
            score=-len(errors_locations),
45
            locations=errors_locations,
46
            message=(
47
                "All OK."
48
                if len(errors_locations) == 0
49
                else "Stop codons found at indices %s" % errors_locations
50
            ),
51
        )
52

53
    def __str__(self):
1✔
54
        """Represent."""
55
        return "AvoidStopCodons(%s)" % self.location
×
56

57
    def __str__(self):
1✔
58
        """Represent."""
59
        return "AvoidStopCodons(%s)" % self.location
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc