diff --git a/.github/workflows/gh-ci-tests.yaml b/.github/workflows/gh-ci-tests.yaml index f1d443024..ab02e4dd0 100644 --- a/.github/workflows/gh-ci-tests.yaml +++ b/.github/workflows/gh-ci-tests.yaml @@ -43,7 +43,10 @@ jobs: micromamba info micromamba list + - name: "test snapshots" + working-directory: doc/source/scripts/ + run: python -m pytest + - name: "test notebooks" - run: | - cd ${GITHUB_WORKSPACE}/tests - pytest + working-directory: tests/ + run: python -m pytest diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a7457a5a6..279473110 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,14 +5,15 @@ repos: - id: check-yaml - id: end-of-file-fixer - id: trailing-whitespace - exclude: ^.*\.(pdb)$ + exclude: ^.*\.(pdb|ambr)$ - repo: https://github.com/pycqa/isort rev: 5.12.0 hooks: - id: isort name: isort (python) - args: ["--profile", "black"] + args: ["--profile", "black", "--line-length", "79"] - repo: https://github.com/psf/black rev: 22.3.0 hooks: - id: black + args: [--line-length=79] diff --git a/doc/source/conf.py b/doc/source/conf.py index 7f106f0bd..3b30a2e54 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -136,7 +136,9 @@ def sort_authors(filename): html_logo = "_static/logos/user_guide.png" -html_context = {"versions_json_url": "https://userguide.mdanalysis.org/versions.json"} +html_context = { + "versions_json_url": "https://userguide.mdanalysis.org/versions.json" +} # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, diff --git a/doc/source/preparing_releases_and_hotfixes.rst b/doc/source/preparing_releases_and_hotfixes.rst index b4b24f962..09bfd7a79 100644 --- a/doc/source/preparing_releases_and_hotfixes.rst +++ b/doc/source/preparing_releases_and_hotfixes.rst @@ -174,7 +174,15 @@ To do this you will need to: Create a release of the UserGuide --------------------------------- -For now, the UserGuide is released at the same time as the core library. To make a release of the UserGuide you should: +For now, the UserGuide is released at the same time as the core library. If it's failing please fix *before* you do the tag / release. Here is how to update the snapshots + +#. Update the version of MDA used by the UserGuide to the release version. + +#. Re-generate the Syrupy test snapshots, and commit those a to git and confirm the build passes. + + .. code-block:: bash + cd doc/source/scripts + python -m pytest tests/snapshot/ --snapshot-update #. Create a new release tag and upload them for the UserGuide repository. diff --git a/doc/source/scripts/base.py b/doc/source/scripts/base.py index 7964ab11e..d1da2a533 100644 --- a/doc/source/scripts/base.py +++ b/doc/source/scripts/base.py @@ -88,12 +88,16 @@ def write_table(self): @staticmethod def sphinx_class(klass, tilde=True): prefix = "~" if tilde else "" - return ":class:`{}{}.{}`".format(prefix, klass.__module__, klass.__name__) + return ":class:`{}{}.{}`".format( + prefix, klass.__module__, klass.__name__ + ) @staticmethod def sphinx_meth(meth, tilde=True): prefix = "~" if tilde else "" - return ":meth:`{}{}.{}`".format(prefix, meth.__module__, meth.__qualname__) + return ":meth:`{}{}.{}`".format( + prefix, meth.__module__, meth.__qualname__ + ) @staticmethod def sphinx_ref(txt: str, label: str = None, suffix: str = "") -> str: diff --git a/doc/source/scripts/clean_example_notebooks.py b/doc/source/scripts/clean_example_notebooks.py index d7a3f5d56..5a8fbcde2 100755 --- a/doc/source/scripts/clean_example_notebooks.py +++ b/doc/source/scripts/clean_example_notebooks.py @@ -116,9 +116,9 @@ class JupyterCell: time_fmt = "%b %d, %Y" tag = "a" close_tag = "".format(tag) - tagline = ('<{} data-cite="{{key}}" ' 'href="{{url}}">{{authors}}').format( - tag, tag - ) + tagline = ( + '<{} data-cite="{{key}}" ' 'href="{{url}}">{{authors}}' + ).format(tag, tag) @classmethod def as_references(cls, refs, keys=[]): @@ -171,7 +171,9 @@ def find_reference_keys(self, refs, keys=[]): Track the order of the keys for a final bibliography cell. """ - matches = [x for x in re.split(refs.regex, self.source) if x is not None] + matches = [ + x for x in re.split(refs.regex, self.source) if x is not None + ] new_source = "" while len(matches) > 1: @@ -191,7 +193,9 @@ def find_reference_keys(self, refs, keys=[]): elif prev_char in ('"', "'"): new_source += before.rsplit("<", maxsplit=1)[0] if len(matches) > 2: - matches[2] = matches[2].split(self.close_tag, maxsplit=1)[-1] + matches[2] = matches[2].split(self.close_tag, maxsplit=1)[ + -1 + ] tag = self.tagline.format(key=key, authors=authors, url=url) new_source += tag matches.pop(0) @@ -322,7 +326,9 @@ def clean_all_notebooks(notebooks): if len(errs): errmsgs = ["{}: {}".format(nb, err) for nb, err in errs] delim = "\n" + "===" * 10 + "\n" - raise ValueError("Notebooks have errors: {}".format(delim.join(errmsgs))) + raise ValueError( + "Notebooks have errors: {}".format(delim.join(errmsgs)) + ) if __name__ == "__main__": diff --git a/doc/source/scripts/core.py b/doc/source/scripts/core.py index 84c6d3073..59341d88e 100644 --- a/doc/source/scripts/core.py +++ b/doc/source/scripts/core.py @@ -75,7 +75,9 @@ for c in _TOPOLOGY_ATTRS.values() } -base_attrnames = set(["atomattrs", "residueattrs", "segmentattrs", "topologyattrs"]) +base_attrnames = set( + ["atomattrs", "residueattrs", "segmentattrs", "topologyattrs"] +) core_attrnames = set(["indices", "resindices", "segindices"]) @@ -83,9 +85,17 @@ NON_BASE_ATTRS = {k: v for k, v in ATTRS.items() if k not in base_attrnames} -NON_CORE_ATTRS = {k: v for k, v in NON_BASE_ATTRS.items() if k not in core_attrnames} +NON_CORE_ATTRS = { + k: v for k, v in NON_BASE_ATTRS.items() if k not in core_attrnames +} TOPOLOGY_CLS = sorted( - set([x for x in _TOPOLOGY_ATTRS.values() if x.attrname in NON_CORE_ATTRS.keys()]), + set( + [ + x + for x in _TOPOLOGY_ATTRS.values() + if x.attrname in NON_CORE_ATTRS.keys() + ] + ), key=lambda x: x.attrname, ) diff --git a/doc/source/scripts/gen_format_overview_classes.py b/doc/source/scripts/gen_format_overview_classes.py index 383483c2d..9c03d44e3 100644 --- a/doc/source/scripts/gen_format_overview_classes.py +++ b/doc/source/scripts/gen_format_overview_classes.py @@ -27,7 +27,7 @@ sorted_types = sorted(FILE_TYPES.items()) -SUCCESS = "\u2713" +SUCCESS = "\u2713" # checkmark FAIL = "" @@ -35,7 +35,14 @@ class FormatOverview(TableWriter): filename = "formats/format_overview.txt" include_table = "Table of all supported formats in MDAnalysis" preprocess = ["keys"] - headings = ["File type", "Description", "Topology", "Coordinates", "Read", "Write"] + headings = [ + "File type", + "Description", + "Topology", + "Coordinates", + "Read", + "Write", + ] def _set_up_input(self): return sorted_types @@ -80,7 +87,9 @@ def _write(self, fmt, handlers): class CoordinateReaders(FormatOverview): filename = "formats/coordinate_readers.txt" - include_table = "Table of supported coordinate readers and the information read" + include_table = ( + "Table of supported coordinate readers and the information read" + ) headings = ["File type", "Description", "Velocities", "Forces"] def _set_up_input(self): diff --git a/doc/source/scripts/gen_standard_selections.py b/doc/source/scripts/gen_standard_selections.py index 1498365b3..a9304fbc0 100755 --- a/doc/source/scripts/gen_standard_selections.py +++ b/doc/source/scripts/gen_standard_selections.py @@ -36,8 +36,14 @@ def get_lines(self, klass, attr, sort=False, n=8): if __name__ == "__main__": StandardSelectionTable("protein", sel.ProteinSelection, "prot_res", True) - StandardSelectionTable("protein_backbone", sel.BackboneSelection, "bb_atoms") + StandardSelectionTable( + "protein_backbone", sel.BackboneSelection, "bb_atoms" + ) StandardSelectionTable("nucleic", sel.NucleicSelection, "nucl_res") - StandardSelectionTable("nucleic_backbone", sel.NucleicBackboneSelection, "bb_atoms") + StandardSelectionTable( + "nucleic_backbone", sel.NucleicBackboneSelection, "bb_atoms" + ) StandardSelectionTable("base", sel.BaseSelection, "base_atoms") - StandardSelectionTable("nucleic_sugar", sel.NucleicSugarSelection, "sug_atoms") + StandardSelectionTable( + "nucleic_sugar", sel.NucleicSugarSelection, "sug_atoms" + ) diff --git a/doc/source/scripts/gen_topologyparser_attrs.py b/doc/source/scripts/gen_topologyparser_attrs.py index 340960a67..e648fb737 100755 --- a/doc/source/scripts/gen_topologyparser_attrs.py +++ b/doc/source/scripts/gen_topologyparser_attrs.py @@ -79,10 +79,17 @@ class TopologyParsers(TableWriter): - headings = ["Format", "Description", "Attributes read", "Attributes guessed"] + headings = [ + "Format", + "Description", + "Attributes read", + "Attributes guessed", + ] preprocess = ["keys"] filename = "formats/topology_parsers.txt" - include_table = "Table of supported topology parsers and the attributes read" + include_table = ( + "Table of supported topology parsers and the attributes read" + ) sort = True def __init__(self): @@ -133,7 +140,9 @@ def __init__(self, attrs): def _set_up_input(self): return sorted( - [x, *y] for x, y in NON_CORE_ATTRS.items() if x not in MANDATORY_ATTRS + [x, *y] + for x, y in NON_CORE_ATTRS.items() + if x not in MANDATORY_ATTRS ) def _atom(self, name, singular, *args): diff --git a/doc/source/scripts/gen_unit_tables.py b/doc/source/scripts/gen_unit_tables.py index 640a261ee..c18ab5f4e 100755 --- a/doc/source/scripts/gen_unit_tables.py +++ b/doc/source/scripts/gen_unit_tables.py @@ -32,11 +32,13 @@ def write_unit_table(filename): f.write("\n\n") f.write( textwrap.indent( - tabulate.tabulate(lines, headers=headings, tablefmt="rst"), " " + tabulate.tabulate(lines, headers=headings, tablefmt="rst"), + " ", ) ) f.write("\n") print("Wrote ", filename) + return tables if __name__ == "__main__": diff --git a/doc/source/scripts/tests/snapshot/__snapshots__/test_gen_format_overview_classes.ambr b/doc/source/scripts/tests/snapshot/__snapshots__/test_gen_format_overview_classes.ambr new file mode 100644 index 000000000..b180d63ed --- /dev/null +++ b/doc/source/scripts/tests/snapshot/__snapshots__/test_gen_format_overview_classes.ambr @@ -0,0 +1,677 @@ +# serializer version: 1 +# name: test_CoordinateReaders + list([ + list([ + ':ref:`ARC `', + 'Tinker file', + '', + '', + ]), + list([ + ':ref:`CHEMFILES `', + 'use readers from `chemfiles `_ library', + '', + '', + ]), + list([ + ':ref:`CONFIG `', + 'DL_Poly CONFIG file', + '✓', + '', + ]), + list([ + ':ref:`COOR `', + 'NAMD binary restart file', + '', + '', + ]), + list([ + ':ref:`CRD `', + 'CHARMM CARD file', + '', + '', + ]), + list([ + ':ref:`CRDBOX `', + 'AMBER ASCII trajectories', + '', + '', + ]), + list([ + ':ref:`DATA `', + 'LAMMPS data file', + '✓', + '', + ]), + list([ + ':ref:`DCD `', + 'CHARMM, NAMD, or LAMMPS binary trajectory', + '', + '', + ]), + list([ + ':ref:`DMS `', + 'DESRES Molecular Structure file', + '✓', + '', + ]), + list([ + ':ref:`ENT `', + 'Standard PDB file', + '', + '', + ]), + list([ + ':ref:`FHIAIMS `', + 'FHI-aims input file', + '✓', + '', + ]), + list([ + ':ref:`GMS `', + 'GAMESS file', + '', + '', + ]), + list([ + ':ref:`GRO `', + 'GROMACS structure file', + '✓', + '', + ]), + list([ + ':ref:`GSD `', + 'HOOMD GSD file', + '', + '', + ]), + list([ + ':ref:`H5MD `', + '`H5MD `_ trajectory format', + '', + '', + ]), + list([ + ':ref:`HISTORY `', + 'DL_Poly HISTORY file', + '✓', + '', + ]), + list([ + ':ref:`IN `', + 'FHI-aims input file', + '✓', + '', + ]), + list([ + ':ref:`INPCRD `', + 'AMBER restart file', + '', + '', + ]), + list([ + ':ref:`LAMMPS `', + 'a LAMMPS DCD trajectory', + '', + '', + ]), + list([ + ':ref:`LAMMPSDUMP `', + 'LAMMPS ascii dump file', + '', + '', + ]), + list([ + ':ref:`MDCRD `', + 'AMBER ASCII trajectories', + '', + '', + ]), + list([ + ':ref:`MMTF `', + 'MMTF file', + '', + '', + ]), + list([ + ':ref:`MOL2 `', + 'Tripos MOL2 file', + '', + '', + ]), + list([ + ':ref:`NAMDBIN `', + 'NAMD binary restart file', + '', + '', + ]), + list([ + ':ref:`NC `', + 'AMBER NETCDF format', + '✓', + '✓', + ]), + list([ + ':ref:`NCDF `', + 'AMBER NETCDF format', + '✓', + '✓', + ]), + list([ + ':ref:`OPENMMAPP `', + '`OpenMM `_ Application layer objects', + '', + '', + ]), + list([ + ':ref:`OPENMMSIMULATION `', + '`OpenMM `_ Simulation objects', + '✓', + '✓', + ]), + list([ + ':ref:`PARMED `', + '`ParmEd `_ Structure', + '', + '', + ]), + list([ + ':ref:`PDB `', + 'Standard PDB file', + '', + '', + ]), + list([ + ':ref:`PDBQT `', + 'PDBQT file', + '', + '', + ]), + list([ + ':ref:`PQR `', + 'PQR file', + '', + '', + ]), + list([ + ':ref:`RDKIT `', + '`RDKit `_ Molecule', + '', + '', + ]), + list([ + ':ref:`RESTRT `', + 'AMBER restart file', + '', + '', + ]), + list([ + ':ref:`TNG `', + 'Trajectory Next Generation file', + '✓', + '✓', + ]), + list([ + ':ref:`TRJ `', + 'AMBER ASCII trajectories', + '', + '', + ]), + list([ + ':ref:`TRR `', + 'GROMACS TRR trajectory', + '✓', + '✓', + ]), + list([ + ':ref:`TRZ `', + 'IBIsCO or YASP binary trajectory', + '✓', + '', + ]), + list([ + ':ref:`TXYZ `', + 'Tinker file', + '', + '', + ]), + list([ + ':ref:`XPDB `', + 'Extended PDB file', + '', + '', + ]), + list([ + ':ref:`XTC `', + 'GROMACS compressed trajectory', + '', + '', + ]), + list([ + ':ref:`XYZ `', + 'XYZ file', + '', + '', + ]), + ]) +# --- +# name: test_FormatOverview + list([ + list([ + ':ref:`ARC `', + 'Tinker file', + '✓', + '✓', + '✓', + '', + ]), + list([ + ':ref:`CHEMFILES `', + 'use readers from `chemfiles `_ library', + '', + '✓', + '✓', + '✓', + ]), + list([ + ':ref:`CONFIG `', + 'DL_Poly CONFIG file', + '✓', + '✓', + '✓', + '', + ]), + list([ + ':ref:`COOR `', + 'NAMD binary restart file', + '', + '✓', + '✓', + '✓', + ]), + list([ + ':ref:`CRD `', + 'CHARMM CARD file', + '✓', + '✓', + '✓', + '✓', + ]), + list([ + ':ref:`CRDBOX `', + 'AMBER ASCII trajectories', + '', + '✓', + '✓', + '', + ]), + list([ + ':ref:`DATA `', + 'LAMMPS data file', + '✓', + '✓', + '✓', + '✓', + ]), + list([ + ':ref:`DCD `', + 'CHARMM, NAMD, or LAMMPS binary trajectory', + '', + '✓', + '✓', + '✓', + ]), + list([ + ':ref:`DMS `', + 'DESRES Molecular Structure file', + '✓', + '✓', + '✓', + '', + ]), + list([ + ':ref:`ENT `', + 'Standard PDB file', + '✓', + '✓', + '✓', + '✓', + ]), + list([ + ':ref:`FHIAIMS `', + 'FHI-aims input file', + '✓', + '✓', + '✓', + '✓', + ]), + list([ + ':ref:`GMS `', + 'GAMESS file', + '✓', + '✓', + '✓', + '', + ]), + list([ + ':ref:`GRO `', + 'GROMACS structure file', + '✓', + '✓', + '✓', + '✓', + ]), + list([ + ':ref:`GSD `', + 'HOOMD GSD file', + '✓', + '✓', + '✓', + '', + ]), + list([ + ':ref:`H5MD `', + '`H5MD `_ trajectory format', + '', + '✓', + '✓', + '✓', + ]), + list([ + ':ref:`HISTORY `', + 'DL_Poly HISTORY file', + '✓', + '✓', + '✓', + '', + ]), + list([ + ':ref:`IN `', + 'FHI-aims input file', + '✓', + '✓', + '✓', + '✓', + ]), + list([ + ':ref:`INPCRD `', + 'AMBER restart file', + '', + '✓', + '✓', + '', + ]), + list([ + ':ref:`ITP `', + 'GROMACS portable topology file', + '✓', + '', + '✓', + '', + ]), + list([ + ':ref:`LAMMPS `', + 'a LAMMPS DCD trajectory', + '', + '✓', + '✓', + '✓', + ]), + list([ + ':ref:`LAMMPSDUMP `', + 'LAMMPS ascii dump file', + '✓', + '✓', + '✓', + '', + ]), + list([ + ':ref:`MDCRD `', + 'AMBER ASCII trajectories', + '', + '✓', + '✓', + '', + ]), + list([ + ':ref:`MMTF `', + 'MMTF file', + '✓', + '✓', + '✓', + '', + ]), + list([ + ':ref:`MOL2 `', + 'Tripos MOL2 file', + '✓', + '✓', + '✓', + '✓', + ]), + list([ + ':ref:`NAMDBIN `', + 'NAMD binary restart file', + '', + '✓', + '✓', + '✓', + ]), + list([ + ':ref:`NC `', + 'AMBER NETCDF format', + '', + '✓', + '✓', + '✓', + ]), + list([ + ':ref:`NCDF `', + 'AMBER NETCDF format', + '', + '✓', + '✓', + '✓', + ]), + list([ + ':ref:`OPENMMAPP `', + '`OpenMM `_ Application layer objects', + '✓', + '✓', + '✓', + '', + ]), + list([ + ':ref:`OPENMMSIMULATION `', + '`OpenMM `_ Simulation objects', + '', + '✓', + '✓', + '', + ]), + list([ + ':ref:`OPENMMTOPOLOGY `', + '`OpenMM `_ Topology object', + '✓', + '', + '✓', + '', + ]), + list([ + ':ref:`PARM7 `', + 'AMBER topology file', + '✓', + '', + '✓', + '', + ]), + list([ + ':ref:`PARMED `', + '`ParmEd `_ Structure', + '✓', + '✓', + '✓', + '✓', + ]), + list([ + ':ref:`PDB `', + 'Standard PDB file', + '✓', + '✓', + '✓', + '✓', + ]), + list([ + ':ref:`PDBQT `', + 'PDBQT file', + '✓', + '✓', + '✓', + '✓', + ]), + list([ + ':ref:`PQR `', + 'PQR file', + '✓', + '✓', + '✓', + '✓', + ]), + list([ + ':ref:`PRMTOP `', + 'AMBER topology file', + '✓', + '', + '✓', + '', + ]), + list([ + ':ref:`PSF `', + 'CHARMM, NAMD, or XPLOR PSF file', + '✓', + '', + '✓', + '', + ]), + list([ + ':ref:`RDKIT `', + '`RDKit `_ Molecule', + '✓', + '✓', + '✓', + '✓', + ]), + list([ + ':ref:`RESTRT `', + 'AMBER restart file', + '', + '✓', + '✓', + '', + ]), + list([ + ':ref:`TNG `', + 'Trajectory Next Generation file', + '', + '✓', + '✓', + '', + ]), + list([ + ':ref:`TOP `', + 'AMBER topology file', + '✓', + '', + '✓', + '', + ]), + list([ + ':ref:`TPR `', + 'GROMACS run topology file', + '✓', + '', + '✓', + '', + ]), + list([ + ':ref:`TRJ `', + 'AMBER ASCII trajectories', + '', + '✓', + '✓', + '', + ]), + list([ + ':ref:`TRR `', + 'GROMACS TRR trajectory', + '', + '✓', + '✓', + '✓', + ]), + list([ + ':ref:`TRZ `', + 'IBIsCO or YASP binary trajectory', + '', + '✓', + '✓', + '✓', + ]), + list([ + ':ref:`TXYZ `', + 'Tinker file', + '✓', + '✓', + '✓', + '', + ]), + list([ + ':ref:`XML `', + 'HOOMD XML file', + '✓', + '', + '✓', + '', + ]), + list([ + ':ref:`XPDB `', + 'Extended PDB file', + '✓', + '✓', + '✓', + '', + ]), + list([ + ':ref:`XTC `', + 'GROMACS compressed trajectory', + '', + '✓', + '✓', + '✓', + ]), + list([ + ':ref:`XYZ `', + 'XYZ file', + '✓', + '✓', + '✓', + '✓', + ]), + ]) +# --- +# name: test_SphinxClasses + list([ + list([ + '**Coordinate reader**', + ':class:`MDAnalysis.coordinates.PDB.PDBReader`', + ]), + list([ + '**Coordinate writer**', + ':class:`MDAnalysis.coordinates.PDB.PDBWriter`', + ]), + list([ + '**Topology parser**', + ':class:`MDAnalysis.topology.PDBParser.PDBParser`', + ]), + ]) +# --- diff --git a/doc/source/scripts/tests/snapshot/__snapshots__/test_gen_selection_exporters.ambr b/doc/source/scripts/tests/snapshot/__snapshots__/test_gen_selection_exporters.ambr new file mode 100644 index 000000000..13a83f079 --- /dev/null +++ b/doc/source/scripts/tests/snapshot/__snapshots__/test_gen_selection_exporters.ambr @@ -0,0 +1,35 @@ +# serializer version: 1 +# name: test_SelectionExporterWriter + list([ + list([ + '`CHARMM`_', + 'str', + 'CHARMM selection of individual atoms', + ':class:`MDAnalysis.selections.charmm.SelectionWriter`', + ]), + list([ + '`Gromacs`_', + 'ndx', + 'GROMACS index file', + ':class:`MDAnalysis.selections.gromacs.SelectionWriter`', + ]), + list([ + '`Jmol`_', + 'spt', + 'Jmol selection commands', + ':class:`MDAnalysis.selections.jmol.SelectionWriter`', + ]), + list([ + '`PyMol`_', + 'pml', + 'PyMOL selection string', + ':class:`MDAnalysis.selections.pymol.SelectionWriter`', + ]), + list([ + '`VMD`_', + 'vmd', + 'VMD macros, available in Representations', + ':class:`MDAnalysis.selections.vmd.SelectionWriter`', + ]), + ]) +# --- diff --git a/doc/source/scripts/tests/snapshot/__snapshots__/test_gen_standard_selections.ambr b/doc/source/scripts/tests/snapshot/__snapshots__/test_gen_standard_selections.ambr new file mode 100644 index 000000000..fa39488d5 --- /dev/null +++ b/doc/source/scripts/tests/snapshot/__snapshots__/test_gen_standard_selections.ambr @@ -0,0 +1,239 @@ +# serializer version: 1 +# name: test_StandardSelectionTable_base + list([ + list([ + 'C2', + 'C4', + 'C5', + 'C5M', + 'C6', + 'C8', + 'N1', + 'N2', + ]), + list([ + 'N3', + 'N4', + 'N6', + 'N7', + 'N9', + 'O2', + 'O4', + 'O6', + ]), + ]) +# --- +# name: test_StandardSelectionTable_nucleic + list([ + list([ + 'A', + 'ADE', + 'C', + 'CYT', + 'DA', + 'DA3', + 'DA5', + 'DC', + ]), + list([ + 'DC3', + 'DC5', + 'DG', + 'DG3', + 'DG5', + 'DT', + 'DT3', + 'DT5', + ]), + list([ + 'G', + 'GUA', + 'RA', + 'RA3', + 'RA5', + 'RC', + 'RC3', + 'RC5', + ]), + list([ + 'RG', + 'RG3', + 'RG5', + 'RU', + 'RU3', + 'RU5', + 'T', + 'THY', + ]), + list([ + 'U', + 'URA', + ]), + ]) +# --- +# name: test_StandardSelectionTable_nucleic_backbone + list([ + list([ + "C3'", + "C5'", + "O3'", + "O5'", + 'P', + ]), + ]) +# --- +# name: test_StandardSelectionTable_nucleic_sugar + list([ + list([ + "C1'", + "C2'", + "C3'", + "C4'", + "O4'", + ]), + ]) +# --- +# name: test_StandardSelectionTable_protein + list([ + list([ + 'ACE', + 'ALA', + 'ALAD', + 'ARG', + 'ARGN', + 'ASF', + 'ASH', + 'ASN', + ]), + list([ + 'ASN1', + 'ASP', + 'ASPH', + 'CALA', + 'CARG', + 'CASF', + 'CASN', + 'CASP', + ]), + list([ + 'CCYS', + 'CCYX', + 'CGLN', + 'CGLU', + 'CGLY', + 'CHID', + 'CHIE', + 'CHIP', + ]), + list([ + 'CILE', + 'CLEU', + 'CLYS', + 'CME', + 'CMET', + 'CPHE', + 'CPRO', + 'CSER', + ]), + list([ + 'CTHR', + 'CTRP', + 'CTYR', + 'CVAL', + 'CYM', + 'CYS', + 'CYS1', + 'CYS2', + ]), + list([ + 'CYSH', + 'CYX', + 'DAB', + 'GLH', + 'GLN', + 'GLU', + 'GLUH', + 'GLY', + ]), + list([ + 'HID', + 'HIE', + 'HIP', + 'HIS', + 'HIS1', + 'HIS2', + 'HISA', + 'HISB', + ]), + list([ + 'HISD', + 'HISE', + 'HISH', + 'HSD', + 'HSE', + 'HSP', + 'HYP', + 'ILE', + ]), + list([ + 'LEU', + 'LYN', + 'LYS', + 'LYSH', + 'MET', + 'MSE', + 'NALA', + 'NARG', + ]), + list([ + 'NASN', + 'NASP', + 'NCYS', + 'NCYX', + 'NGLN', + 'NGLU', + 'NGLY', + 'NHID', + ]), + list([ + 'NHIE', + 'NHIP', + 'NILE', + 'NLEU', + 'NLYS', + 'NME', + 'NMET', + 'NPHE', + ]), + list([ + 'NPRO', + 'NSER', + 'NTHR', + 'NTRP', + 'NTYR', + 'NVAL', + 'ORN', + 'PGLU', + ]), + list([ + 'PHE', + 'PRO', + 'QLN', + 'SER', + 'THR', + 'TRP', + 'TYR', + 'VAL', + ]), + ]) +# --- +# name: test_StandardSelectionTable_protein_backbone + list([ + list([ + 'C', + 'CA', + 'N', + 'O', + ]), + ]) +# --- diff --git a/doc/source/scripts/tests/snapshot/__snapshots__/test_gen_topology_groupmethods.ambr b/doc/source/scripts/tests/snapshot/__snapshots__/test_gen_topology_groupmethods.ambr new file mode 100644 index 000000000..d7a36e48b --- /dev/null +++ b/doc/source/scripts/tests/snapshot/__snapshots__/test_gen_topology_groupmethods.ambr @@ -0,0 +1,80 @@ +# serializer version: 1 +# name: test_TransplantedMethods + list([ + list([ + ':meth:`~MDAnalysis.core.topologyattrs.Charges.center_of_charge`', + 'Center of (absolute) charge of (compounds of) the group .. math:: \\boldsymbol R = \\frac{\\sum_i \\vert q_i \\vert \\boldsymbol r_i} {\\sum_i \\vert q_i \\vert} where :math:`q_i` is the charge and :math:`\\boldsymbol r_i` the position of atom :math:`i` in the given :class:`MDAnalysis.core.groups.AtomGroup`', + 'charges', + ]), + list([ + ':meth:`~MDAnalysis.core.topologyattrs.Charges.dipole_moment`', + 'Dipole moment of the group or compounds in a group', + 'charges', + ]), + list([ + ':meth:`~MDAnalysis.core.topologyattrs.Charges.dipole_vector`', + 'Dipole vector of the group', + 'charges', + ]), + list([ + ':meth:`~MDAnalysis.core.topologyattrs.Charges.quadrupole_moment`', + 'Quadrupole moment of the group according to :footcite:p:`Gray1984`', + 'charges', + ]), + list([ + ':meth:`~MDAnalysis.core.topologyattrs.Charges.quadrupole_tensor`', + 'Traceless quadrupole tensor of the group or compounds', + 'charges', + ]), + list([ + ':meth:`~MDAnalysis.core.topologyattrs.Charges.total_charge`', + 'Total charge of (compounds of) the group', + 'charges', + ]), + list([ + ':meth:`~MDAnalysis.core.topologyattrs.Masses.align_principal_axis`', + 'Align principal axis with index `axis` with `vector`', + 'masses', + ]), + list([ + ':meth:`~MDAnalysis.core.topologyattrs.Masses.asphericity`', + 'Asphericity', + 'masses', + ]), + list([ + ':meth:`~MDAnalysis.core.topologyattrs.Masses.center_of_mass`', + 'Center of mass of (compounds of) the group .. math:: \\boldsymbol R = \\frac{\\sum_i m_i \\boldsymbol r_i}{\\sum m_i} where :math:`m_i` is the mass and :math:`\\boldsymbol r_i` the position of atom :math:`i` in the given :class:`MDAnalysis.core.groups.AtomGroup`', + 'masses', + ]), + list([ + ':meth:`~MDAnalysis.core.topologyattrs.Masses.gyration_moments`', + 'Moments of the gyration tensor', + 'masses', + ]), + list([ + ':meth:`~MDAnalysis.core.topologyattrs.Masses.moment_of_inertia`', + 'Moment of inertia tensor relative to center of mass', + 'masses', + ]), + list([ + ':meth:`~MDAnalysis.core.topologyattrs.Masses.principal_axes`', + 'Calculate the principal axes from the moment of inertia', + 'masses', + ]), + list([ + ':meth:`~MDAnalysis.core.topologyattrs.Masses.radius_of_gyration`', + 'Radius of gyration', + 'masses', + ]), + list([ + ':meth:`~MDAnalysis.core.topologyattrs.Masses.shape_parameter`', + 'Shape parameter', + 'masses', + ]), + list([ + ':meth:`~MDAnalysis.core.topologyattrs.Masses.total_mass`', + 'Total mass of (compounds of) the group', + 'masses', + ]), + ]) +# --- diff --git a/doc/source/scripts/tests/snapshot/__snapshots__/test_gen_topologyattr_defaults.ambr b/doc/source/scripts/tests/snapshot/__snapshots__/test_gen_topologyattr_defaults.ambr new file mode 100644 index 000000000..7ed079ab4 --- /dev/null +++ b/doc/source/scripts/tests/snapshot/__snapshots__/test_gen_topologyattr_defaults.ambr @@ -0,0 +1,285 @@ +# serializer version: 1 +# name: test_TopologyDefaults + list([ + list([ + 'altLocs', + 'altLoc', + "''", + 'atom', + , + ]), + list([ + 'angles', + 'angles', + 'No default values', + 'atom', + None, + ]), + list([ + 'aromaticities', + 'aromaticity', + 'False', + 'atom', + , + ]), + list([ + 'atomiccharges', + 'atomiccharge', + 'No default values', + 'atom', + None, + ]), + list([ + 'atomnums', + 'atomnum', + 'No default values', + 'atom', + None, + ]), + list([ + 'bonds', + 'bonds', + 'No default values', + 'atom', + None, + ]), + list([ + 'chainIDs', + 'chainID', + "''", + 'atom', + , + ]), + list([ + 'chargegroups', + 'chargegroup', + 'No default values', + 'atom', + None, + ]), + list([ + 'charges', + 'charge', + '0.0', + 'atom', + , + ]), + list([ + 'chiralities', + 'chirality', + 'No default values', + 'atom', + 'U1', + ]), + list([ + 'cmaps', + 'cmaps', + 'No default values', + 'atom', + None, + ]), + list([ + 'dihedrals', + 'dihedrals', + 'No default values', + 'atom', + None, + ]), + list([ + 'elements', + 'element', + "''", + 'atom', + , + ]), + list([ + 'epsilon14s', + 'epsilon14', + '0.0', + 'atom', + , + ]), + list([ + 'epsilons', + 'epsilon', + '0.0', + 'atom', + , + ]), + list([ + 'formalcharges', + 'formalcharge', + '0.0', + 'atom', + , + ]), + list([ + 'gbscreens', + 'gbscreen', + '0.0', + 'atom', + , + ]), + list([ + 'icodes', + 'icode', + "''", + 'residue', + , + ]), + list([ + 'ids', + 'id', + 'continuous sequence from 1 to n_atoms', + 'atom', + , + ]), + list([ + 'impropers', + 'impropers', + 'No default values', + 'atom', + None, + ]), + list([ + 'masses', + 'mass', + '0.0', + 'atom', + , + ]), + list([ + 'models', + 'model', + 'No default values', + 'segment', + None, + ]), + list([ + 'molnums', + 'molnum', + 'No default values', + 'residue', + , + ]), + list([ + 'moltypes', + 'moltype', + "''", + 'residue', + , + ]), + list([ + 'names', + 'name', + "''", + 'atom', + , + ]), + list([ + 'nbindices', + 'nbindex', + '0', + 'atom', + , + ]), + list([ + 'occupancies', + 'occupancy', + '0.0', + 'atom', + , + ]), + list([ + 'radii', + 'radius', + '0.0', + 'atom', + , + ]), + list([ + 'record_types', + 'record_type', + "'ATOM'", + 'atom', + , + ]), + list([ + 'resids', + 'resid', + 'continuous sequence from 1 to n_residues', + 'residue', + , + ]), + list([ + 'resnames', + 'resname', + "''", + 'residue', + , + ]), + list([ + 'resnums', + 'resnum', + 'continuous sequence from 1 to n_residues', + 'residue', + , + ]), + list([ + 'rmin14s', + 'rmin14', + '0.0', + 'atom', + , + ]), + list([ + 'rmins', + 'rmin', + '0.0', + 'atom', + , + ]), + list([ + 'segids', + 'segid', + "''", + 'segment', + , + ]), + list([ + 'solventradii', + 'solventradius', + '0.0', + 'atom', + , + ]), + list([ + 'tempfactors', + 'tempfactor', + '0.0', + 'atom', + , + ]), + list([ + 'type_indices', + 'type_index', + 'No default values', + 'atom', + None, + ]), + list([ + 'types', + 'type', + "''", + 'atom', + , + ]), + list([ + 'ureybradleys', + 'ureybradleys', + 'No default values', + 'atom', + None, + ]), + ]) +# --- diff --git a/doc/source/scripts/tests/snapshot/__snapshots__/test_gen_topologyparser_attrs.ambr b/doc/source/scripts/tests/snapshot/__snapshots__/test_gen_topologyparser_attrs.ambr new file mode 100644 index 000000000..79a63fd0c --- /dev/null +++ b/doc/source/scripts/tests/snapshot/__snapshots__/test_gen_topologyparser_attrs.ambr @@ -0,0 +1,558 @@ +# serializer version: 1 +# name: test_ConnectivityAttrs + list([ + list([ + 'angles', + 'angles', + ':ref:`DATA `, :ref:`GSD `, :ref:`PSF `, :ref:`TOP, PRMTOP, PARM7 `, :ref:`TPR `, :ref:`XML `', + ]), + list([ + 'bonds', + 'bonds', + ':ref:`DATA `, :ref:`DMS `, :ref:`GSD `, :ref:`MMTF `, :ref:`MOL2 `, :ref:`PSF `, :ref:`TOP, PRMTOP, PARM7 `, :ref:`TPR `, :ref:`TXYZ, ARC `, :ref:`XML `', + ]), + list([ + 'dihedrals', + 'dihedrals', + ':ref:`DATA `, :ref:`GSD `, :ref:`PSF `, :ref:`TOP, PRMTOP, PARM7 `, :ref:`TPR `, :ref:`XML `', + ]), + list([ + 'impropers', + 'impropers', + ':ref:`DATA `, :ref:`GSD `, :ref:`PSF `, :ref:`TOP, PRMTOP, PARM7 `, :ref:`TPR `, :ref:`XML `', + ]), + ]) +# --- +# name: test_TopologyAttrs + list([ + list([ + 'altLoc', + 'altLocs', + 'Alternate location', + ':ref:`MMTF `, :ref:`PDB, ENT `, :ref:`PDBQT `, :ref:`XPDB `', + ]), + list([ + 'angles', + 'angles', + '', + ':ref:`DATA `, :ref:`GSD `, :ref:`PSF `, :ref:`TOP, PRMTOP, PARM7 `, :ref:`TPR `, :ref:`XML `', + ]), + list([ + 'aromaticity', + 'aromaticities', + '', + '', + ]), + list([ + 'atomiccharge', + 'atomiccharges', + 'Atomic number', + ':ref:`GMS `', + ]), + list([ + 'atomnum', + 'atomnums', + '?', + ':ref:`DMS `', + ]), + list([ + 'bonds', + 'bonds', + '', + ':ref:`DATA `, :ref:`DMS `, :ref:`GSD `, :ref:`MMTF `, :ref:`MOL2 `, :ref:`PSF `, :ref:`TOP, PRMTOP, PARM7 `, :ref:`TPR `, :ref:`TXYZ, ARC `, :ref:`XML `', + ]), + list([ + 'chainID', + 'chainIDs', + 'chain ID', + ':ref:`DMS `, :ref:`PDB, ENT `, :ref:`PDBQT `, :ref:`TPR `, :ref:`XPDB `', + ]), + list([ + 'charge', + 'charges', + 'partial atomic charge', + ':ref:`DATA `, :ref:`DMS `, :ref:`GSD `, :ref:`MMTF `, :ref:`MOL2 `, :ref:`PDBQT `, :ref:`PQR `, :ref:`PSF `, :ref:`TOP, PRMTOP, PARM7 `, :ref:`TPR `, :ref:`XML `', + ]), + list([ + 'chargegroup', + 'chargegroups', + '', + '', + ]), + list([ + 'chirality', + 'chiralities', + '', + '', + ]), + list([ + 'cmaps', + 'cmaps', + '', + '', + ]), + list([ + 'dihedrals', + 'dihedrals', + '', + ':ref:`DATA `, :ref:`GSD `, :ref:`PSF `, :ref:`TOP, PRMTOP, PARM7 `, :ref:`TPR `, :ref:`XML `', + ]), + list([ + 'element', + 'elements', + 'atom element', + ':ref:`IN, FHIAIMS `, :ref:`MOL2 `, :ref:`PDB, ENT `, :ref:`TPR `, :ref:`TXYZ, ARC `, :ref:`XYZ `', + ]), + list([ + 'epsilon', + 'epsilons', + '', + '', + ]), + list([ + 'epsilon14', + 'epsilon14s', + '', + '', + ]), + list([ + 'formalcharge', + 'formalcharges', + '', + '', + ]), + list([ + 'gbscreen', + 'gbscreens', + '', + '', + ]), + list([ + 'icode', + 'icodes', + 'atom insertion code', + ':ref:`MMTF `, :ref:`PDB, ENT `, :ref:`PDBQT `, :ref:`PQR `, :ref:`XPDB `', + ]), + list([ + 'impropers', + 'impropers', + '', + ':ref:`DATA `, :ref:`GSD `, :ref:`PSF `, :ref:`TOP, PRMTOP, PARM7 `, :ref:`TPR `, :ref:`XML `', + ]), + list([ + 'model', + 'models', + 'model number (from 0)', + ':ref:`MMTF `', + ]), + list([ + 'molnum', + 'molnums', + '[molecules] number (from 0)', + ':ref:`TPR `', + ]), + list([ + 'moltype', + 'moltypes', + '[moleculetype] name', + ':ref:`TPR `', + ]), + list([ + 'name', + 'names', + 'atom names', + ':ref:`CONFIG `, :ref:`CRD `, :ref:`DMS `, :ref:`GMS `, :ref:`GRO `, :ref:`GSD `, :ref:`HISTORY `, :ref:`IN, FHIAIMS `, :ref:`MMTF `, :ref:`MOL2 `, :ref:`PDB, ENT `, :ref:`PDBQT `, :ref:`PQR `, :ref:`PSF `, :ref:`TOP, PRMTOP, PARM7 `, :ref:`TPR `, :ref:`TXYZ, ARC `, :ref:`XPDB `, :ref:`XYZ `', + ]), + list([ + 'nbindex', + 'nbindices', + '', + '', + ]), + list([ + 'occupancy', + 'occupancies', + 'atom occupancy', + ':ref:`MMTF `, :ref:`PDB, ENT `, :ref:`PDBQT `, :ref:`XPDB `', + ]), + list([ + 'radius', + 'radii', + 'atomic radius', + ':ref:`GSD `, :ref:`PQR `, :ref:`XML `', + ]), + list([ + 'record_type', + 'record_types', + 'ATOM / HETATM', + ':ref:`PDB, ENT `, :ref:`PDBQT `, :ref:`PQR `, :ref:`XPDB `', + ]), + list([ + 'resname', + 'resnames', + 'residue name (except GSD has ints)', + ':ref:`CRD `, :ref:`DMS `, :ref:`GRO `, :ref:`GSD `, :ref:`MMTF `, :ref:`MOL2 `, :ref:`PDB, ENT `, :ref:`PDBQT `, :ref:`PQR `, :ref:`PSF `, :ref:`TOP, PRMTOP, PARM7 `, :ref:`TPR `, :ref:`XPDB `', + ]), + list([ + 'rmin', + 'rmins', + '', + '', + ]), + list([ + 'rmin14', + 'rmin14s', + '', + '', + ]), + list([ + 'solventradius', + 'solventradii', + '', + '', + ]), + list([ + 'tempfactor', + 'tempfactors', + 'B-factor', + ':ref:`CRD `, :ref:`MMTF `, :ref:`PDB, ENT `, :ref:`PDBQT `, :ref:`XPDB `', + ]), + list([ + 'type_index', + 'type_indices', + 'amber atom type number', + ':ref:`TOP, PRMTOP, PARM7 `', + ]), + list([ + 'ureybradleys', + 'ureybradleys', + '', + '', + ]), + ]) +# --- +# name: test_TopologyParsers_attrs + defaultdict({ + 'altLocs': set({ + ':ref:`MMTF `', + ':ref:`PDB, ENT `', + ':ref:`PDBQT `', + ':ref:`XPDB `', + }), + 'angles': set({ + ':ref:`DATA `', + ':ref:`GSD `', + ':ref:`PSF `', + ':ref:`TOP, PRMTOP, PARM7 `', + ':ref:`TPR `', + ':ref:`XML `', + }), + 'atomiccharges': set({ + ':ref:`GMS `', + }), + 'atomnums': set({ + ':ref:`DMS `', + }), + 'bonds': set({ + ':ref:`DATA `', + ':ref:`DMS `', + ':ref:`GSD `', + ':ref:`MMTF `', + ':ref:`MOL2 `', + ':ref:`PSF `', + ':ref:`TOP, PRMTOP, PARM7 `', + ':ref:`TPR `', + ':ref:`TXYZ, ARC `', + ':ref:`XML `', + }), + 'chainIDs': set({ + ':ref:`DMS `', + ':ref:`PDB, ENT `', + ':ref:`PDBQT `', + ':ref:`TPR `', + ':ref:`XPDB `', + }), + 'charges': set({ + ':ref:`DATA `', + ':ref:`DMS `', + ':ref:`GSD `', + ':ref:`MMTF `', + ':ref:`MOL2 `', + ':ref:`PDBQT `', + ':ref:`PQR `', + ':ref:`PSF `', + ':ref:`TOP, PRMTOP, PARM7 `', + ':ref:`TPR `', + ':ref:`XML `', + }), + 'dihedrals': set({ + ':ref:`DATA `', + ':ref:`GSD `', + ':ref:`PSF `', + ':ref:`TOP, PRMTOP, PARM7 `', + ':ref:`TPR `', + ':ref:`XML `', + }), + 'elements': set({ + ':ref:`IN, FHIAIMS `', + ':ref:`MOL2 `', + ':ref:`PDB, ENT `', + ':ref:`TPR `', + ':ref:`TXYZ, ARC `', + ':ref:`XYZ `', + }), + 'icodes': set({ + ':ref:`MMTF `', + ':ref:`PDB, ENT `', + ':ref:`PDBQT `', + ':ref:`PQR `', + ':ref:`XPDB `', + }), + 'impropers': set({ + ':ref:`DATA `', + ':ref:`GSD `', + ':ref:`PSF `', + ':ref:`TOP, PRMTOP, PARM7 `', + ':ref:`TPR `', + ':ref:`XML `', + }), + 'masses': set({ + ':ref:`CONFIG `', + ':ref:`CRD `', + ':ref:`GMS `', + ':ref:`GRO `', + ':ref:`HISTORY `', + ':ref:`IN, FHIAIMS `', + ':ref:`LAMMPSDUMP `', + ':ref:`MMTF `', + ':ref:`MOL2 `', + ':ref:`PDB, ENT `', + ':ref:`PDBQT `', + ':ref:`PQR `', + ':ref:`TXYZ, ARC `', + ':ref:`XPDB `', + ':ref:`XYZ `', + }), + 'models': set({ + ':ref:`MMTF `', + }), + 'molnums': set({ + ':ref:`TPR `', + }), + 'moltypes': set({ + ':ref:`TPR `', + }), + 'names': set({ + ':ref:`CONFIG `', + ':ref:`CRD `', + ':ref:`DMS `', + ':ref:`GMS `', + ':ref:`GRO `', + ':ref:`GSD `', + ':ref:`HISTORY `', + ':ref:`IN, FHIAIMS `', + ':ref:`MMTF `', + ':ref:`MOL2 `', + ':ref:`PDB, ENT `', + ':ref:`PDBQT `', + ':ref:`PQR `', + ':ref:`PSF `', + ':ref:`TOP, PRMTOP, PARM7 `', + ':ref:`TPR `', + ':ref:`TXYZ, ARC `', + ':ref:`XPDB `', + ':ref:`XYZ `', + }), + 'occupancies': set({ + ':ref:`MMTF `', + ':ref:`PDB, ENT `', + ':ref:`PDBQT `', + ':ref:`XPDB `', + }), + 'radii': set({ + ':ref:`GSD `', + ':ref:`PQR `', + ':ref:`XML `', + }), + 'record_types': set({ + ':ref:`PDB, ENT `', + ':ref:`PDBQT `', + ':ref:`PQR `', + ':ref:`XPDB `', + }), + 'resnames': set({ + ':ref:`CRD `', + ':ref:`DMS `', + ':ref:`GRO `', + ':ref:`GSD `', + ':ref:`MMTF `', + ':ref:`MOL2 `', + ':ref:`PDB, ENT `', + ':ref:`PDBQT `', + ':ref:`PQR `', + ':ref:`PSF `', + ':ref:`TOP, PRMTOP, PARM7 `', + ':ref:`TPR `', + ':ref:`XPDB `', + }), + 'tempfactors': set({ + ':ref:`CRD `', + ':ref:`MMTF `', + ':ref:`PDB, ENT `', + ':ref:`PDBQT `', + ':ref:`XPDB `', + }), + 'type_indices': set({ + ':ref:`TOP, PRMTOP, PARM7 `', + }), + 'types': set({ + ':ref:`CONFIG `', + ':ref:`CRD `', + ':ref:`DMS `', + ':ref:`GMS `', + ':ref:`GRO `', + ':ref:`HISTORY `', + ':ref:`IN, FHIAIMS `', + ':ref:`PDB, ENT `', + ':ref:`PQR `', + ':ref:`XPDB `', + ':ref:`XYZ `', + }), + }) +# --- +# name: test_TopologyParsers_lines + list([ + list([ + ':ref:`CONFIG `', + 'DL_Poly CONFIG file', + 'names', + 'masses, types', + ]), + list([ + ':ref:`CRD `', + 'CHARMM CARD file', + 'names, resnames, tempfactors', + 'masses, types', + ]), + list([ + ':ref:`DATA `', + 'LAMMPS data file', + 'angles, bonds, charges, dihedrals, impropers', + '', + ]), + list([ + ':ref:`DMS `', + 'DESRES Molecular Structure file', + 'atomnums, bonds, chainIDs, charges, names, resnames', + 'types', + ]), + list([ + ':ref:`GMS `', + 'GAMESS file', + 'atomiccharges, names', + 'masses, types', + ]), + list([ + ':ref:`GRO `', + 'GROMACS structure file', + 'names, resnames', + 'masses, types', + ]), + list([ + ':ref:`GSD `', + 'HOOMD GSD file', + 'angles, bonds, charges, dihedrals, impropers, names, radii, resnames', + '', + ]), + list([ + ':ref:`HISTORY `', + 'DL_Poly HISTORY file', + 'names', + 'masses, types', + ]), + list([ + ':ref:`IN, FHIAIMS `', + 'FHI-aims input file', + 'elements, names', + 'masses, types', + ]), + list([ + ':ref:`LAMMPSDUMP `', + 'LAMMPS ascii dump file', + '', + 'masses', + ]), + list([ + ':ref:`MMTF `', + 'MMTF file', + 'altLocs, bonds, charges, icodes, models, names, occupancies, resnames, tempfactors', + 'masses', + ]), + list([ + ':ref:`MOL2 `', + 'Tripos MOL2 file', + 'bonds, charges, elements, names, resnames', + 'masses', + ]), + list([ + ':ref:`PDB, ENT `', + 'Standard PDB file', + 'altLocs, chainIDs, elements, icodes, names, occupancies, record_types, resnames, tempfactors', + 'masses, types', + ]), + list([ + ':ref:`PDBQT `', + 'PDBQT file', + 'altLocs, chainIDs, charges, icodes, names, occupancies, record_types, resnames, tempfactors', + 'masses', + ]), + list([ + ':ref:`PQR `', + 'PQR file', + 'charges, icodes, names, radii, record_types, resnames', + 'masses, types', + ]), + list([ + ':ref:`PSF `', + 'CHARMM, NAMD, or XPLOR PSF file', + 'angles, bonds, charges, dihedrals, impropers, names, resnames', + '', + ]), + list([ + ':ref:`TOP, PRMTOP, PARM7 `', + 'AMBER topology file', + 'angles, bonds, charges, dihedrals, impropers, names, resnames, type_indices', + '', + ]), + list([ + ':ref:`TPR `', + 'GROMACS run topology file', + 'angles, bonds, chainIDs, charges, dihedrals, elements, impropers, molnums, moltypes, names, resnames', + '', + ]), + list([ + ':ref:`TXYZ, ARC `', + 'Tinker file', + 'bonds, elements, names', + 'masses', + ]), + list([ + ':ref:`XML `', + 'HOOMD XML file', + 'angles, bonds, charges, dihedrals, impropers, radii', + '', + ]), + list([ + ':ref:`XPDB `', + 'Extended PDB file', + 'altLocs, chainIDs, icodes, names, occupancies, record_types, resnames, tempfactors', + 'masses, types', + ]), + list([ + ':ref:`XYZ `', + 'XYZ file', + 'elements, names', + 'masses, types', + ]), + ]) +# --- diff --git a/doc/source/scripts/tests/snapshot/__snapshots__/test_gen_unit_tables.ambr b/doc/source/scripts/tests/snapshot/__snapshots__/test_gen_unit_tables.ambr new file mode 100644 index 000000000..d5515869b --- /dev/null +++ b/doc/source/scripts/tests/snapshot/__snapshots__/test_gen_unit_tables.ambr @@ -0,0 +1,352 @@ +# serializer version: 1 +# name: test_write_unit_table + list([ + tuple( + ''' + + ------ + + ''', + ), + tuple( + 'Length', + ), + tuple( + ''' + + ------ + + ''', + ), + tuple( + ''' + + + + ''', + ), + tuple( + ''' + ========== =================== + Unit Conversion factor + ========== =================== + A 1 + Angstrom 1 + angstrom 1 + femtometer 100000 + fm 100000 + nanometer 0.1 + nm 0.1 + picometer 100 + pm 100 + Å 1 + ========== =================== + ''', + ), + tuple( + ''' + + + ''', + ), + tuple( + ''' + + ------- + + ''', + ), + tuple( + 'Density', + ), + tuple( + ''' + + ------- + + ''', + ), + tuple( + ''' + + + + ''', + ), + tuple( + ''' + ============== =================== + Unit Conversion factor + ============== =================== + A^{-3} 1 + Angstrom^{-3} 1 + Molar 1660.54 + SPC 30.3718 + TIP3P 29.8566 + TIP4P 29.8864 + nanometer^{-3} 1000 + nm^{-3} 1000 + water 30.0063 + Å^{-3} 1 + ============== =================== + ''', + ), + tuple( + ''' + + + ''', + ), + tuple( + ''' + + ---- + + ''', + ), + tuple( + 'Time', + ), + tuple( + ''' + + ---- + + ''', + ), + tuple( + ''' + + + + ''', + ), + tuple( + ''' + =========== =================== + Unit Conversion factor + =========== =================== + AKMA 20.4548 + femtosecond 1000 + fs 1000 + microsecond 1e-06 + millisecond 1e-09 + ms 1e-09 + nanosecond 0.001 + ns 0.001 + picosecond 1 + ps 1 + s 1e-12 + sec 1e-12 + second 1e-12 + us 1e-06 + μs 1e-06 + =========== =================== + ''', + ), + tuple( + ''' + + + ''', + ), + tuple( + ''' + + ------ + + ''', + ), + tuple( + 'Charge', + ), + tuple( + ''' + + ------ + + ''', + ), + tuple( + ''' + + + + ''', + ), + tuple( + ''' + ====== =================== + Unit Conversion factor + ====== =================== + Amber 18.2223 + As 1.60218e-19 + C 1.60218e-19 + e 1 + ====== =================== + ''', + ), + tuple( + ''' + + + ''', + ), + tuple( + ''' + + ----- + + ''', + ), + tuple( + 'Speed', + ), + tuple( + ''' + + ----- + + ''', + ), + tuple( + ''' + + + + ''', + ), + tuple( + ''' + ==================== =================== + Unit Conversion factor + ==================== =================== + A/AKMA 0.0488882 + A/fs 1000 + A/ms 1e-09 + A/ps 1 + A/us 1e-06 + Angstrom/AKMA 0.0488882 + Angstrom/femtosecond 1000 + Angstrom/fs 1000 + Angstrom/microsecond 1e-06 + Angstrom/millisecond 1e-09 + Angstrom/ms 1e-09 + Angstrom/picosecond 1 + Angstrom/ps 1 + Angstrom/us 1e-06 + Angstrom/μs 1e-06 + angstrom/femtosecond 1000 + angstrom/fs 1000 + angstrom/microsecond 1e-06 + angstrom/millisecond 1e-09 + angstrom/ms 1e-09 + angstrom/picosecond 1 + angstrom/us 1e-06 + angstrom/μs 1e-06 + m/s 100 + nanometer/picosecond 0.1 + nanometer/ps 0.1 + nm/ns 100 + nm/ps 0.1 + pm/ps 100 + Å/ps 1 + ==================== =================== + ''', + ), + tuple( + ''' + + + ''', + ), + tuple( + ''' + + ----- + + ''', + ), + tuple( + 'Force', + ), + tuple( + ''' + + ----- + + ''', + ), + tuple( + ''' + + + + ''', + ), + tuple( + ''' + =================== =================== + Unit Conversion factor + =================== =================== + J/m 1.66054e-11 + N 1.66054e-11 + Newton 1.66054e-11 + kJ/(mol*A) 1 + kJ/(mol*Angstrom) 1 + kJ/(mol*nm) 10 + kJ/(mol*Å) 1 + kcal/(mol*Angstrom) 0.239006 + =================== =================== + ''', + ), + tuple( + ''' + + + ''', + ), + tuple( + ''' + + ------ + + ''', + ), + tuple( + 'Energy', + ), + tuple( + ''' + + ------ + + ''', + ), + tuple( + ''' + + + + ''', + ), + tuple( + ''' + ======== =================== + Unit Conversion factor + ======== =================== + J 1.66054e-21 + eV 0.0103643 + kJ/mol 1 + kcal/mol 0.239006 + ======== =================== + ''', + ), + tuple( + ''' + + + ''', + ), + ]) +# --- diff --git a/doc/source/scripts/tests/snapshot/test_gen_format_overview_classes.py b/doc/source/scripts/tests/snapshot/test_gen_format_overview_classes.py new file mode 100644 index 000000000..835e5d039 --- /dev/null +++ b/doc/source/scripts/tests/snapshot/test_gen_format_overview_classes.py @@ -0,0 +1,30 @@ +from unittest.mock import patch + +from gen_format_overview_classes import ( + FILE_TYPES, + CoordinateReaders, + FormatOverview, + SphinxClasses, +) + + +def test_FILE_TYPES(): + assert FILE_TYPES.keys() >= {"DCD", "GRO", "XTC", "ITP"} + + +def test_FormatOverview(snapshot): + with patch("builtins.open"): + ov = FormatOverview() + assert ov.lines == snapshot + + +def test_CoordinateReaders(snapshot): + with patch("builtins.open"): + cr = CoordinateReaders() + assert cr.lines == snapshot + + +def test_SphinxClasses(snapshot): + with patch("builtins.open"): + sc = SphinxClasses("PDB") + assert sc.lines == snapshot diff --git a/doc/source/scripts/tests/snapshot/test_gen_selection_exporters.py b/doc/source/scripts/tests/snapshot/test_gen_selection_exporters.py new file mode 100644 index 000000000..34d8a5616 --- /dev/null +++ b/doc/source/scripts/tests/snapshot/test_gen_selection_exporters.py @@ -0,0 +1,10 @@ +from unittest.mock import patch + +from gen_selection_exporters import SelectionExporterWriter +from MDAnalysis.core import selection as sel + + +def test_SelectionExporterWriter(snapshot): + with patch("builtins.open"): + se = SelectionExporterWriter() + assert se.lines == snapshot diff --git a/doc/source/scripts/tests/snapshot/test_gen_standard_selections.py b/doc/source/scripts/tests/snapshot/test_gen_standard_selections.py new file mode 100644 index 000000000..dc4529de3 --- /dev/null +++ b/doc/source/scripts/tests/snapshot/test_gen_standard_selections.py @@ -0,0 +1,52 @@ +from unittest.mock import patch + +from gen_standard_selections import StandardSelectionTable +from MDAnalysis.core import selection as sel + + +def test_StandardSelectionTable_protein(snapshot): + with patch("builtins.open"): + ss = StandardSelectionTable( + "protein", sel.ProteinSelection, "prot_res", True + ) + assert ss.lines == snapshot + + +def test_StandardSelectionTable_protein_backbone(snapshot): + with patch("builtins.open"): + ss = StandardSelectionTable( + "protein_backbone", sel.BackboneSelection, "bb_atoms", True + ) + assert ss.lines == snapshot + + +def test_StandardSelectionTable_nucleic(snapshot): + with patch("builtins.open"): + ss = StandardSelectionTable( + "nucleic", sel.NucleicSelection, "nucl_res", True + ) + assert ss.lines == snapshot + + +def test_StandardSelectionTable_nucleic_backbone(snapshot): + with patch("builtins.open"): + ss = StandardSelectionTable( + "nucleic_backbone", sel.NucleicBackboneSelection, "bb_atoms", True + ) + assert ss.lines == snapshot + + +def test_StandardSelectionTable_base(snapshot): + with patch("builtins.open"): + ss = StandardSelectionTable( + "base", sel.BaseSelection, "base_atoms", True + ) + assert ss.lines == snapshot + + +def test_StandardSelectionTable_nucleic_sugar(snapshot): + with patch("builtins.open"): + ss = StandardSelectionTable( + "nucleic_sugar", sel.NucleicSugarSelection, "sug_atoms", True + ) + assert ss.lines == snapshot diff --git a/doc/source/scripts/tests/snapshot/test_gen_topology_groupmethods.py b/doc/source/scripts/tests/snapshot/test_gen_topology_groupmethods.py new file mode 100644 index 000000000..f585f489d --- /dev/null +++ b/doc/source/scripts/tests/snapshot/test_gen_topology_groupmethods.py @@ -0,0 +1,10 @@ +from unittest.mock import patch + +from gen_topology_groupmethods import TransplantedMethods +from MDAnalysis.core import selection as sel + + +def test_TransplantedMethods(snapshot): + with patch("builtins.open"): + tm = TransplantedMethods() + assert tm.lines == snapshot diff --git a/doc/source/scripts/tests/snapshot/test_gen_topologyattr_defaults.py b/doc/source/scripts/tests/snapshot/test_gen_topologyattr_defaults.py new file mode 100644 index 000000000..bf461d275 --- /dev/null +++ b/doc/source/scripts/tests/snapshot/test_gen_topologyattr_defaults.py @@ -0,0 +1,10 @@ +from unittest.mock import patch + +from gen_topologyattr_defaults import TopologyDefaults +from MDAnalysis.core import selection as sel + + +def test_TopologyDefaults(snapshot): + with patch("builtins.open"): + td = TopologyDefaults() + assert td.lines == snapshot diff --git a/doc/source/scripts/tests/snapshot/test_gen_topologyparser_attrs.py b/doc/source/scripts/tests/snapshot/test_gen_topologyparser_attrs.py new file mode 100644 index 000000000..f8d95a152 --- /dev/null +++ b/doc/source/scripts/tests/snapshot/test_gen_topologyparser_attrs.py @@ -0,0 +1,34 @@ +from unittest.mock import patch + +from gen_topologyparser_attrs import ( + ConnectivityAttrs, + TopologyAttrs, + TopologyParsers, +) +from MDAnalysis.core import selection as sel + + +def test_TopologyParsers_lines(snapshot): + with patch("builtins.open"): + top = TopologyParsers() + assert top.lines == snapshot + + +def test_TopologyParsers_attrs(snapshot): + with patch("builtins.open"): + top = TopologyParsers() + assert top.attrs == snapshot + + +def test_TopologyAttrs(snapshot): + with patch("builtins.open"): + top = TopologyParsers() + ta = TopologyAttrs(top.attrs) + assert ta.lines == snapshot + + +def test_ConnectivityAttrs(snapshot): + with patch("builtins.open"): + top = TopologyParsers() + ca = ConnectivityAttrs(top.attrs) + assert ca.lines == snapshot diff --git a/doc/source/scripts/tests/snapshot/test_gen_unit_tables.py b/doc/source/scripts/tests/snapshot/test_gen_unit_tables.py new file mode 100644 index 000000000..fa90bc589 --- /dev/null +++ b/doc/source/scripts/tests/snapshot/test_gen_unit_tables.py @@ -0,0 +1,15 @@ +from pathlib import Path +from unittest.mock import mock_open, patch + +from gen_unit_tables import write_unit_table + + +def test_write_unit_table(snapshot): + with patch.object(Path, "open", mock_open()) as mock_open_file: + write_unit_table(filename=Path()) + + lines = [ + args[0] for args in mock_open_file.return_value.write.call_args_list + ] + # Exclude the first line, because it contains "Generated by /home/username/..." + assert lines[1:] == snapshot diff --git a/environment.yml b/environment.yml index 709cb78bf..e23c2477e 100644 --- a/environment.yml +++ b/environment.yml @@ -55,3 +55,4 @@ dependencies: - git+https://github.com/MDAnalysis/mdanalysis@develop#egg=mdanalysis&subdirectory=package - git+https://github.com/MDAnalysis/mdanalysis@develop#egg=MDAnalysisTests&subdirectory=testsuite - git+https://github.com/MDAnalysis/MDAnalysisData@master#egg=MDAnalysisData + - syrupy # snapshot tests