1111from __future__ import absolute_import , division
1212
1313import os .path
14+ import glob
1415
1516import pytest
1617
1718from MDAnalysisData import base
1819from MDAnalysisData import datasets
1920from MDAnalysisData import adk_equilibrium
2021from MDAnalysisData import ifabp_water
21-
22+ from MDAnalysisData import nhaa_equilibrium
23+ from MDAnalysisData import CG_fiber
24+ from MDAnalysisData import vesicles
25+ from MDAnalysisData import adk_transitions
2226
2327# For filetype=topology, the data are downloaded and cached.
2428# For filetype=trajectory the cached data are used.
@@ -38,7 +42,9 @@ def test_adk_equilibrium(filetype):
3842 assert os .path .exists (data [filetype ])
3943
4044@pytest .mark .online
41- @pytest .mark .parametrize ('filetype' , ('topology' , 'trajectory' ))
45+ @pytest .mark .parametrize ('filetype' , ('topology' ,
46+ 'trajectory' ,
47+ 'structure' ))
4248def test_ifabp_water (filetype ):
4349 data = datasets .fetch_ifabp_water ()
4450
@@ -50,3 +56,77 @@ def test_ifabp_water(filetype):
5056 assert os .path .basename (data [filetype ]) == metadata [filetype ].filename
5157 assert os .path .exists (data [filetype ])
5258
59+
60+ @pytest .mark .online
61+ @pytest .mark .parametrize ('filetype' , ('topology' , 'trajectory' ))
62+ def test_nhaa_equilibrium (filetype ):
63+ data = datasets .fetch_nhaa_equilibrium ()
64+
65+ metadata = nhaa_equilibrium .ARCHIVE
66+
67+ assert len (data .DESCR ) == 1475
68+ assert data .DESCR .startswith (".. -*- coding: utf-8 -*-\n \n .. _`nhaa-equilibrium-dataset`:" )
69+
70+ assert os .path .basename (data [filetype ]) == metadata [filetype ].filename
71+ assert os .path .exists (data [filetype ])
72+
73+
74+ @pytest .mark .online
75+ @pytest .mark .parametrize ('filetype' , ('topology' , 'trajectory' ))
76+ def test_CG_fiber (filetype ):
77+ data = datasets .fetch_CG_fiber ()
78+
79+ metadata = CG_fiber .ARCHIVE
80+
81+ assert len (data .DESCR ) == 535
82+ assert data .DESCR .startswith (".. -*- coding: utf-8 -*-\n \n .. _`CG_fiber-dataset`:" )
83+
84+ assert os .path .basename (data [filetype ]) == metadata [filetype ].filename
85+ assert os .path .exists (data [filetype ])
86+
87+
88+ @pytest .mark .online
89+ @pytest .mark .parametrize ('filename' ,
90+ vesicles .METADATA ['vesicle_lib' ]['CONTENTS' ]['structures' ])
91+ def test_vesicles (filename ):
92+ data = datasets .fetch_vesicle_lib ()
93+
94+ metadata = vesicles .METADATA ['vesicle_lib' ]
95+
96+ assert len (data .DESCR ) == 1329
97+ assert data .DESCR .startswith (".. -*- coding: utf-8 -*-\n \n .. _`vesicle-library-dataset`:" )
98+
99+ assert data .N_structures == metadata ['CONTENTS' ]['N_structures' ]
100+ assert data .N_structures == len (metadata ['CONTENTS' ]['structures' ])
101+ assert any (path .endswith (filename ) for path in data .structures )
102+ assert any (os .path .exists (path ) for path in data .structures if path .endswith (filename ))
103+
104+
105+ @pytest .mark .online
106+ @pytest .mark .parametrize ('method,descr_length' ,
107+ (('DIMS' , 1395 ),
108+ ('FRODA' , 1399 )))
109+ @pytest .mark .parametrize ('filetype' , ('topology' , 'trajectories' ))
110+ def test_adk_transitions (method , descr_length , filetype ):
111+ if method == "DIMS" :
112+ data = datasets .fetch_adk_transitions_DIMS ()
113+ elif method == "FRODA" :
114+ data = datasets .fetch_adk_transitions_FRODA ()
115+ else :
116+ raise ValueError ("Unknown adk_transitions method '{}'" .format (method ))
117+
118+ metadata = adk_transitions .METADATA [method ]['CONTENTS' ]
119+
120+ assert len (data .DESCR ) == descr_length
121+ descr_header = (".. -*- coding: utf-8 -*-\n \n "
122+ ".. _`adk-transitions-{}-dataset`:" .format (
123+ method ))
124+ assert data .DESCR .startswith (descr_header )
125+
126+ datafiles = data [filetype ] if isinstance (data [filetype ], list ) \
127+ else [data [filetype ]]
128+ pattern = os .path .join ("*" , metadata [filetype ])
129+
130+ assert all (glob .fnmatch .fnmatch (path , pattern ) for path in datafiles ), \
131+ "not all datafiles {} match {}" .format (datafiles , pattern )
132+ assert all (os .path .exists (path ) for path in datafiles )
0 commit comments