Breaking Change: removed `domain_names` parameter from `Strand` constructor
In fixing issue 175, we have removed the argument `domain_names` from the `Strand` constructor. Now, the correct way to create a `Strand` from a list of domain names is to call the new method [`Design.add_strand`](https://nuad.readthedocs.io/en/latest/#constraints.Design.add_strand).
In particular, you will need to create a `Design` prior to creating any strands.
The [`Design.add_strand`](https://nuad.readthedocs.io/en/latest/#constraints.Design.add_strand) method returns the `Strand` that was created, so `design.add_strand` should be a drop-in replacement for the `Strand` constructor that was previously used in this way.
So replace code like this:
python
XXX: no longer works
strands = [Strand(domain_names=[f'a{i}', f'b{i}']) for i in range(5)]
design = Design(strands)
with this
python
new way to create a Strand from domain names
design = Design()
strands = [design.add_strand(domain_names=[f'a{i}', f'b{i}']) for i in range(5)]
The reason this was done was to address issue 175. When the `add_strand` method sees a new domain name, it creates a new `Domain` object and saves it in the `Design`, and when it sees a domain name that has been used before with the same `Design`, then it uses the saved `Domain`.
Previously, this saved `Domain` object was stored in a global variable, which caused incorrect results in scripts where two designs were used at the same time with the same domain names.
Caution: call `Design.computed_derived_fields()`
Previously, it was advisable to create the `Design` last, after creating all domains and strands. The constructor calls a method `Design.computed_derived_fields()` that computes some fields based on other fields in `Design`.
This method is called at the start of `nuad.search.search_for_dna_sequences`, so if all you do with a design is give it to this function, your code should still work. However, if you are doing any other processing in between creating the `Design` object and calling that function, then it is safest to call `Design.computed_derived_fields()` to ensure that these fields have the proper values.
For example, the field `Design.domains` is computed based on the strands in the design, so for it to be correct this method may need to be called, in case Strands were added "manually" by appending to the field `Design.strands`, although that field should be correct if `Design.add_strand` is called to add strands.
Commits
- 31b3220: updated requirements to include tabulate and installation instructions in README (David Doty) [207](https://github.com/UC-Davis-molecular-computing/nuad/pull/207)
- a50a454: Update search.py (David Doty) [207](https://github.com/UC-Davis-molecular-computing/nuad/pull/207)
- 13e6337: fixes 190: `DomainPool`'s should have distinct names (David Doty) [204](https://github.com/UC-Davis-molecular-computing/nuad/pull/204)
- ec40907: closes 175: Domains and pools should be stored per-design (David Doty) [206](https://github.com/UC-Davis-molecular-computing/nuad/pull/206)
- bfb9c17: updated installation instructions to include pip (David Doty) [207](https://github.com/UC-Davis-molecular-computing/nuad/pull/207)
- 422e391: Update README.md (David Doty) [207](https://github.com/UC-Davis-molecular-computing/nuad/pull/207)
- 1ba345b: Update README.md (David Doty) [207](https://github.com/UC-Davis-molecular-computing/nuad/pull/207)
- beeb30c: Update README.md (David Doty) [207](https://github.com/UC-Davis-molecular-computing/nuad/pull/207)
- d7e1619: Update README.md (David Doty) [207](https://github.com/UC-Davis-molecular-computing/nuad/pull/207)
- 6e74f96: Update README.md (David Doty) [207](https://github.com/UC-Davis-molecular-computing/nuad/pull/207)
- 4b16c91: Update constraints.py (David Doty) [206](https://github.com/UC-Davis-molecular-computing/nuad/pull/206)
- f6dda1a: switched to print statements instead of logging for iteration updates; still need to add SearchParameters options to control this more (David Doty) [206](https://github.com/UC-Davis-molecular-computing/nuad/pull/206)
- 3b47359: closes 134: implement `SearchParameters.report_only_violations` (David Doty) [205](https://github.com/UC-Davis-molecular-computing/nuad/pull/205)
- d9cd965: Update search.py (David Doty) [205](https://github.com/UC-Davis-molecular-computing/nuad/pull/205)
- 43a5cc8: removed Python 3.8+ f-string formatting (David Doty) [205](https://github.com/UC-Davis-molecular-computing/nuad/pull/205)
- e56a861: Merge branch 'dev' into 175-domains-and-pools-are-global-rather-than-per-design-recreating-same-design-causes-error (David Doty) [206](https://github.com/UC-Davis-molecular-computing/nuad/pull/206)
- 6c5f215: added option `SearchParameters.scrolling_output` to control whether screen output scrolls on the terminal or updates in place (David Doty) [206](https://github.com/UC-Davis-molecular-computing/nuad/pull/206)
- 3c1ab46: bumped version since removing `domain_names` parameter from `Strand` constructor will be a breaking change (David Doty) [206](https://github.com/UC-Davis-molecular-computing/nuad/pull/206)
- faaaec3: updated docstring for scrolling_output (David Doty) [206](https://github.com/UC-Davis-molecular-computing/nuad/pull/206)
- e490fdd: fixed unit tests to use `Design.add_strand` instead of Strand constructor with `domain_names` parameter (David Doty) [206](https://github.com/UC-Davis-molecular-computing/nuad/pull/206)
- caabd55: fixed API calls in examples in examples folder (David Doty) [207](https://github.com/UC-Davis-molecular-computing/nuad/pull/207)
- 9387ad3: fixed unit test calling Complex constructor (David Doty) [207](https://github.com/UC-Davis-molecular-computing/nuad/pull/207)