|
54 | 54 | # needed to use forward annotations: https://docs.python.org/3/whatsnew/3.7.html#whatsnew37-pep563 |
55 | 55 | from __future__ import annotations |
56 | 56 |
|
57 | | -__version__ = "0.19.3" # version line; WARNING: do not remove or change this line or comment |
| 57 | +__version__ = "0.19.4" # version line; WARNING: do not remove or change this line or comment |
58 | 58 |
|
59 | 59 | import collections |
60 | 60 | import dataclasses |
@@ -7755,17 +7755,57 @@ def _write_plates_default(self, directory: str, filename: Optional[str], strands |
7755 | 7755 |
|
7756 | 7756 | workbook.save(filename_plate) |
7757 | 7757 |
|
| 7758 | + def write_oxview_file(self, directory: str = '.', filename: Optional[str] = None, |
| 7759 | + warn_duplicate_strand_names: bool = True, use_strand_colors: bool = True) -> None: |
| 7760 | + """Writes an oxView file rerpesenting this design. |
| 7761 | +
|
| 7762 | + :param directory: |
| 7763 | + directy in which to write the file (default: current working directory) |
| 7764 | + :param filename: |
| 7765 | + name of the file to write (default: name of the running script with .oxview extension) |
| 7766 | + :param warn_duplicate_strand_names: |
| 7767 | + if True, prints a warning to the screen indicating when strands are found to |
| 7768 | + have duplicate names. (default: True) |
| 7769 | + :param use_strand_colors: |
| 7770 | + if True (default), sets the color of each nucleotide in a strand in oxView to the color |
| 7771 | + of the strand. |
| 7772 | + """ |
| 7773 | + text = self.to_oxview_format(warn_duplicate_strand_names=warn_duplicate_strand_names, |
| 7774 | + use_strand_colors=use_strand_colors) |
| 7775 | + write_file_same_name_as_running_python_script(text, 'oxview', directory, filename) |
| 7776 | + |
7758 | 7777 | def to_oxview_format(self, warn_duplicate_strand_names: bool = True, |
7759 | | - use_strand_colors: bool = True) -> dict: |
| 7778 | + use_strand_colors: bool = True) -> str: |
| 7779 | + """ |
| 7780 | + Exports to oxView format: https://github.com/sulcgroup/oxdna-viewer/blob/master/file-format.md |
| 7781 | +
|
| 7782 | + :param warn_duplicate_strand_names: |
| 7783 | + if True, prints a warning to the screen indicating when strands are found to |
| 7784 | + have duplicate names. (default: True) |
| 7785 | + :param use_strand_colors: |
| 7786 | + if True (default), sets the color of each nucleotide in a strand in oxView to the color |
| 7787 | + of the strand. |
| 7788 | + :return: |
| 7789 | + string in oxView text format |
7760 | 7790 | """ |
7761 | | - Exports to oxView format. |
| 7791 | + oxvsystem = self.to_oxview_json(warn_duplicate_strand_names=warn_duplicate_strand_names, |
| 7792 | + use_strand_colors=use_strand_colors) |
| 7793 | + text = json.dumps(oxvsystem) |
| 7794 | + return text |
| 7795 | + |
| 7796 | + def to_oxview_json(self, warn_duplicate_strand_names: bool = True, |
| 7797 | + use_strand_colors: bool = True) -> dict: |
| 7798 | + """ |
| 7799 | + Exports to oxView format: https://github.com/sulcgroup/oxdna-viewer/blob/master/file-format.md |
7762 | 7800 |
|
7763 | 7801 | :param warn_duplicate_strand_names: |
7764 | 7802 | if True, prints a warning to the screen indicating when strands are found to |
7765 | 7803 | have duplicate names. (default: True) |
7766 | 7804 | :param use_strand_colors: |
7767 | 7805 | if True (default), sets the color of each nucleotide in a strand in oxView to the color |
7768 | 7806 | of the strand. |
| 7807 | + :return: |
| 7808 | + Python dict |
7769 | 7809 | """ |
7770 | 7810 | import datetime |
7771 | 7811 | self._check_legal_design(warn_duplicate_strand_names) |
@@ -7859,25 +7899,6 @@ def to_oxview_format(self, warn_duplicate_strand_names: bool = True, |
7859 | 7899 |
|
7860 | 7900 | return oxvsystem |
7861 | 7901 |
|
7862 | | - def write_oxview_file(self, directory: str = '.', filename: Optional[str] = None, |
7863 | | - warn_duplicate_strand_names: bool = True, use_strand_colors: bool = True) -> None: |
7864 | | - """Writes an oxView file rerpesenting this design. |
7865 | | -
|
7866 | | - :param directory: |
7867 | | - directy in which to write the file (default: current working directory) |
7868 | | - :param filename: |
7869 | | - name of the file to write (default: name of the running script with .oxview extension) |
7870 | | - :param warn_duplicate_strand_names: |
7871 | | - if True, prints a warning to the screen indicating when strands are found to |
7872 | | - have duplicate names. (default: True) |
7873 | | - :param use_strand_colors: |
7874 | | - if True (default), sets the color of each nucleotide in a strand in oxView to the color |
7875 | | - of the strand. |
7876 | | - """ |
7877 | | - oxvsystem = self.to_oxview_format(warn_duplicate_strand_names=warn_duplicate_strand_names, |
7878 | | - use_strand_colors=use_strand_colors) |
7879 | | - write_file_same_name_as_running_python_script(json.dumps(oxvsystem), 'oxview', directory, filename) |
7880 | | - |
7881 | 7902 | def to_oxdna_format(self, warn_duplicate_strand_names: bool = True) -> Tuple[str, str]: |
7882 | 7903 | """Exports to oxdna format. |
7883 | 7904 |
|
|
0 commit comments