1# -*- Mode: python; tab-width: 4; indent-tabs-mode:nil; coding:utf-8 -*-
2# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 fileencoding=utf-8
3#
4# MDAnalysis --- https://www.mdanalysis.org
5# Copyright (c) 2006-2017 The MDAnalysis Development Team and contributors
6# (see the file AUTHORS for the full list of names)
7#
8# Released under the GNU Public Licence, v2 or any higher version
9#
10# Please cite your use of MDAnalysis in published work:
11#
12# R. J. Gowers, M. Linke, J. Barnoud, T. J. E. Reddy, M. N. Melo, S. L. Seyler,
13# D. L. Dotson, J. Domanski, S. Buchoux, I. M. Kenney, and O. Beckstein.
14# MDAnalysis: A Python package for the rapid analysis of molecular dynamics
15# simulations. In S. Benthall and S. Rostrup editors, Proceedings of the 15th
16# Python in Science Conference, pages 102-109, Austin, TX, 2016. SciPy.
17#
18# N. Michaud-Agrawal, E. J. Denning, T. B. Woolf, and O. Beckstein.
19# MDAnalysis: A Toolkit for the Analysis of Molecular Dynamics Simulations.
20# J. Comput. Chem. 32 (2011), 2319--2327, doi:10.1002/jcc.21787
21#
22from __future__ import division, absolute_import
23
24
25from six import string_types
26import MDAnalysis
27import pytest
28
29from MDAnalysis.tests.datafiles import (
30    CRD,
31    LAMMPSdata,
32    DLP_CONFIG_minimal,
33    GRO,
34    TPR,
35    DMS,
36    GMS_SYMOPT,
37    MMTF,
38    mol2_molecule,
39    PRM7,
40    PDB_small,
41    PDBQT_input,
42    PQR,
43    PRM,
44    PSF,
45    PRM12,
46    HoomdXMLdata,
47    XPDB_small,
48    XYZ_mini,
49    DLP_HISTORY_minimal, )
50
51
52@pytest.mark.parametrize('prop', [
53    'name',
54    'resname',
55    'type',
56    'segid',
57    'moltype',
58])
59# topology formats curated from values available in
60# MDAnalysis._PARSERS
61@pytest.mark.parametrize( 'top_format, top', [
62    ('CONFIG', DLP_CONFIG_minimal),
63    ('CRD', CRD),
64    ('DATA', LAMMPSdata),
65    ('DMS', DMS),
66    ('GMS', GMS_SYMOPT),
67    ('GRO', GRO),
68    ('HISTORY', DLP_HISTORY_minimal),
69    ('MMTF', MMTF),
70    ('MOL2', mol2_molecule),
71    ('PARM7', PRM7),
72    ('PDB', PDB_small),
73    ('PDBQT', PDBQT_input),
74    ('PQR', PQR),
75    ('PRMTOP', PRM),
76    ('PSF', PSF),
77    ('TOP', PRM12),
78    ('TPR', TPR),
79    ('XML', HoomdXMLdata),
80    ('XPDB', XPDB_small),
81    ('XYZ', XYZ_mini)
82])
83def test_str_types(top_format, top, prop):
84    # Python 2/3 topology string type checking
85    # Related to Issue #1336
86    u = MDAnalysis.Universe(top, format=top_format)
87    if hasattr(u.atoms[0], prop):
88        assert isinstance(getattr(u.atoms[0], prop), string_types)
89