Search documentation
Search the Foldnano user guide, plugin docs and contributor docs

Parse API Reference

parse_foldnano_json() turns the JSON string from ctx.get_part_as_foldnano_json() into read-only Python objects, so you can walk the design instead of indexing raw dicts. These names come from the foldnano package (which package to import). It is the reading half of the foldnano_json format: to change the design, edit part._raw and hand it back with ctx.set_result_foldnano_json(json.dumps(part._raw)) (see the round-trip pattern). For an API you edit directly, use foldnano.edit.

from foldnano import parse_foldnano_json

part = parse_foldnano_json(ctx.get_part_as_foldnano_json(), active_region_id=ctx.active_region_id)

Kind says what each name does:

  • read-only: a value parsed from the JSON. Assigning to it changes only the Python object, never the result; edit part._raw instead.
  • query: a method that only reads.
  • function, class: module-level names.

The proxies are snapshots of the JSON at parse time. Bases (bp) are 0-based indices along a helix; strand 0 runs 5' to 3' with increasing index, strand 1 with decreasing index.

Module

APIKindBehaviour
parse_foldnano_json(json_str, active_region_id=None)functionParse a Foldnano JSON string into a PartData. Pass ctx.active_region_id through for region-scoped plugins.
parse_cadnano_json(json_str)functionParse a cadnano JSON string into a plain dict (name, vstrands). cadnano designs have no proxies.
PartDataclassThe parsed part (below).
OligoProxy, OligoSegmentProxyclassAn oligo and one of its segments.
VirtualHelixProxyclassA helix.
RegionProxy, LatticedRegionProxy, FreeformRegionProxy, WireframeRegionProxyclassA region; lattice and freeform regions are subclasses, and a WireframeRegionProxy is a FreeformRegionProxy. Test region.supports_lattice_grid rather than the class.
PlaneProxyclassThe plane a region lives on.
ReferenceGeometry, ReferenceMeshclassThe geometry a wireframe region was built from.
BACKBONE_RISE_NMconstantThe rise along a helix axis, in nm per bp, that Foldnano draws and exports helices with (about 0.332).

All of these import from foldnano.

PartData

APIKindBehaviour
part.name, part.idread‑onlyThe part's name and id.
part.virtual_helices, part.oligos, part.regions, part.planesread‑onlyEverything in the part, in JSON order.
part.lattice_typeread‑onlyDeprecated, and logs a warning. The first region's kind only. Use region.kind.
part.max_baseread‑onlyDeprecated, and logs a warning. The first region's length only. Use region.max_base.
part.active_region_id, part.active_regionread‑onlyThe region passed to parse_foldnano_json (id, and its proxy or None).
part._rawread‑onlyThe parsed JSON dict itself. Change it and serialise it back to return an edited design.
part.get_vh(index), part.get_oligo(id), part.get_region(id), part.get_plane(id)queryThe proxy with that index or id, or None.
part.region_for_vh(vh_index)queryThe region a helix belongs to, or None.
part.vhs_in_region(region_id)queryHelices in a region.
part.oligos_in_region(region_id)queryOligos whose segments all lie in that region (oligos crossing into another region are left out).

OligoProxy

APIKindBehaviour
oligo.id, oligo.nameread‑onlyId, and the name (or None).
oligo.colorread‑onlyHex color, e.g. '#0066cc'.
oligo.is_scaffold, oligo.is_sequence_lockedread‑onlyWhether it is a scaffold, and whether its sequence is locked against overwriting.
oligo.segmentsread‑onlyIts segments, 5' to 3'.
oligo.sequenceread‑onlyThe bases of all segments, 5' to 3'; empty where none are assigned.
oligo.is_circularread‑onlyTrue when the last segment's 3' end joins the first one's 5' end.
oligo.touches_regions(part)queryThe ids of the regions its segments visit. More than one means it crosses regions.

OligoSegmentProxy

APIKindBehaviour
seg.idread‑onlyThe segment's id.
seg.vh_indexread‑onlyThe helix it lies on.
seg.five_prime_index, seg.three_prime_indexread‑onlyIts 5' and 3' bases on that helix.
seg.lengthread‑onlyBases spanned, both ends included.
seg.five_prime_modification, seg.three_prime_modificationread‑onlyModification codes (e.g. '/5Alex488N/'), or None.
seg.connected_from_segment_id, seg.connected_to_segment_idread‑onlyThe segment joined to its 5' end and to its 3' end, or None at a free end.
seg.is_free_five_prime, seg.is_free_three_primeread‑onlyWhether its 5' / 3' end is free (the oligo's own end).
seg.slotsread‑onlyOne dict per base, 5' to 3': {"bpIndex": int, "seq": str}. seq is empty for a skip and longer than one base for an insertion.
seg.sequenceread‑onlyIts bases, 5' to 3'.

VirtualHelixProxy

APIKindBehaviour
vh.index, vh.idread‑onlyIts index in the part, and its stable id (regions list helices by id).
vh.region_idread‑onlyThe region it belongs to.
vh.lengthread‑onlyBases along the helix.
vh.row, vh.colread‑onlyLattice position, or None for a freeform helix.
vh.is_freeformread‑onlyTrue when it has no lattice position.
vh.parity_is_evenread‑onlyTrue when row % 2 == col % 2. Raises ValueError on a freeform helix.
vh.local_frameread‑onlyA freeform helix's placement (origin, axis, radial0), or None.
vh.roll_degread‑onlyA freeform helix's rotation about its own axis, in degrees (-180 to 180], or None. 0 points radial0 along the region plane's normal; positive turns right-handed about the axis.
vh.list_rowread‑onlyIts row in the strand view, or None.
vh.strand_set_segment_idsread‑only[strand 0 ids, strand 1 ids]: the segments on each strand.

RegionProxy

APIKindBehaviour
region.id, region.name, region.kind, region.plane_idread‑onlyIdentity, name, 'HONEYCOMB' / 'SQUARE' / 'FREEFORM' / 'WIREFRAME', and its plane.
region.vh_orderread‑onlyIts helices' ids in display order (ids, not indices; use part.vhs_in_region for helices).
region.step, region.turns_per_step, region.sub_step_size, region.twist_offsetread‑onlyHelical geometry: bases per step (21 honeycomb, 32 square), turns per step, crossover sub-step, and twist offset.
region.min_base, region.default_max_baseread‑onlyIts first base, and the default length of new helices.
region.max_baseread‑onlyThe length of every helix in the region.
region.supports_lattice_gridread‑onlyTrue for honeycomb and square regions.
region.reference_geometryread‑onlyWireframe regions only: the ReferenceGeometry it was built from, or None.
geometry.mesh, geometry.unitread‑onlyIts ReferenceMesh or None, and the unit, always 'nm'.
mesh.vertices, mesh.faces, mesh.edgesread‑only(x, y, z) positions in nm in the region's frame, faces of three or more vertex indices, and (a, b) vertex pairs.
mesh.all_edges()queryEvery distinct edge as a sorted (a, b) pair: mesh.edges plus the sides of mesh.faces.
mesh.to_ply()queryThe mesh as ASCII PLY text.

PlaneProxy

APIKindBehaviour
plane.id, plane.nameread‑onlyIdentity and name.
plane.origin, plane.u, plane.v, plane.normalread‑onlyIts origin and basis vectors in the lab frame, each with .x, .y, .z. u and v span the plane.