def encodePart(part: PartT) -> dict: """ Args: part (Part): Returns: dict: """ # iterate through virtualhelix list group_props = part.getModelProperties().copy() if not group_props.get('is_lattice', True): vh_props, origins, directions = part.helixProperties() group_props['virtual_helices'] = vh_props group_props['origins'] = origins group_props['directions'] = directions else: vh_props, origins, directions = part.helixProperties() group_props['virtual_helices'] = vh_props group_props['origins'] = origins group_props['directions'] = directions # print("ORIGINS") # print(group_props['origins']) # print("DIRECTIONS") # print(group_props['directions']) xover_list = [] strand_list = [] prop_list = [] vh_list = [] for id_num in part.getidNums(): offset_and_size = part.getOffsetAndSize(id_num) if offset_and_size is None: # add a placeholder strand_list.append(None) prop_list.append(None) else: offset, size = offset_and_size vh_list.append((id_num, size)) fwd_ss, rev_ss = part.getStrandSets(id_num) fwd_idxs, fwd_colors = fwd_ss.dump(xover_list) rev_idxs, rev_colors = rev_ss.dump(xover_list) strand_list.append((fwd_idxs, rev_idxs)) prop_list.append((fwd_colors, rev_colors)) # end for group_props['vh_list'] = vh_list group_props['strands'] = {'indices': strand_list, 'properties': prop_list } group_props['insertions'] = list(part.dumpInsertions()) group_props['xovers'] = xover_list group_props['oligos'] = [o.dump() for o in part.oligos()] instance_props = list(part.instanceProperties()) group_props['instance_properties'] = instance_props group_props['uuid'] = part.uuid return group_props
def __init__(self, part: PartT, part_instance: ObjectInstanceT, view_name: str, key: str, val: Any): super(ChangeInstancePropertyCommand, self).__init__("change instance property") self.part = part self.part_instance = part_instance self.view_name = view_name self.flat_key = flat_key = '%s:%s' % (view_name, key) self.keyval = (key, val) self.old_keyval = (key, part.getInstanceProperty(part_instance, flat_key))
def encodePart(part: PartT) -> dict: """ Args: part (Part): Returns: dict: """ # iterate through virtualhelix list group_props = part.getModelProperties().copy() if group_props.get('point_type') == PointEnum.ARBITRARY: # TODO add code to encode Parts with ARBITRARY point configurations pass else: vh_props, origins = part.helixPropertiesAndOrigins() group_props['virtual_helices'] = vh_props group_props['origins'] = origins xover_list = [] strand_list = [] prop_list = [] vh_list = [] for id_num in part.getidNums(): offset_and_size = part.getOffsetAndSize(id_num) if offset_and_size is None: # add a placeholder strand_list.append(None) prop_list.append(None) else: offset, size = offset_and_size vh_list.append((id_num, size)) fwd_ss, rev_ss = part.getStrandSets(id_num) fwd_idxs, fwd_colors = fwd_ss.dump(xover_list) rev_idxs, rev_colors = rev_ss.dump(xover_list) strand_list.append((fwd_idxs, rev_idxs)) prop_list.append((fwd_colors, rev_colors)) # end for group_props['vh_list'] = vh_list group_props['strands'] = {'indices': strand_list, 'properties': prop_list } group_props['insertions'] = list(part.dumpInsertions()) group_props['xovers'] = xover_list group_props['oligos'] = [o.dump() for o in part.oligos()] instance_props = list(part.instanceProperties()) group_props['instance_properties'] = instance_props group_props['uuid'] = part.uuid return group_props
def reEmitPart(part: PartT): """ Args: part (Part): """ # iterate through virtualhelix list group_props = part.getModelProperties().copy() if not group_props.get('is_lattice', True): # TODO add code to encode Parts with ARBITRARY point configurations pass else: vh_props, origins = part.helixPropertiesAndOrigins() group_props['virtual_helices'] = vh_props group_props['origins'] = origins xover_list = [] threshold = 2.1 * part.radius() for id_num in part.getidNums(): offset_and_size = part.getOffsetAndSize(id_num) if offset_and_size is not None: offset, size = offset_and_size vh = part.getVirtualHelix(id_num) neighbors = part._getVirtualHelixOriginNeighbors(id_num, threshold) part.partVirtualHelixAddedSignal.emit(part, id_num, vh, neighbors) fwd_ss, rev_ss = part.getStrandSets(id_num) for strand in fwd_ss.strands(): fwd_ss.strandsetStrandAddedSignal.emit(fwd_ss, strand) for strand in rev_ss.strands(): fwd_ss.strandsetStrandAddedSignal.emit(rev_ss, strand) part.partStrandChangedSignal.emit(part, id_num) fwd_idxs, fwd_colors = fwd_ss.dump(xover_list) rev_idxs, rev_colors = rev_ss.dump(xover_list) # end for for from_id, from_is_fwd, from_idx, to_id, to_is_fwd, to_idx in xover_list: strand5p = from_strand = part.getStrand(from_is_fwd, from_id, from_idx) strand3p = to_strand = part.getStrand(to_is_fwd, to_id, to_idx) strand5p.strandConnectionChangedSignal.emit(strand5p) strand3p.strandConnectionChangedSignal.emit(strand3p) # end for for id_num, id_dict in part.insertions().items(): for idx, insertion in id_dict.items(): fwd_strand = part.getStrand(True, id_num, idx) rev_strand = part.getStrand(False, id_num, idx) if fwd_strand: fwd_strand.strandInsertionAddedSignal.emit( fwd_strand, insertion) if rev_strand: rev_strand.strandInsertionAddedSignal.emit( rev_strand, insertion) # end for # instance_props = list(part.instanceProperties()) # emit instance properties return group_props
def __init__(self, part: PartT): super(RemovePartCommand, self).__init__("remove part") self._part = part self._instances = part.instances().copy() self._document = part.document()