Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error if location not specified #53

Closed
veghp opened this issue Apr 1, 2021 · 1 comment
Closed

Error if location not specified #53

veghp opened this issue Apr 1, 2021 · 1 comment

Comments

@veghp
Copy link
Member

veghp commented Apr 1, 2021

Issue for bug mentioned in #52 (comment).
If no location given;

from dnachisel import DnaOptimizationProblem, EnforcePatternOccurence
seq="AAAAAAAAAA"

problem = DnaOptimizationProblem(
    sequence=seq,
    constraints=[
        EnforcePatternOccurence(pattern='CTG', occurences=2, strand=-1)
    ],
)

then:

AttributeError                            Traceback (most recent call last)
<ipython-input-219-82901a020845> in <module>
      5     sequence=seq,
      6     constraints=[
----> 7         EnforcePatternOccurence(pattern='CTG', occurences=2, strand=-1)
      8     ],
      9 )

/path/to/DnaChisel/dnachisel/builtin_specifications/EnforcePatternOccurence.py in __init__(self, pattern, occurences, location, strand, center, boost)
     69             if strand not in [-1, 0, 1]:
     70                 raise ValueError("unknown strand: %s" % strand)
---> 71             self.location.strand = strand
     72         self.strand = strand
     73         self.occurences = occurences

AttributeError: 'NoneType' object has no attribute 'strand'

because in

self.location = Location.from_data(location)
from_data() returns a None as location, and a value is assigned to its attribute in:
This issue also exists in other classes.

@veghp
Copy link
Member Author

veghp commented Sep 6, 2021

Also: missing explanation of the default option strand="from_location". The docstring example EnforcePatternOccurence('BsmBI_site', strand=1) does not work.

A proposed solution is in the issue53 branch:

self.location = Location.from_data(location)

I made handling of the 6 cases of initialisation more explicit: location=None or specified * 3 strand options: "from_location", "both", one of [-1, 0, 1], and carried over the intended strand with

copy_of_constraint = self._copy_with_full_span_if_no_location(problem)

If this approach proves correct, I'll add more tests, and implement the changes in AvoidPattern too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant