3. The FileIO Class

3.1. File Types and Formats

scoria can naitvely read and write PDB, PDBQT, and PYM files. It can also read multiframe PDB and PDBQT files. It also has the ability to import information from MDAnalysis objects.

3.2. Function Definitions

class scoria.FileIO.FileIO(parent_molecule_object)

A class for saving and loading molecular data into a scoria.Molecule object.

load_MDAnalysis_into(universe)

Allows import of molecular structure from an MDAnalysis object.

Requires the MDAnalysis library.

Should be called via the wrapper function load_via_MDAnalysis()

Parameters:universe (mdanalysis.universe) – An MDAnalysis universe object to import.
load_pdb_into(filename, bonds_by_distance=True, serial_reindex=True, resseq_reindex=False, is_trajectory=False)

Loads the molecular data contained in a pdb file into the current scoria.Molecule object.

Should be called via the wrapper function load_pdb_into()

Parameters:
  • filename (str) – A string, the filename of the pdb file.
  • bonds_by_distance (bool) – An optional boolean, whether or not to determine atomic bonds based on atom proximity. True by default.
  • serial_reindex (bool) – An optional boolean, whether or not to reindex the pdb serial field. True by default.
  • resseq_reindex (bool) – An optional boolean, whether or not to reindex the pdb resseq field. False by default.
  • is_trajectory (bool) – An optional boolean, whether or not the PDB is multi-frame.
load_pdb_into_using_file_object(file_obj, bonds_by_distance=True, serial_reindex=True, resseq_reindex=False, is_trajectory=False)

Loads molecular data from a python file object (pdb formatted) into the current scoria.Molecule object. Note that most users will want to use the load_pdb_into() function instead, which is identical except that it accepts a filename string instead of a python file object.

Requires the numpy library.

Should be called via the wrapper function load_pdb_into_using_file_object()

Parameters:
  • file_obj (file) – A python file object, containing pdb-formatted data.
  • bonds_by_distance (bool) – An optional boolean, whether or not to determine atomic bonds based on atom proximity. True by default.
  • serial_reindex (bool) – An optional boolean, whether or not to reindex the pdb serial field. True by default.
  • resseq_reindex (bool) – An optional boolean, whether or not to reindex the pdb resseq field. False by default.
  • is_trajectory (bool) – An optional boolean, whether or not the PDB is multi-frame.
load_pdb_trajectory_into(filename, bonds_by_distance=True, serial_reindex=True, resseq_reindex=False)

Loads the molecular data contained in a pdb trajectory file into the current scoria.Molecule object.

Should be called via the wrapper function scoria.Molecule.Molecule.load_pdb_trajectory_into()

Parameters:
  • filename (str) – A string, the filename of the pdb trajectory file.
  • bonds_by_distance (bool) – An optional boolean, whether or not to determine atomic bonds based on atom proximity. True by default.
  • serial_reindex (bool) – An optional boolean, whether or not to reindex the pdb serial field. True by default.
  • resseq_reindex (bool) – An optional boolean, whether or not to reindex the pdb resseq field. False by default.
load_pdb_trajectory_into_using_file_object(file_obj, bonds_by_distance=True, serial_reindex=True, resseq_reindex=False)

Loads molecular data from a python file object (pdb trajectory formatted) into the current scoria.Molecule object. Note that most users will want to use the load_pdb_trajectory_into() function instead, which is identical except that it accepts a filename string instead of a python file object.

Should be called via the wrapper function scoria.Molecule.Molecule.load_pdb_trajectory_into_using_file_object()

Parameters:
  • file_obj (file) – A python file object, containing pdb-formatted trajectory data.
  • bonds_by_distance (bool) – An optional boolean, whether or not to determine atomic bonds based on atom proximity. True by default.
  • serial_reindex (bool) – An optional boolean, whether or not to reindex the pdb serial field. True by default.
  • resseq_reindex (bool) – An optional boolean, whether or not to reindex the pdb resseq field. False by default.
load_pdbqt_into(filename, bonds_by_distance=False, serial_reindex=True, resseq_reindex=False, is_trajectory=False)

Loads the molecular data contained in a pdbqt file into the current scoria.Molecule object. Note that this implementation is incomplete. It doesn’t save atomic charges, for example. The atom types are stored in the “element” and “element_stripped” columns.

Should be called via the wrapper function load_pdbqt_into()

Parameters:
  • filename (str) – A string, the filename of the pdbqt file.
  • bonds_by_distance (bool) – An optional boolean, whether or not to determine atomic bonds based on atom proximity. False by default, unlike for PDB.
  • serial_reindex (bool) – An optional boolean, whether or not to reindex the pdb serial field. True by default.
  • resseq_reindex (bool) – An optional boolean, whether or not to reindex the pdbqt resseq field. False by default.
  • is_trajectory (bool) – An optional boolean, whether or not the PDB is multi-frame. Defaults of False.
load_pdbqt_into_using_file_object(file_obj, bonds_by_distance=False, serial_reindex=True, resseq_reindex=False, is_trajectory=False)

Loads molecular data from a python file object (pdbqt formatted) into the current scoria.Molecule object. Note that most users will want to use the load_pdb_into() function instead, which is identical except that it accepts a filename string instead of a python file object.

Requires the numpy library.

Should be called via the wrapper function load_pdbqt_into_using_file_object()

Parameters:
  • file_obj (file) – A python file object, containing pdb-formatted data.
  • bonds_by_distance (bool) – An optional boolean, whether or not to determine atomic bonds based on atom proximity. False by default, unlike for PDB.
  • serial_reindex (bool) – An optional boolean, whether or not to reindex the pdb serial field. True by default.
  • resseq_reindex (bool) – An optional boolean, whether or not to reindex the pdb resseq field. False by default.
  • is_trajectory (bool) – An optional boolean, whether or not the PDB is multi-frame.
load_pdbqt_trajectory_into(filename, bonds_by_distance=True, serial_reindex=True, resseq_reindex=False)

Loads the molecular data contained in a pdbqt trajectoy file (e.g., an AutoDock Vina output file) into the current scoria.Molecule object.

Should be called via the wrapper function scoria.Molecule.Molecule.load_pdbqt_trajectory_into()

Parameters:
  • filename (str) – A string, the filename of the pdbqt file.
  • bonds_by_distance (bool) – An optional boolean, whether or not to determine atomic bonds based on atom proximity. True by default.
  • serial_reindex (bool) – An optional boolean, whether or not to reindex the pdb serial field. True by default.
  • resseq_reindex (bool) – An optional boolean, whether or not to reindex the pdb resseq field. False by default.
load_pdbqt_trajectory_into_using_file_object(file_obj, bonds_by_distance=True, serial_reindex=True, resseq_reindex=False)

Loads molecular data from a python file object (pdbqt trajectory formatted) into the current scoria.Molecule object. Note that most users will want to use the load_pdbqt_trajectory_into() function instead, which is identical except that it accepts a filename string instead of a python file object.

Should be called via the wrapper function pymolecule.Molecule.Molecule.load_pdbqt_trajectory_into_using_file_object()

Parameters:
  • file_obj (file) – A python file object, containing pdbqt-formatted trajectory data.
  • bonds_by_distance (bool) – An optional boolean, whether or not to determine atomic bonds based on atom proximity. True by default.
  • serial_reindex (bool) – An optional boolean, whether or not to reindex the pdb serial field. True by default.
  • resseq_reindex (bool) – An optional boolean, whether or not to reindex the pdb resseq field. False by default.
load_pym_into(filename)

Loads the molecular data contained in a pym file into the current pymolecule.Molecule object.

Requires the numpy library.

Should be called via the wrapper function load_pym_into()

Parameters:filename (str) – A string, the filename of the pym file.
load_via_MDAnalysis(*args)

Allows import of molecular structure with MDAnalysis.

Requires the MDAnalysis library.

Should be called via the wrapper function load_via_MDAnalysis()

Params *args:Filename, filenames, or list of file names. Used to inizalize a MDAnalysis.Universe object.
save_pdb(filename='', serial_reindex=True, resseq_reindex=False, return_text=False, frame=None)

Saves the molecular data contained in a pymolecule.Molecule object to a pdb file.

Should be called via the wrapper function save_pdb()

Parameters:
  • filename (str) – An string, the filename to use for saving.
  • serial_reindex (bool) – An optional boolean, whether or not to reindex the pdb serial field. True by default.
  • resseq_reindex (bool) – An optional boolean, whether or not to reindex the pdb resseq field. False by default.
  • return_text (bool) – An optional boolean, whether or not to return text instead of writing to a file. If True, the filename variable is ignored.
  • frame (int) – If specified, a single-frame PDB will be generated. If not specified, a multi-frame PDB will be generated if the Molecule has multiple frames. Otherwise, the single existing frame will be used.
Returns:

If return_text is True, a PDB-formatted string. Otherwise, returns nothing.

Return type:

str or None

save_pym(filename, save_bonds=False, save_filename=False, save_remarks=False, save_hierarchy=False, save_coordinates_undo_point=False)

Saves the molecular data contained in a pymolecule.Molecule object to a pym file.

Requires the numpy library.

Should be called via the wrapper function save_pym()

Parameters:
  • filename (str) – An string, the filename to use for saving. (Note that this is actually a directory, not a file.)
  • save_bonds (bool) – An optional boolean, whether or not to save information about atomic bonds. False by default.
  • save_filename (bool) – An optional boolean, whether or not to save the original (pdb) filename. False by default.
  • save_remarks (bool) – An optional boolean, whether or not to save remarks associated with the molecule. False by default.
  • save_hierarchy (bool) – An optional boolean, whether or not to save information about spheres the bound (encompass) the whole molecule, the chains, and the residues. False by default.
  • save_coordinates_undo_point (bool) – An optional boolean, whether or not to save the last coordinate undo point. False by default.