diff --git a/scadnano/scadnano.py b/scadnano/scadnano.py index 72eef28e..6b6859d1 100644 --- a/scadnano/scadnano.py +++ b/scadnano/scadnano.py @@ -4702,7 +4702,8 @@ def __init__(self, *, strands: List[Strand] = None, grid: Grid = Grid.none, helices_view_order: List[int] = None, - geometry: Geometry = None) -> None: + geometry: Geometry = None, + warn_duplicate_strand_names: bool = True) -> None: """ :param helices: List of :any:`Helix`'s; if missing, set based on `strands`. @@ -4784,9 +4785,9 @@ def __init__(self, *, helices_in_group = [self.helices[idx] for idx in helix_idxs_in_group] _check_helices_grid_legal(group.grid, helices_in_group) - self.__post_init__() + self.__post_init__(warn_duplicate_strand_names=warn_duplicate_strand_names) - def __post_init__(self) -> None: + def __post_init__(self, warn_duplicate_strand_names: bool = True) -> None: # XXX: exact order of these calls is important self._ensure_helices_distinct_objects() self._ensure_strands_distinct_objects() @@ -4795,7 +4796,7 @@ def __post_init__(self) -> None: self._set_helices_min_max_offsets(update=False) self._ensure_helix_groups_exist() self._assign_default_helices_view_orders_to_groups() - self._check_legal_design() + self._check_legal_design(warn_duplicate_strand_names=warn_duplicate_strand_names) if self.automatically_assign_color: self._assign_colors_to_strands() @@ -4882,7 +4883,7 @@ def roll_of_helix(self, helix: Helix) -> float: return self.groups[helix.group].roll + helix.roll @staticmethod - def from_scadnano_file(filename: str) -> 'Design': # remove quotes when Py3.6 support dropped + def from_scadnano_file(filename: str, warn_duplicate_strand_names: bool = True) -> 'Design': # remove quotes when Py3.6 support dropped """ Loads a :any:`Design` from the file with the given name. @@ -4891,10 +4892,10 @@ def from_scadnano_file(filename: str) -> 'Design': # remove quotes when Py3.6 s """ with open(filename) as f: json_str = f.read() - return Design.from_scadnano_json_str(json_str) + return Design.from_scadnano_json_str(json_str, warn_duplicate_strand_names=warn_duplicate_strand_names) @staticmethod - def from_scadnano_json_str(json_str: str) -> 'Design': # remove quotes when Py3.6 support dropped + def from_scadnano_json_str(json_str: str, warn_duplicate_strand_names: bool = True) -> 'Design': # remove quotes when Py3.6 support dropped """ Loads a :any:`Design` from the given JSON string. @@ -4903,7 +4904,7 @@ def from_scadnano_json_str(json_str: str) -> 'Design': # remove quotes when Py3 """ json_map = json.loads(json_str) try: - design = Design.from_scadnano_json_map(json_map) + design = Design.from_scadnano_json_map(json_map, warn_duplicate_strand_names=warn_duplicate_strand_names) return design except KeyError as e: raise IllegalDesignError(f'I was expecting a JSON key but did not find it: {e}') @@ -5096,7 +5097,7 @@ def _helices_and_groups_and_grid_from_json(json_map: Dict) -> Tuple[List[Helix], @staticmethod def from_scadnano_json_map( - json_map: dict) -> 'Design': # remove quotes when Py3.6 support dropped + json_map: dict, warn_duplicate_strand_names: bool = True) -> 'Design': # remove quotes when Py3.6 support dropped """ Loads a :any:`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. @@ -5152,6 +5153,7 @@ def from_scadnano_json_map( grid=grid, helices_view_order=helices_view_order, geometry=geometry, + warn_duplicate_strand_names=warn_duplicate_strand_names, ) def to_json_serializable(self, suppress_indent: bool = True, **kwargs: Any) -> Dict[str, Any]: