### Install scadnano using pip Source: https://github.com/uc-davis-molecular-computing/scadnano-python-package/blob/main/README.md Use this command to install the scadnano package via pip. Ensure pip is installed and up-to-date. ```console pip install scadnano ``` -------------------------------- ### Install required packages for manual download Source: https://github.com/uc-davis-molecular-computing/scadnano-python-package/blob/main/README.md Before downloading scadnano manually, install the 'openpyxl' and 'tabulate' packages using pip. ```console pip install openpyxl tabulate ``` -------------------------------- ### Verify scadnano installation and basic usage Source: https://github.com/uc-davis-molecular-computing/scadnano-python-package/blob/main/README.md After installation, open a Python interpreter to import the scadnano module and create a Domain object. This confirms the package is working correctly. ```python import scadnano as sc print(sc.Domain(helix=1, forward=True, start=0, end=8)) ``` -------------------------------- ### Install xlwt for Excel export Source: https://github.com/uc-davis-molecular-computing/scadnano-python-package/blob/main/README.md To use the `Design.write_idt_plate_excel_file()` method, install the 'xlwt' package. This is automatically installed if you use pip to install scadnano. ```console pip install xlwt ``` -------------------------------- ### Check pip version Source: https://github.com/uc-davis-molecular-computing/scadnano-python-package/blob/main/README.md Verify your pip installation and associated Python version. If Python 3.9 or higher is not detected, you may need to use `pip3`. ```console pip --version ``` -------------------------------- ### Create a table with custom well markers Source: https://github.com/uc-davis-molecular-computing/scadnano-python-package/blob/main/doc/index.md Use a lambda function for the `well_marker` argument to dynamically set the content of each well based on its address. This example places the well's address (e.g., 'B3') into the well itself. ```python mix.to_table(well_marker=lambda x: x) ``` -------------------------------- ### Create and Write Basic Design Source: https://context7.com/uc-davis-molecular-computing/scadnano-python-package/llms.txt Demonstrates drawing strands and writing a basic scadnano file. Ensure the 'output_designs' directory exists. ```python import scadnano as sc # Create a design with two helices helices = [sc.Helix(max_offset=100), sc.Helix(max_offset=100)] design = sc.Design(helices=helices, grid=sc.square) # Add strands design.draw_strand(0, 0).move(50).cross(1).move(-50) design.draw_strand(2, 0).move(50).cross(3).move(-50) design.write_scadnano_file(directory='output_designs') ``` -------------------------------- ### Create Extensions and Strands Source: https://github.com/uc-davis-molecular-computing/scadnano-python-package/blob/main/doc/index.md Demonstrates how to instantiate Extension objects and include them in a Strand definition. ```Python import scadnano as sc domain = sc.Domain(helix=0, forward=True, start=0, end=10) left_toehold = sc.Extension(num_bases=3) right_toehold = sc.Extension(num_bases=2) strand = sc.Strand([left_toehold, domain, right_toehold]) ``` -------------------------------- ### Construct a strand using StrandBuilder Source: https://github.com/uc-davis-molecular-computing/scadnano-python-package/blob/main/doc/index.md Demonstrates the fluent interface for building a strand domain by domain, and the equivalent manual construction using the Strand class. ```python design.draw_strand(0, 7).to(10).cross(1).to(5).cross(2).to(15) ``` ```python design.add_strand(Strand([ sc.Domain(0, True, 7, 10), sc.Domain(1, False, 5, 10), sc.Domain(2, True, 5, 15), ])) ``` -------------------------------- ### Initialize an empty scadnano design Source: https://github.com/uc-davis-molecular-computing/scadnano-python-package/blob/main/tutorial/tutorial.md Create a basic Python script to initialize an empty scadnano design and export it to a .sc file. ```python import scadnano as sc def main() -> None: design = create_design() design.write_scadnano_file() def create_design() -> sc.Design: design = sc.Design() return design if __name__ == '__main__': main() ``` -------------------------------- ### GET domain_at Source: https://github.com/uc-davis-molecular-computing/scadnano-python-package/blob/main/doc/index.md Retrieves a specific domain at a given helix and offset. ```APIDOC ## GET domain_at ### Description Returns the Domain that overlaps a specific offset on a helix with a specific forward orientation. ### Parameters #### Query Parameters - **helix** (int) - Required - The index of the helix. - **offset** (int) - Required - The offset on the helix. - **forward** (bool) - Required - The forward orientation of the domain. ### Response #### Success Response (200) - **domain** (Domain | None) - The matching Domain object or None if not found. ``` -------------------------------- ### GET domains_at Source: https://github.com/uc-davis-molecular-computing/scadnano-python-package/blob/main/doc/index.md Retrieves a list of domains overlapping a specific helix and offset. ```APIDOC ## GET domains_at ### Description Returns a list of all Domains that overlap a specific offset on a given helix. ### Parameters #### Query Parameters - **helix** (int) - Required - The index of the helix. - **offset** (int) - Required - The offset on the helix. ### Response #### Success Response (200) - **domains** (List[Domain]) - A list of Domain objects overlapping the specified location. ``` -------------------------------- ### Create Strands with Chained Methods Source: https://github.com/uc-davis-molecular-computing/scadnano-python-package/blob/main/doc/index.md Shows how to use fluent method chaining to construct a strand with extensions on both sides of a domain. ```Python import scadnano as sc design = sc.Design(helices=[sc.Helix(max_offset=10)]) design.draw_strand(0,0).extension_5p(3).move(10).extension_3p(2) ``` -------------------------------- ### GET base_pairs Source: https://github.com/uc-davis-molecular-computing/scadnano-python-package/blob/main/doc/index.md Retrieves a mapping of helix indices to lists of offsets where base pairs are located. ```APIDOC ## GET base_pairs ### Description Returns a dictionary mapping each helix index to a list of offsets on that helix where two strands are paired. ### Parameters #### Query Parameters - **allow_mismatches** (bool) - Optional - If True, includes offsets with insertions on either domain regardless of sequence complementarity. Defaults to False. ### Response #### Success Response (200) - **result** (Dict[int, List[int]]) - A dictionary where keys are helix indices and values are lists of offsets. ``` -------------------------------- ### Suppress JSON Indentation in scadnano Files Source: https://github.com/uc-davis-molecular-computing/scadnano-python-package/blob/main/doc/index.md Example of how JSON output appears when suppress_indent is set to True versus False. ```JSON { "grid_position": [1, 2] } ``` ```JSON { "grid_position": [ 1, 2 ] } ``` -------------------------------- ### Get M13 Scaffold Sequence Source: https://context7.com/uc-davis-molecular-computing/scadnano-python-package/llms.txt Retrieves the M13 scaffold sequence for a specified rotation and variant. The length of the sequence depends on the chosen variant. ```python import scadnano as sc # Get M13 scaffold sequence with custom rotation m13_seq = sc.m13(rotation=5587, variant=sc.M13Variant.p7249) print(f"M13 p7249 length: {len(m13_seq)}") # 7249 ``` -------------------------------- ### Clone the scadnano repository Source: https://github.com/uc-davis-molecular-computing/scadnano-python-package/blob/main/CONTRIBUTING.md Initial step to obtain a local copy of the project source code. ```bash git clone https://github.com/UC-Davis-molecular-computing/scadnano-python-package.git ``` -------------------------------- ### Switch to the development branch Source: https://github.com/uc-davis-molecular-computing/scadnano-python-package/blob/main/CONTRIBUTING.md Command to switch to the dev branch where all contributions should be pushed. ```bash git checkout dev ``` -------------------------------- ### Create a DNA Design Source: https://github.com/uc-davis-molecular-computing/scadnano-python-package/blob/main/tutorial/tutorial.md Initializes a new DNA design with a specified number of helices and a square grid. This is the starting point for all subsequent design modifications. ```python def create_design() -> sc.Design: helices = [sc.Helix(max_offset=288) for _ in range(24)] design = sc.Design(helices=helices, grid=sc.square) add_scaffold_precursors(design) add_scaffold_crossovers(design) add_staple_precursors(design) ### return design ``` -------------------------------- ### Design Initialization from SCADnano File Source: https://github.com/uc-davis-molecular-computing/scadnano-python-package/blob/main/doc/index.md Loads a Design object from a SCADnano JSON file. ```APIDOC ## static from_scadnano_file(filename) ### Description Loads a [Design](#scadnano.Design) from the file with the given name. ### Parameters #### Path Parameters - **filename** (str) - Required - name of the file with the design. Should be a JSON file ending in .sc ### Returns Design described in the file ### Return type [Design](#scadnano.Design) ``` -------------------------------- ### Add Staple Nicks Source: https://github.com/uc-davis-molecular-computing/scadnano-python-package/blob/main/tutorial/tutorial.md Inserts nicks into the staple strands at regular intervals along each helix. The starting offset for these nicks varies based on the helix index parity. ```python def add_staple_nicks(design: sc.Design) -> None: for helix in range(24): start_offset = 24 if helix % 2 == 0 else 40 for offset in range(start_offset, 272, 32): design.add_nick(helix, offset, forward=helix % 2 == 1) ``` -------------------------------- ### Build a Strand using chained methods Source: https://github.com/uc-davis-molecular-computing/scadnano-python-package/blob/main/doc/index.md Demonstrates the use of chained method calls to define a strand's path, modifications, and scaffold status. ```python design.draw_strand(0, 0).to(10).cross(1).to(5).with_modification_5p(mod.biotin_5p).as_scaffold() ``` -------------------------------- ### Add Staple Crossovers Source: https://github.com/uc-davis-molecular-computing/scadnano-python-package/blob/main/tutorial/tutorial.md Adds crossovers between adjacent staple strands on neighboring helices. The starting offset and spacing of these crossovers are dependent on the helix index parity, with a specific offset near the seam being omitted. ```python def add_staple_crossovers(design: sc.Design) -> None: for helix in range(23): start_offset = 16 if helix % 2 == 0 else 32 for offset in range(start_offset, 288, 32): if offset != 144: # skip crossover near seam design.add_full_crossover(helix=helix, helix2=helix + 1, offset=offset, forward=helix % 2 == 1) ``` -------------------------------- ### Create a Hairpin Strand with Loopout Source: https://github.com/uc-davis-molecular-computing/scadnano-python-package/blob/main/doc/index.md Demonstrates creating a hairpin structure using Domain and Loopout objects. Ensure that loopouts are not at the ends of a strand and that two consecutive loopouts are not used. ```Python import scadnano as sc domain_f = sc.Domain(helix=0, forward=True, start=0, end=10) loop = sc.Loopout(length=5) domain_r = sc.Domain(helix=0, forward=False, start=0, end=10) hairpin = sc.Strand([domain_f, loop, domain_r]) ``` -------------------------------- ### Create Scaffold Strand using Constructor Source: https://github.com/uc-davis-molecular-computing/scadnano-python-package/blob/main/doc/index.md Instantiate a Strand object and set it as a scaffold using the 'is_scaffold' parameter. ```Python import scadnano as sc scaffold_domains = [ ... ] scaffold_strand = sc.Strand(domains=scaffold_domains, is_scaffold=True) ``` -------------------------------- ### Execute a scadnano script Source: https://github.com/uc-davis-molecular-computing/scadnano-python-package/blob/main/tutorial/tutorial.md Run the Python script from the command line to generate the design file. ```console python 24_helix_rectangle.py ``` ```console python3 24_helix_rectangle.py ``` -------------------------------- ### Scaffold Strand Representation in JSON Output Source: https://github.com/uc-davis-molecular-computing/scadnano-python-package/blob/main/tutorial/tutorial.md Illustrates the JSON structure for scaffold strands within a scadnano design. Each scaffold strand is represented with a color, a list of domains (specifying helix, direction, start, and end points), and a boolean indicating if it's a scaffold. ```json "strands": [ { "color": "#0066cc", "domains": [ {"helix": 0, "forward": true, "start": 0, "end": 288} ], "is_scaffold": true }, { "color": "#0066cc", "domains": [ {"helix": 2, "forward": true, "start": 0, "end": 288} ], "is_scaffold": true }, { "color": "#0066cc", "domains": [ {"helix": 4, "forward": true, "start": 0, "end": 288} ], "is_scaffold": true }, { "color": "#0066cc", ... ``` -------------------------------- ### Create Scaffold Strand using StrandBuilder Source: https://github.com/uc-davis-molecular-computing/scadnano-python-package/blob/main/doc/index.md Create a Design object, obtain a StrandBuilder using design.strand(), and then use .as_scaffold() to create a scaffold strand. ```Python import scadnano as sc design = sc.Design(helices=[sc.Helix(max_offset=100) for _ in range(2)]) scaffold_strand = design.strand(0, 0).move(100).cross(1).move(-100).as_scaffold() ``` -------------------------------- ### Create a Strand with Loopout using Chained Methods Source: https://github.com/uc-davis-molecular-computing/scadnano-python-package/blob/main/doc/index.md Illustrates an alternative method for creating a strand with a loopout by chaining design and movement methods. This approach is useful for more complex strand constructions. ```Python import scadnano as sc design = sc.Design(helices=[sc.Helix(max_offset=10)]) design.draw_strand(0,0).move(10).loopout(0,5).move(-10) ``` -------------------------------- ### Construct a strand with loopouts Source: https://github.com/uc-davis-molecular-computing/scadnano-python-package/blob/main/doc/index.md Shows how to include loopouts within a strand construction chain and the resulting Strand object structure. ```python design.draw_strand(0, 7).to(10).cross(1).to(5).loopout(2, 3).to(15) ``` ```python design.add_strand(Strand([ sc.Domain(0, True, 7, 10), sc.Domain(1, False, 5, 10), sc.Loopout(3), sc.Domain(2, True, 5, 15), ])) ``` -------------------------------- ### Design Initialization from Cadnano Source: https://github.com/uc-davis-molecular-computing/scadnano-python-package/blob/main/doc/index.md Creates a Design from a cadnano v2 design. Specify either a filename or a JSON dictionary. ```APIDOC ## static from_cadnano_v2(directory='', filename=None, json_dict=None) ### Description Creates a Design from a cadnano v2 design. The design can either be specified as a filename (assumed to be the a JSON file containing the cadnano design) or as a Python dictionary, assumed to be the result of importing the JSON from the cadnano file. Exactly one of filename or json_dict should be specified. ### Parameters #### Path Parameters - **directory** (str) - Optional - directory in which to look for filename; current directory by default. Ignored if json_dict is specified. - **filename** (str | None) - Optional - name of file containing cadnano design. Mutually exclusive with json_dict. - **json_dict** (dict | None) - Optional - cadnano design represented as a Python dict. (assumed to be the result of json.load on a cadnano file) ### Returns An scadnano design equivalent to the specified cadnano design. ### Return type [Design](#scadnano.Design) ``` -------------------------------- ### Assign names to domains or loopouts Source: https://github.com/uc-davis-molecular-computing/scadnano-python-package/blob/main/doc/index.md Use with_domain_name immediately after creating a domain or loopout to assign a name. ```Python design.draw_strand(0, 0).to(10).with_domain_name('dom1*').cross(1).to(5).with_domain_name('dom1') ``` -------------------------------- ### Design Initialization from SCADnano JSON String Source: https://github.com/uc-davis-molecular-computing/scadnano-python-package/blob/main/doc/index.md Loads a Design object from a JSON string. ```APIDOC ## static from_scadnano_json_str(json_str) ### Description Loads a [Design](#scadnano.Design) from the given JSON string. ### Parameters #### Path Parameters - **json_str** (str) - Required - JSON description of the [Design](#scadnano.Design) ### Returns Design described in the JSON string ### Return type [Design](#scadnano.Design) ``` -------------------------------- ### Create Scaffold Strand using set_scaffold() Source: https://github.com/uc-davis-molecular-computing/scadnano-python-package/blob/main/doc/index.md Instantiate a Strand object and then call the set_scaffold() method to designate it as a scaffold. ```Python import scadnano as sc scaffold_domains = [ ... ] scaffold_strand = sc.Strand(domains=scaffold_domains) scaffold_strand.set_scaffold() ``` -------------------------------- ### scadnano.Domain Class Methods Source: https://github.com/uc-davis-molecular-computing/scadnano-python-package/blob/main/doc/index.md Documentation for the methods and properties available within the scadnano.Domain class. ```APIDOC ## scadnano.Domain ### Description A maximal portion of a Strand that is contiguous on a single Helix. ### Parameters - **helix** (int) - Required - **forward** (bool) - Required - **start** (int) - Required - **end** (int) - Required - **deletions** (List[int]) - Optional - **insertions** (List[Tuple[int, int]]) - Optional - **name** (str | None) - Optional - **label** (str | None) - Optional - **dna_sequence** (str | None) - Optional - **color** (Color | None) - Optional ### Methods #### compute_overlap(other) Return [left,right) offset indicating overlap between this Domain and other. - **Parameters:** other (Domain) - **Returns:** Tuple[int, int] #### contains_offset(offset) Indicates if offset is the offset of a base on this Domain. - **Parameters:** offset (int) - **Returns:** bool #### dna_length() Number of bases in this Domain. - **Returns:** int #### dna_length_in(left, right) Number of bases in this Domain between offsets left and right (INCLUSIVE). - **Parameters:** left (int), right (int) - **Returns:** int #### dna_sequence_in(offset_left, offset_right) Return DNA sequence of this Domain in the interval of offsets given by [offset_left, offset_right], INCLUSIVE. - **Parameters:** offset_left (int), offset_right (int) - **Returns:** str | None #### domain_offset_to_strand_dna_idx(offset, offset_closer_to_5p) Convert from offset on this Domain's Helix to string index on the parent Strand's DNA sequence. - **Parameters:** offset (int), offset_closer_to_5p (bool) - **Returns:** int #### get_seq_start_idx() Starting DNA subsequence index for first base of this Domain on its Parent Strand's DNA sequence. - **Returns:** int ``` -------------------------------- ### NickPattern Convenience References Source: https://github.com/uc-davis-molecular-computing/scadnano-python-package/blob/main/doc/index.md Convenience references for `NickPattern` that allow for shorter type hints. Note: These are currently unsupported. ```APIDOC ## NickPattern Convenience References ### Description These are convenience references for `origami_rectangle.NickPattern`. ### References - **origami_rectangle.even**: Equivalent to `origami_rectangle.NickPattern.even`. - **origami_rectangle.odd**: Equivalent to `origami_rectangle.NickPattern.odd`. - **origami_rectangle.staggered**: Equivalent to `origami_rectangle.NickPattern.staggered`. - **origami_rectangle.staggered_opposite**: Equivalent to `origami_rectangle.NickPattern.staggered_opposite`. **Note:** These references are currently unsupported. ``` -------------------------------- ### Design Import Methods Source: https://context7.com/uc-davis-molecular-computing/scadnano-python-package/llms.txt Methods for loading existing designs from scadnano or cadnano v2 files. ```APIDOC ## Design.from_scadnano_file / from_cadnano_v2 ### Description Loads a design from a JSON file or cadnano v2 format. ### Parameters - **filename** (str) - Required - Path to the design file. - **directory** (str) - Optional - Directory path for cadnano files. ``` -------------------------------- ### Create scadnano Design with Scaffold Precursors Source: https://github.com/uc-davis-molecular-computing/scadnano-python-package/blob/main/tutorial/tutorial.md Initializes a scadnano Design object with specified helices and then calls a function to add scaffold precursor strands. This function sets up the basic structure for the DNA design. ```python def create_design() -> sc.Design: helices = [sc.Helix(max_offset=288) for _ in range(24)] design = sc.Design(helices=helices, grid=sc.square) add_scaffold_precursors(design) ### return design ``` -------------------------------- ### Strand Methods and Properties Source: https://github.com/uc-davis-molecular-computing/scadnano-python-package/blob/main/doc/index.md Documentation for methods and properties related to Strand objects in scadnano. ```APIDOC ## GET /Strand/default_export_name ### Description Returns a default name to use when exporting the DNA sequence, following cadnano naming conventions. ### Parameters #### Query Parameters - **unique_names** (bool) - Optional - If True, enforces unique strand names by encoding forward/reverse information. ### Response #### Success Response (200) - **name** (str) - The default name to export. --- ## GET /Strand/dna_index_start_domain ### Description Returns the index in the DNA sequence where a specific domain starts. ### Parameters #### Query Parameters - **domain** (Domain | Loopout) - Required - The domain or loopout to find the start index for. ### Response #### Success Response (200) - **index** (int) - The index within the DNA sequence string. --- ## GET /Strand/dna_length ### Description Calculates the total DNA length of the strand. ### Response #### Success Response (200) - **length** (int) - Sum of DNA length of domains, loopouts, and extensions. --- ## GET /Strand/dna_sequence_delimited ### Description Returns the DNA sequence of the strand with a specified delimiter between domains. ### Parameters #### Query Parameters - **delimiter** (str) - Required - String to insert between DNA sequences of each domain. ### Response #### Success Response (200) - **sequence** (str) - The delimited DNA sequence. ``` -------------------------------- ### Configure Strand Insertions Source: https://github.com/uc-davis-molecular-computing/scadnano-python-package/blob/main/doc/index.md Applies insertions to the most recently created domain. Call this immediately after domain-creating methods like move or to. ```Python design.draw_strand(0, 0)\ .move(8).with_insertions((4, 2))\ .cross(1)\ .move(-8).with_insertions([(2, 3), (3, 3)]) ``` -------------------------------- ### StrandBuilder Configuration Methods Source: https://github.com/uc-davis-molecular-computing/scadnano-python-package/blob/main/doc/index.md Methods used to configure properties of a strand during the building process. ```APIDOC ## with_insertions(insertions) ### Description Assigns insertions to the most recently created domain of the strand being built. ### Parameters - **insertions** (Tuple[int, int] | Iterable[Tuple[int, int]]) - Required - A single pair of ints or an Iterable of pairs indicating the offset for insertions. ## with_label(label) ### Description Assigns a label to the strand being built. ### Parameters - **label** (str) - Required - The label to assign. ## with_modification_3p(mod) ### Description Sets the 3' modification for the strand being built. ### Parameters - **mod** (Modification3Prime) - Required - The 3' modification object. ## with_modification_5p(mod) ### Description Sets the 5' modification for the strand being built. ### Parameters - **mod** (Modification5Prime) - Required - The 5' modification object. ## with_modification_internal(idx, mod, warn_no_dna=True) ### Description Sets an internal modification for the strand being built. ### Parameters - **idx** (int) - Required - Index along the DNA sequence. - **mod** (ModificationInternal) - Required - The internal modification object. - **warn_no_dna** (bool) - Optional - Whether to print a warning if DNA is not assigned. ## with_name(name) ### Description Assigns a name to the strand being built. ### Parameters - **name** (str) - Required - The name to assign. ## with_sequence(sequence, assign_complement=False) ### Description Assigns a DNA sequence to the strand being built. ### Parameters - **sequence** (str) - Required - The DNA sequence. - **assign_complement** (bool) - Optional - Whether to automatically assign the complement. ## with_vendor_fields(scale='25nm', purification='STD', plate=None, well=None) ### Description Assigns vendor fields to the strand being built. ### Parameters - **scale** (str) - Optional - Vendor scale. - **purification** (str) - Optional - Vendor purification. - **plate** (str | None) - Optional - Vendor plate. - **well** (str | None) - Optional - Vendor well. ``` -------------------------------- ### Build strands using the fluent API Source: https://context7.com/uc-davis-molecular-computing/scadnano-python-package/llms.txt Use the draw_strand method for a concise, chained syntax to build strands domain by domain. This is the recommended method for programmatic design. ```python import scadnano as sc helices = [sc.Helix(max_offset=48), sc.Helix(max_offset=48)] design = sc.Design(helices=helices, grid=sc.square) # Draw a staple using .to() for absolute offsets design.draw_strand(1, 8).to(24).cross(0).to(8) # Draw a staple using .move() for relative offsets, with 5' modification design.draw_strand(0, 40).move(-16).cross(1).move(16).with_modification_5p(sc.biotin_5p) # Draw a scaffold with loopout using chained methods design.draw_strand(1, 24).move(-16).cross(0).move(32).loopout(1, 3).move(-16).as_scaffold() # Add deletions and insertions design.add_deletion(helix=1, offset=20) design.add_insertion(helix=0, offset=14, length=1) # Assign DNA sequence (also assigns complement to bound strands) design.assign_dna(design.scaffold, 'AACGT' * 18) design.write_scadnano_file(directory='output_designs') ``` -------------------------------- ### Complete Scadnano Design Script Source: https://github.com/uc-davis-molecular-computing/scadnano-python-package/blob/main/tutorial/tutorial.md This script initializes a scadnano design, adds scaffold and staple precursors, and incorporates crossovers, nicks, and deletions. It then assigns M13 to the scaffold and writes the design to files. ```python import scadnano as sc def main() -> None: design = create_design() design.write_scadnano_file() design.write_idt_plate_excel_file() def create_design() -> sc.Design: helices = [sc.Helix(max_offset=288) for _ in range(24)] design = sc.Design(helices=helices, grid=sc.square) add_scaffold_precursors(design) add_scaffold_crossovers(design) add_staple_precursors(design) add_staple_crossovers(design) add_staple_nicks(design) add_twist_correction_deletions(design) design.assign_m13_to_scaffold() return design def add_scaffold_precursors(design: sc.Design) -> None: for helix in range(0, 23, 2): # scaffold goes forward on even helices design.draw_strand(helix, 0).move(288).as_scaffold() for helix in range(1, 23, 2): # scaffold goes reverse on odd helices design.draw_strand(helix, 288).move(-288).as_scaffold() design.draw_strand(23, 288).move(-144).as_scaffold() # bottom part of scaffold has a "nick" design.draw_strand(23, 144).move(-144).as_scaffold() # def add_scaffold_crossovers(design: sc.Design) -> None: for helix in range(1, 23, 2): # scaffold interior crossovers design.add_full_crossover(helix=helix, helix2=helix + 1, offset=144, forward=False) for helix in range(0, 23, 2): # scaffold edges crossovers design.add_half_crossover(helix=helix, helix2=helix + 1, offset=0, forward=True) design.add_half_crossover(helix=helix, helix2=helix + 1, offset=287, forward=True) def add_staple_precursors(design: sc.Design) -> None: staples = [sc.Strand([sc.Domain(helix=helix, forward=helix % 2 == 1, start=0, end=288)]) # noqa for helix in range(24)] for staple in staples: design.add_strand(staple) def add_staple_crossovers(design: sc.Design) -> None: for helix in range(23): start_offset = 16 if helix % 2 == 0 else 32 for offset in range(start_offset, 288, 32): if offset != 144: # skip crossover near seam design.add_full_crossover(helix=helix, helix2=helix + 1, offset=offset, forward=helix % 2 == 1) def add_staple_nicks(design: sc.Design) -> None: for helix in range(24): start_offset = 24 if helix % 2 == 0 else 40 for offset in range(start_offset, 272, 32): design.add_nick(helix, offset, forward=helix % 2 == 1) def add_twist_correction_deletions(design: sc.Design) -> None: for helix in range(24): for offset in range(19, 286, 48): design.add_deletion(helix, offset) if __name__ == '__main__': main() ``` -------------------------------- ### Assign labels to domains or loopouts Source: https://github.com/uc-davis-molecular-computing/scadnano-python-package/blob/main/doc/index.md Use with_domain_label immediately after creating a domain or loopout to assign a descriptive label. ```Python design.draw_strand(0, 5)\ .to(8).with_domain_label('domain 1')\ .cross(1)\ .to(5).with_domain_label('domain 2')\ .loopout(2, 4).with_domain_label('domain 3')\ .to(10).with_domain_label('domain 4') ``` -------------------------------- ### Load and modify existing designs Source: https://context7.com/uc-davis-molecular-computing/scadnano-python-package/llms.txt Import designs from scadnano or cadnano v2 formats to inspect or modify components. ```python import scadnano as sc # Load from scadnano file design = sc.Design.from_scadnano_file('my_design.sc') # Load from cadnano v2 file design = sc.Design.from_cadnano_v2(directory='.', filename='cadnano_design.json') # Access design components print(f"Number of helices: {len(design.helices)}") print(f"Number of strands: {len(design.strands)}") print(f"Scaffold: {design.scaffold}") # Modify and save for strand in design.strands: if not strand.is_scaffold: print(f"Staple {strand.name}: {strand.dna_sequence}") design.write_scadnano_file(filename='modified_design.sc') ``` -------------------------------- ### Design Initialization from SCADnano JSON Map Source: https://github.com/uc-davis-molecular-computing/scadnano-python-package/blob/main/doc/index.md Loads a Design object from a JSON object (Python dictionary). ```APIDOC ## static from_scadnano_json_map(json_map) ### Description Loads a [Design](#scadnano.Design) from the given JSON object (i.e., Python object obtained by calling json.loads(json_str) from a string representing contents of a JSON file. ### Parameters #### Path Parameters - **json_map** (dict) - Required - map describing the [Design](#scadnano.Design); should be JSON serializable via `encode(json_map)` ### Returns [Design](#scadnano.Design) described in the object ### Return type [Design](#scadnano.Design) ``` -------------------------------- ### Annotate Python functions with type hints Source: https://github.com/uc-davis-molecular-computing/scadnano-python-package/blob/main/tutorial/tutorial.md Use type hints to declare input and return types for functions, improving code readability and static analysis. ```python def f(x, n): return len(x) / n ``` ```python def f(x: str, n: int) -> float: return len(x) / n ``` ```python def g(x: int) -> None: print(x*2) ``` -------------------------------- ### write_scadnano_file Source: https://github.com/uc-davis-molecular-computing/scadnano-python-package/blob/main/doc/index.md Exports the design to a scadnano file format. ```APIDOC ## write_scadnano_file ### Description Writes a text file representing the Design, suitable for reading by the scadnano web interface. ### Parameters #### Query Parameters - **filename** (str | None) - Optional - Filename (default: name of script with .py replaced by .sc). - **directory** (str) - Optional - Directory in which to put file (default: current working directory). - **extension** (str | None) - Optional - Extension for filename (default: .sc). - **warn_duplicate_strand_names** (bool) - Optional - If True, prints a warning to the screen indicating when strands are found to have duplicate names. - **suppress_indent** (bool) - Optional - Whether to suppress indenting JSON for small objects. ``` -------------------------------- ### StrandBuilder.with_domain_name Source: https://github.com/uc-davis-molecular-computing/scadnano-python-package/blob/main/doc/index.md Assigns a name to the most recently created Domain or Loopout. ```APIDOC ## StrandBuilder.with_domain_name(name) ### Description Assigns `name` as the name of the most recently created [`Domain`](#scadnano.Domain) or [`Loopout`](#scadnano.Loopout) in the [`Strand`](#scadnano.Strand) being built. This should be called immediately after a [`Domain`](#scadnano.Domain) is created. ### Method This is a method of the `StrandBuilder` object. ### Parameters #### Path Parameters - **name** (str) - Required - The name to assign to the most recently created [`Domain`](#scadnano.Domain) or [`Loopout`](#scadnano.Loopout). ### Response #### Success Response (200) - **self** (StrandBuilder) - Returns the `StrandBuilder` instance for chaining. ### Request Example ```python design.draw_strand(0, 0).to(10).with_domain_name('dom1*').cross(1).to(5).with_domain_name('dom1') ``` ### Response Example ```json { "example": "StrandBuilder instance" } ``` ``` -------------------------------- ### StrandBuilder.with_domain_label Source: https://github.com/uc-davis-molecular-computing/scadnano-python-package/blob/main/doc/index.md Assigns a label to the most recently created Domain or Loopout. ```APIDOC ## StrandBuilder.with_domain_label(label) ### Description Assigns `label` as the label of the most recently created [`Domain`](#scadnano.Domain) or [`Loopout`](#scadnano.Loopout) in the [`Strand`](#scadnano.Strand) being built. This should be called immediately after a [`Domain`](#scadnano.Domain) or [`Loopout`](#scadnano.Loopout) is created. ### Method This is a method of the `StrandBuilder` object. ### Parameters #### Path Parameters - **label** (str) - Required - The label to assign to the [`Domain`](#scadnano.Domain) or [`Loopout`](#scadnano.Loopout). ### Response #### Success Response (200) - **self** (StrandBuilder) - Returns the `StrandBuilder` instance for chaining. ### Request Example ```python design.draw_strand(0, 5) .to(8).with_domain_label('domain 1') .cross(1) .to(5).with_domain_label('domain 2') .loopout(2, 4).with_domain_label('domain 3') .to(10).with_domain_label('domain 4') ``` ### Response Example ```json { "example": "StrandBuilder instance" } ``` ``` -------------------------------- ### Strand Configuration Methods Source: https://github.com/uc-davis-molecular-computing/scadnano-python-package/blob/main/doc/index.md Methods for configuring properties of a Strand object, such as scaffold status and vendor-specific export details. ```APIDOC ## set_scaffold(is_scaf=True) ### Description Sets the current Strand as a scaffold. If is_scaf is True, it alters the color to the default scaffold color. If False, it sets the strand as not a scaffold and preserves the current color. ### Parameters #### Request Body - **is_scaf** (bool) - Optional - Whether to set the strand as a scaffold (default: True). ### Response - **Return type** (None) ``` ```APIDOC ## vendor_dna_sequence(domain_delimiter='') ### Description Generates the DNA sequence formatted for ordering from a DNA synthesis vendor, including modifications. ### Parameters #### Request Body - **domain_delimiter** (str) - Optional - String to insert between DNA sequences of each domain and between modifications and DNA. ### Response - **Return type** (str) - The formatted DNA sequence string. ``` ```APIDOC ## vendor_export_name(unique_names=False) ### Description Returns the name of the strand for vendor export, optionally enforcing unique names. ### Parameters #### Request Body - **unique_names** (bool) - Optional - If True, enforces unique names by encoding forward/reverse status. ### Response - **Return type** (str) - The export name of the strand. ``` -------------------------------- ### Inspect scadnano design file output Source: https://github.com/uc-davis-molecular-computing/scadnano-python-package/blob/main/tutorial/tutorial.md The resulting JSON structure of the generated .sc file showing the grid configuration and helix positions. ```json { "version": "0.14.0", "grid": "square", "helices": [ {"max_offset": 288, "grid_position": [0, 0]}, {"max_offset": 288, "grid_position": [0, 1]}, {"max_offset": 288, "grid_position": [0, 2]}, {"max_offset": 288, "grid_position": [0, 3]}, {"max_offset": 288, "grid_position": [0, 4]}, {"max_offset": 288, "grid_position": [0, 5]}, {"max_offset": 288, "grid_position": [0, 6]}, {"max_offset": 288, "grid_position": [0, 7]}, {"max_offset": 288, "grid_position": [0, 8]}, {"max_offset": 288, "grid_position": [0, 9]}, {"max_offset": 288, "grid_position": [0, 10]}, {"max_offset": 288, "grid_position": [0, 11]}, {"max_offset": 288, "grid_position": [0, 12]}, {"max_offset": 288, "grid_position": [0, 13]}, {"max_offset": 288, "grid_position": [0, 14]}, {"max_offset": 288, "grid_position": [0, 15]}, {"max_offset": 288, "grid_position": [0, 16]}, {"max_offset": 288, "grid_position": [0, 17]}, {"max_offset": 288, "grid_position": [0, 18]}, {"max_offset": 288, "grid_position": [0, 19]}, {"max_offset": 288, "grid_position": [0, 20]}, {"max_offset": 288, "grid_position": [0, 21]}, {"max_offset": 288, "grid_position": [0, 22]}, {"max_offset": 288, "grid_position": [0, 23]} ], "strands": [] } ``` -------------------------------- ### to_oxview_format Source: https://github.com/uc-davis-molecular-computing/scadnano-python-package/blob/main/doc/index.md Exports the design to oxView text format. ```APIDOC ## to_oxview_format ### Description Exports the design to the oxView text format. ### Parameters #### Query Parameters - **warn_duplicate_strand_names** (bool) - Optional - If True, prints a warning for duplicate strand names. - **use_strand_colors** (bool) - Optional - If True, applies strand colors to nucleotides. ### Response - **Return type** (str) - The oxView formatted string. ``` -------------------------------- ### Create DNA Design with Chained Methods Source: https://github.com/uc-davis-molecular-computing/scadnano-python-package/blob/main/README.md Use this abbreviated syntax with chained method calls for a more concise way to draw strands. This method is useful for quickly defining strands without explicitly creating domain objects. ```python def create_design() -> sc.Design: # helices helices = [sc.Helix(max_offset=48), sc.Helix(max_offset=48)] # whole design design = sc.Design(helices=helices, grid=sc.square) # for absolute offsets, call method "to" # left staple design.draw_strand(1, 8).to(24).cross(0).to(8) # for relative offsets, call method "move" # right staple design.draw_strand(0, 40).move(-16).cross(1).move(16).with_modification_5p(mod.biotin_5p) # scaffold design.draw_strand(1, 24).move(-16).cross(0).move(32).loopout(1, 3).move(-16).as_scaffold() # deletions and insertions added to design are added to both strands on a helix design.add_deletion(helix=1, offset=20) design.add_insertion(helix=0, offset=14, length=1) design.add_insertion(helix=0, offset=26, length=2) # also assigns complement to strands other than scaf bound to it design.assign_dna(design.scaffold, 'AACGT' * 18) return design ``` -------------------------------- ### Build Strands conditionally in a loop Source: https://github.com/uc-davis-molecular-computing/scadnano-python-package/blob/main/doc/index.md Illustrates using StrandBuilder within a loop to apply modifications or properties based on iteration logic. ```python for i in range(n): sb = design.draw_strand(0, 10).move(10).with_name(f'strand {i}') if i == 0: sb.with_modification_5p(mod.biotin_5p) ``` -------------------------------- ### POST draw_strand Source: https://github.com/uc-davis-molecular-computing/scadnano-python-package/blob/main/doc/index.md Initiates the creation of a strand using a builder pattern. ```APIDOC ## POST draw_strand ### Description Used for chained method building of a Strand domain by domain, starting from a specific helix and offset. ### Parameters #### Request Body - **helix** (int) - Required - The starting helix index. - **offset** (int) - Required - The starting offset on the helix. ### Response #### Success Response (200) - **builder** (StrandBuilder) - A StrandBuilder object representing the partially completed strand. ```