cadnano.strand.strand module

class Strand(strandset, base_idx_low, base_idx_high, oligo=None)

Bases: cadnano.cnobject.CNObject

A Strand is a continuous stretch of bases that are all in the same StrandSet (recall: a VirtualHelix is made up of two StrandSets).

Every Strand has two endpoints. The naming convention for keeping track of these endpoints is based on the relative numeric value of those endpoints (low and high). Thus, Strand has a ‘_base_idx_low’, which is its index with the lower numeric value (typically positioned on the left), and a ‘_base_idx_high’ which is the higher-value index (typically positioned on the right)

Strands can be linked to other strands by “connections”. References to connected strands are named “_strand5p” and “_strand3p”, which correspond to the 5’ and 3’ phosphate linkages in the physical DNA strand, respectively. Since Strands can point 5’-to-3’ in either the low-to-high or high-to-low directions, connection accessor methods (connectionLow and connectionHigh) are bound during the init for convenience.

Parameters:
  • strandset (StrandSet) –
  • base_idx_low (int) – low index
  • base_idx_high (int) – high index
  • oligo (cadnano.oligo.Oligo) – optional, defaults to None.
abstractSeq()
addInsertion(idx, length, use_undostack=True)

Adds an insertion or skip at idx. length should be:

>0 for an insertion
-1 for a skip
Parameters:
  • idx (int) –
  • length (int) –
  • use_undostack (bool) – optional, default is True
addMods(document, mod_id, idx, use_undostack=True)

Used to add mods during a merge operation.

applyAbstractSequence()

Assigns virtual index from 5’ to 3’ on strand and it’s complement location.

canInstallXoverAt(idx, from_strand, from_idx)

Assumes idx is: self.lowIdx() <= idx <= self.highIdx()

canResizeTo(new_low, new_high)

Checks to see if a resize is allowed. Similar to getResizeBounds but works for two bounds at once.

changeInsertion(idx, length, use_undostack=True)
Parameters:
  • idx (int) –
  • length (int) –
  • use_undostack (bool) – optional, default is True
clearAbstractSequence()
clearDecoratorCommands()
clearInsertionsCommands(insertions, idxL, idxH)

clear out insertions in this range

connection3p()
connection5p()
copyAbstractSequenceToSequence()
destroy()
document()
dump5p()
generator3pStrand()

Iterate from self to the final _strand3p is None 5prime to 3prime Includes originalCount to check for circular linked list

Yields:Strand – 3’ connected Strand
generator5pStrand()

Iterate from self to the final _strand5p is None 3’ to 5’

Includes originalCount to check for circular linked list

Yields:Strand – 5’ connected Strand
getColor()
getComplementStrands()

Return the list of complement strands that overlap with this strand.

getRemoveInsertionCommands(new_idxs)

Removes Insertions, Decorators, and Modifiers that have fallen out of range of new_idxs.

For insertions, it finds the ones that have neither Staple nor Scaffold strands at the insertion idx as a result of the change of this strand to new_idxs

getResizeBounds(idx)

Determines (inclusive) low and high drag boundaries resizing from an endpoint located at idx.

When resizing from _base_idx_low:

low bound is determined by checking for lower neighbor strands.
high bound is the index of this strand's high cap, minus 1.

When resizing from _base_idx_high:

low bound is the index of this strand's low cap, plus 1.
high bound is determined by checking for higher neighbor strands.

When a neighbor is not present, just use the Part boundary.

getSequenceList()

return the list of sequences strings comprising the sequence and the inserts as a tuple with the index of the insertion [(idx, (strandItemString, insertionItemString), …]

This takes advantage of the fact the python iterates a dictionary by keys in order so if keys are indices, the insertions will iterate out from low index to high index

hasInsertionAt(idx)
hasXoverAt(idx)

An xover is necessarily at an enpoint of a strand

highIdx()
idNum()
idx3Prime()

Returns the absolute base_idx of the 3’ end of the strand. overloaded in __init__

idx5Prime()

Returns the absolute base_idx of the 5’ end of the strand. overloaded in __init__

idxs()
insertionLengthBetweenIdxs(idxL, idxH)

includes the length of insertions in addition to the bases

insertionsOnStrand(idxL=None, idxH=None)

if passed indices it will use those as a bounds

isForward()
length()
lowIdx()
merge(idx)

Check for neighbor, then merge if possible.

Parameters:idx (int) –
Raises:IndexError
modifersOnStrand()
oligo()
part()
reapplySequence()
removeInsertion(idx, use_undostack=True)
Parameters:
  • idx (int) –
  • use_undostack (bool) – optional, default is True
removeMods(document, mod_id, idx, use_undostack=True)

Used to add mods during a merge operation.

resize(new_idxs, use_undostack=True, update_segments=True)
sequence(for_export=False)
setComplementSequence(sequence_string, strand)

This version takes anothers strand and only sets the indices that align with the given complimentary strand.

As it depends which direction this is going, and strings are stored in memory left to right, we need to test for is_forward to map the reverse compliment appropriately, as we traverse overlapping strands.

We reverse the sequence ahead of time if we are applying it 5’ to 3’, otherwise we reverse the sequence post parsing if it’s 3’ to 5’

Again, sequences are stored as strings in memory 5’ to 3’ so we need to jump through these hoops to iterate 5’ to 3’ through them correctly

Perhaps it’s wiser to merely store them left to right and reverse them at draw time, or export time

Parameters:
  • sequence_string (str) –
  • strand (Strand) –
Returns:

str – the used portion of the sequence_string

setConnection3p(strand)
setConnection5p(strand)
setIdxs(idxs)
setOligo(new_oligo, emit_signal=True)
setSequence(sequence_string)

Applies sequence string from 5’ to 3’ return the tuple (used, unused) portion of the sequence_string

Parameters:sequence_string (str) –
Returns:tuple

of str of form:

(used, unused)
shallowCopy()
split(idx, update_sequence=True)

Called by view items to split this strand at idx.

strandFilter()
strandHasNewOligoSignal = <cadnano.cnproxy.DummySignal object>

pyqtSignal(QObject) – strand

strandInsertionAddedSignal = <cadnano.cnproxy.DummySignal object>

pyqtSignal(QObject, object) – (strand, insertion object)

strandInsertionChangedSignal = <cadnano.cnproxy.DummySignal object>

#pyqtSignal(QObject, object) – (strand, insertion object)

strandInsertionRemovedSignal = <cadnano.cnproxy.DummySignal object>

#pyqtSignal(QObject, int) – # Parameters: (strand, insertion index)

strandModsAddedSignal = <cadnano.cnproxy.DummySignal object>

pyqtSignal(QObject, object, str, int) – (strand, document, mod_id, idx)

strandModsChangedSignal = <cadnano.cnproxy.DummySignal object>

pyqtSignal(QObject, object, str, int) – (strand, document, mod_id, idx)

strandModsRemovedSignal = <cadnano.cnproxy.DummySignal object>

pyqtSignal(QObject, object, str, int) – (strand, document, mod_id, idx)

strandRemovedSignal = <cadnano.cnproxy.DummySignal object>

pyqtSignal(QObject) – strand

strandResizedSignal = <cadnano.cnproxy.DummySignal object>

pyqtSignal(QObject, tuple)

strandSelectedChangedSignal = <cadnano.cnproxy.DummySignal object>

pyqtSignal(QObject, tuple) – (strand, value)

strandSet()
strandType()
strandUpdateSignal = <cadnano.cnproxy.DummySignal object>

pyqtSignal(QObject) – strand

strandXover5pRemovedSignal = <cadnano.cnproxy.DummySignal object>

pyqtSignal(QObject, QObject) – (strand3p, strand5p)

totalLength()

includes the length of insertions in addition to the bases

sixb(x)
tostring(x)