Closes #2; support Extensions on the end of a Strand#230
Conversation
…th_relative_offset_on_empty_error
|
@dave-doty For creating a 5' extension, should the extension chain method only take effect when a domain is added, similar to how cross works? Or should it just add an extension immediately? scadnano-python-package/scadnano/scadnano.py Lines 2265 to 2266 in 6a2c101 |
It should be like design.draw_strand(0,0).move(10).cross(1).move(-5).extension(6)On the other hand, if it is the first substrand, it's not clear what's the best approach. |
After thinking about this for a second, I think the best is to have an optional argument design.draw_strand(0, 0, extension_5p_length=6).move(10)Then maybe the name of the |
… argument to draw_strand
I think this is a good idea and I'll proceed with implementing this way.
design.draw_strand(0, 0, extension_5p_length=6)
Edit: Disregard the question above, I just realize that we have always been using the absence of a value to indicate default so there's no need to explicitly figure out what the offset is and just assign None to it and make relative_offset an Optional field |
|
@dave-doty Almost finished implementation in the Python library. Just wanted to double check a few things with you. I have 3 test cases for actions that I think should be disallowed and wanted to see if you agree. scadnano-python-package/tests/scadnano_tests.py Lines 3271 to 3280 in 06fe222 scadnano-python-package/tests/scadnano_tests.py Lines 3361 to 3380 in 06fe222 scadnano-python-package/tests/scadnano_tests.py Lines 3429 to 3446 in 06fe222 Essentially, should ligate, crossover, and half-crossover be disallowed if applied to the domain on the side where the extension is located. I also have test cases for normal cases for ligate, crossover, and nick. All the error cases and normal cases begin here, if you want to take a look: scadnano-python-package/tests/scadnano_tests.py Line 3271 in 06fe222 |
|
Yes, I agree those cases should all be errors. |
|
I notice a similar problem with crossovers: In the example here, adding a crossover between 1 and 2 at offset 0 should not be allowed. The web app prevents this (because of the modify crossover feature) but there are no checks in the python code: def test_add_half_crossover_middle(self) -> None:
"""
0 +------]
|
1 +------>
2 <------]
"""
# Setup
design: sc.Design = sc.Design(
helices=[sc.Helix(max_offset=100), sc.Helix(max_offset=100), sc.Helix(max_offset=100)]
)
design.draw_strand(0, 10).to(0).cross(1).to(10)
design.draw_strand(2, 10).to(0)
design.add_half_crossover(1, 2, 0, True)The code should throw an error but instead, we get a new design with strands: "strands": [
{
"color": "#57bb00",
"domains": [
{"helix": 2, "forward": false, "start": 0, "end": 10},
{"helix": 0, "forward": false, "start": 0, "end": 10},
{"helix": 1, "forward": true, "start": 0, "end": 10}
]
}
]which visually looks like: which isn't right either. Am I using these functions incorrectly or are there actual bugs? |
Definitely looks like an error to me. Do you mind adding unit tests to ensure it raises an exception? |
This also looks like a bug. |
|
@dave-doty Changes are ready to merge to dev now |
|
Can you write up some simple release notes and put them as a comment in the related issue #2? That way we can copy/paste them into the release notes when this is merged to main. |


WIP: #2
@dave-doty I added some unit tests for chain methods for DNA extensions. Can you give feedback on the unit tests written so far. Is the tested behavior desirable? Are there additional tests/behavior you would like me to add?