A small number of functions and classes are included to help organize the data.
- class MDAnalysisData.base.Bunch(**kwargs)
Container object for datasets
Dictionary-like object that exposes its keys as attributes.
>>> b = Bunch(a=1, b=2) >>> b['b'] 2 >>> b.b 2 >>> b.a = 3 >>> b['a'] 3 >>> b.c = 6 >>> b['c'] 6
- MDAnalysisData.base.DEFAULT_DATADIR = '~/MDAnalysis_data'
Default value for the cache directory. It can be changed by setting the environment variable
MDANALYSIS_DATA. The current value should be queried with
Return the path of the MDAnalysisData data dir.
This folder is used by some large dataset loaders to avoid downloading the data several times. By default the data dir is set to a folder named ‘MDAnalysis_data’ in the user’s home directory.
Alternatively, it can be set by the
MDANALYSIS_DATAenvironment variable or programmatically by giving an explicit folder path. The ‘~’ symbol is expanded to the user home folder.
If the folder does not already exist, it is automatically created.
If you want to add your own dataset then you will likely use these functions in your code.
- MDAnalysisData.base.RemoteFileMetadata = <class 'MDAnalysisData.base.RemoteFileMetadata'>
filename: name of the file in the local file system
url: full URL for downloading
checksum: SHA256 (can be generated with
MDAnalysisData.base._sha256(); often it is just as convenient to run the downloader during testing and note the required SHA256 then)
Calculate the sha256 hash of the file at path.
- MDAnalysisData.base._fetch_remote(remote, dirname=None)
Helper function to download a remote dataset into path
Fetch a dataset pointed by remote’s url, save into path using remote’s filename and ensure its integrity based on the SHA256 Checksum of the downloaded file.
remote (RemoteFileMetadata) – Named tuple containing remote dataset meta information: url, filename and checksum
dirname (string) – Directory to save the file to.
file_path – Full path of the created file.
- Return type
- MDAnalysisData.base._read_description(filename, description_dir='descr')
Read the description from restructured text file.
filename (str) – name of the description file under the
All description files are supposed to be stored in the directory description_dir
="descr"that lives in the same directory as the
MDAnalysisData.basemodule file. All descriptions are assumed to be in restructured text format and in UTF-8 encoding.