vermouth.pdb.pdb module¶
Provides functions for reading and writing PDB files.
-
class
vermouth.pdb.pdb.
PDBParser
(exclude='SOL', ignh=False, modelidx=1)[source]¶ Bases:
vermouth.parser_utils.LineParser
Parser for PDB files
-
active_molecule
¶ The molecule/model currently being read.
-
molecules
¶ All complete molecules read so far.
- Parameters
exclude (collections.abc.Container[str]) – Container of residue names. Any atom that has a residue name that is in exclude will be skipped.
ignh (bool) – Whether all hydrogen atoms should be skipped
modelidx (int) – Which model to take.
-
static
anisou
(line, lineno=0)¶ Does nothing.
-
atom
(line, lineno=0)¶ Parse an ATOM or HETATM record.
Does nothing.
-
static
caveat
(line, lineno=0)¶ Does nothing.
-
static
cispep
(line, lineno=0)¶ Does nothing.
-
static
compnd
(line, lineno=0)¶ Does nothing.
-
static
cryst1
(line, lineno=0)¶ Does nothing.
-
static
dbref
(line, lineno=0)¶ Does nothing.
-
static
dbref1
(line, lineno=0)¶ Does nothing.
-
static
dbref2
(line, lineno=0)¶ Does nothing.
-
dispatch
(line)[source]¶ Returns the appropriate method for parsing line. This is determined based on the first 6 characters of line.
- Parameters
line (str) –
- Returns
The method to call with the line, and the line number.
- Return type
-
end
(line='', lineno=0)¶ Finish parsing the molecule.
active_molecule
will be appended tomolecules
, and a newactive_molecule
will be made.
-
endmdl
(line='', lineno=0)¶ Finish parsing the molecule.
active_molecule
will be appended tomolecules
, and a newactive_molecule
will be made.
-
static
expdta
(line, lineno=0)¶ Does nothing.
-
finalize
(lineno=0)[source]¶ Finish parsing the file. Process all CONECT records found, and returns a list of molecules.
- Parameters
lineno (int) – The line number (not used).
- Returns
All molecules parsed from this file.
- Return type
-
static
formul
(line, lineno=0)¶ Does nothing.
-
static
header
(line, lineno=0)¶ Does nothing.
-
static
helix
(line, lineno=0)¶ Does nothing.
-
static
het
(line, lineno=0)¶ Does nothing.
-
hetatm
(line, lineno=0)¶ Parse an ATOM or HETATM record.
-
static
hetnam
(line, lineno=0)¶ Does nothing.
-
static
hetsyn
(line, lineno=0)¶ Does nothing.
-
static
jrnl
(line, lineno=0)¶ Does nothing.
-
static
keywds
(line, lineno=0)¶ Does nothing.
-
static
link
(line, lineno=0)¶ Does nothing.
-
static
master
(line, lineno=0)¶ Does nothing.
-
static
mdltyp
(line, lineno=0)¶ Does nothing.
-
model
(line, lineno=0)[source]¶ Parse a MODEL record. If the model is not the same as
modelidx
, this model will not be parsed.
-
static
modres
(line, lineno=0)¶ Does nothing.
-
static
mtrix1
(line, lineno=0)¶ Does nothing.
-
static
mtrix2
(line, lineno=0)¶ Does nothing.
-
static
mtrix3
(line, lineno=0)¶ Does nothing.
-
static
nummdl
(line, lineno=0)¶ Does nothing.
-
static
obslte
(line, lineno=0)¶ Does nothing.
-
static
origx1
(line, lineno=0)¶ Does nothing.
-
static
origx2
(line, lineno=0)¶ Does nothing.
-
static
origx3
(line, lineno=0)¶ Does nothing.
-
static
remark
(line, lineno=0)¶ Does nothing.
-
static
revdat
(line, lineno=0)¶ Does nothing.
-
static
scale1
(line, lineno=0)¶ Does nothing.
-
static
scale2
(line, lineno=0)¶ Does nothing.
-
static
scale3
(line, lineno=0)¶ Does nothing.
-
static
seqadv
(line, lineno=0)¶ Does nothing.
-
static
seqres
(line, lineno=0)¶ Does nothing.
-
static
sheet
(line, lineno=0)¶ Does nothing.
-
static
site
(line, lineno=0)¶ Does nothing.
-
static
source
(line, lineno=0)¶ Does nothing.
-
static
splt
(line, lineno=0)¶ Does nothing.
-
static
sprsde
(line, lineno=0)¶ Does nothing.
-
static
ssbond
(line, lineno=0)¶ Does nothing.
-
ter
(line='', lineno=0)¶ Finish parsing the molecule.
active_molecule
will be appended tomolecules
, and a newactive_molecule
will be made.
-
static
title
(line, lineno=0)¶ Does nothing.
-
-
vermouth.pdb.pdb.
get_not_none
(node, attr, default)[source]¶ Returns
node[attr]
. If it doesn’t exists or isNone
, return default.- Parameters
node (collections.abc.Mapping) –
attr (collections.abc.Hashable) –
default – The value to return if
node[attr]
is eitherNone
, or does not exist.
- Returns
The value of
node[attr]
if it exists and is notNone
, else default.- Return type
-
vermouth.pdb.pdb.
read_pdb
(file_name, exclude='SOL', ignh=False, modelidx=1)[source]¶ Parse a PDB file to create a molecule.
- Parameters
filename (str) – The file to read.
exclude (collections.abc.Container[str]) – Atoms that have one of these residue names will not be included.
ignh (bool) – Whether hydrogen atoms should be ignored.
model (int) – If the PDB file contains multiple models, which one to select.
- Returns
The parsed molecules. Will only contain edges if the PDB file has CONECT records. Either way, might be disconnected.
- Return type
-
vermouth.pdb.pdb.
write_pdb
(system, path, conect=True, omit_charges=True, nan_missing_pos=False)[source]¶ Writes system to path as a PDB formatted string.
- Parameters
system (vermouth.system.System) – The system to write.
path (str) – The file to write to.
conect (bool) – Whether to write CONECT records for the edges.
omit_charges (bool) – Whether charges should be omitted. This is usually a good idea since the PDB format can only deal with integer charges.
nan_missing_pos (bool) – Whether the writing should fail if an atom does not have a position. When set to True, atoms without coordinates will be written with ‘nan’ as coordinates; this will cause the output file to be invalid for most uses. for most use.
See also
:func:write_pdb_string
-
vermouth.pdb.pdb.
write_pdb_string
(system, conect=True, omit_charges=True, nan_missing_pos=False)[source]¶ Describes system as a PDB formatted string. Will create CONECT records from the edges in the molecules in system iff conect is True.
- Parameters
system (vermouth.system.System) – The system to write.
conect (bool) – Whether to write CONECT records for the edges.
omit_charges (bool) – Whether charges should be omitted. This is usually a good idea since the PDB format can only deal with integer charges.
nan_missing_pos (bool) – Wether the writing should fail if an atom does not have a position. When set to True, atoms without coordinates will be written with ‘nan’ as coordinates; this will cause the output file to be invalid for most uses.
- Returns
The system as PDB formatted string.
- Return type