BioSimSpace.IO.saveMolecules¶
- BioSimSpace.IO.saveMolecules(filebase, system, fileformat, match_water=True, property_map={}, **kwargs)[source]¶
Save a molecular system to file.
- Parameters:
filebase (str) – The base name of the output files.
system (
System
,Molecule
Molecule
) – The molecular system.fileformat (str, [str]) – The file format (or formats) to save to.
match_water (bool) – Whether to update the naming of water molecules to match the expected convention for the chosen file format. This is useful when a system is being saved to a different file format to that from which it was loaded.
property_map (dict) – A dictionary that maps system “properties” to their user defined values. This allows the user to refer to properties with their own naming scheme, e.g. { “charge” : “my-charge” }
- Returns:
files – The list of files that were generated.
- Return type:
[str]
Examples
Load a molecular system from AMBER coordinate and topology files then try to save it to all supported file formats.
>>> import BioSimSpace as BSS >>> files = BSS.IO.expand(BSS.tutorialUrl(), ["ala.top", "ala.crd"], ".bz2") >>> system = BSS.IO.readMolecules(files) >>> for format in BSS.IO.fileFormats(): ... try: ... BSS.IO.saveMolecules("test", system, format) ... except: ... print("Could not convert to format: '%s'" % format)
Load a molecular system from AMBER coordinate and topology files then try to save it to GROMACS format, mapping and un-mapping the charge property along the way.
>>> import BioSimSpace as BSS >>> files = BSS.IO.expand(BSS.tutorialUrl(), ["ala.top", "ala.crd"], ".bz2") >>> system = BSS.IO.readMolecules(files, property_map={"charge" : "my-charge"}) >>> BSS.IO.saveMolecules("test", system, ["gro87", "grotop"], property_map={"charge" : "my-charge"})