pestifer.psfutil.psfcontents module¶
Definition of the PSFContents class for parsing and managing PSF topology files.
This class reads a PSF file, extracts topology information such as atoms, bonds, angles,
dihedrals, and patches, and provides methods for accessing and manipulating this data.
- class pestifer.psfutil.psfcontents.PSFContents(filename: str, topology_segtypes: list[str] = [], parse_topology: list[str] = [])[source]¶
Bases:
objectA class for parsing and managing PSF topology files. This class reads a PSF file, extracts topology information such as atoms, bonds, angles, dihedrals, and patches, and provides methods for accessing and manipulating this data.
- atoms¶
A list of atoms parsed from the PSF file, represented as instances of the
PSFAtomclass.- Type:
- ssbonds¶
A list of disulfide bonds parsed from the PSF file, represented as instances of the
SSBondclass. These appear in psfgen-generated PSF files as patches of type ‘DISU’.- Type:
- links¶
A list of links parsed from the PSF file, represented as instances of the
Linkclass. These appear in psfgen-generated PSF files as patches recognized as creating covalent bonds between atoms in two different residues OTHER than disulfides.- Type:
- patches¶
A dictionary containing patches defined in the PSF file, where keys are patch types (e.g., ‘NTER’, ‘CTER’) and values are lists of patch definitions.
- Type:
- bonds¶
A list of bonds parsed from the PSF file, represented as instances of the
PSFBondclass. This attribute is only set if theparse_topologyparameter includesbonds.- Type:
PSFBondList, optional
- angles¶
A list of angles parsed from the PSF file, represented as instances of the
PSFAngleclass. This attribute is only set if theparse_topologyparameter includesangles.- Type:
PSFAngleList, optional
- dihedrals¶
A list of dihedrals parsed from the PSF file, represented as instances of the
PSFDihedralclass. This attribute is only set if theparse_topologyparameter includesdihedrals.- Type:
PSFDihedralList, optional
- pairex¶
A list of cross-topology non-bonded pair exclusions parsed from the PSF file, represented as instances of the
PSFPairExclass. Used in the dual-topology alchemical free energy paradigm to suppress interactions between atoms belonging to opposite end-states. This attribute is only set if theparse_topologyparameter includespairex.- Type:
PSFPairExList, optional
- Parameters:
filename (str) – The path to the PSF file to be read.
topology_segtypes (list, optional) – A list of segment types to include in the topology parsing. If provided, only atoms of these segment types will be included in the topology. Default is an empty list, which means all atoms will be included.
parse_topology (list, optional) – A list of topology elements to parse from the PSF file. Possible values are ‘bonds’, ‘angles’, ‘dihedrals’, ‘impropers’, and ‘pairex’. If provided, the class will parse the specified topology elements from the PSF file. Default is an empty list, which means no topology elements will be parsed.
- add_ligands()[source]¶
Add ligands to each atom based on the bonds defined in the PSF file. This method iterates through the atoms and bonds, establishing ligand relationships by adding each bonded atom to the ligand list of the corresponding atom. It ensures that each atom’s ligands are correctly populated based on the bonds defined in the PSF file.
- Raises:
AssertionError – If the bonds attribute is not set or if the atom serial numbers do not match the expected indices.
- apply_atom_logics(inclusion_logics: list[str] = [], exclusion_logics: list[str] = [])[source]¶
Apply inclusion and exclusion logic to the atoms in the PSF contents.
- get_charge()[source]¶
Calculate the total charge of the system by summing the charges of all atoms.
- Returns:
The total charge of the system, calculated as the sum of the charges of all atoms in the PSF file.
- Return type:
- remove_ignored_residues(ignored_residues: ResidueList)[source]¶
Remove ignored residues from the PSF contents.
- Parameters:
ignored_residues (ResidueList) – A list of residues to remove from the PSF contents.
- class pestifer.psfutil.psfcontents.PSFResidue(resname: str = '', resid: pestifer.objs.resid.ResID = <factory>, segname: str = '', atoms: pestifer.psfutil.psfatom.PSFAtomList = <factory>, segtype: str = '')[source]¶
Bases:
object- atoms: PSFAtomList¶
- class pestifer.psfutil.psfcontents.PSFResidueList(initlist=None)[source]¶
Bases:
UserList[PSFResidue]
- class pestifer.psfutil.psfcontents.PSFSegment(segname: str = '', residues: pestifer.psfutil.psfcontents.PSFResidueList = <factory>, commands: list[str] = <factory>, segtype: str = '')[source]¶
Bases:
object- remarkify(remark: PSFSegmentRemark)[source]¶
- residues: PSFResidueList¶
- class pestifer.psfutil.psfcontents.PSFSegmentList(initlist=None)[source]¶
Bases:
UserList[PSFSegment]- remarkify(remarks: PSFSegmentRemarkList)[source]¶
- pestifer.psfutil.psfcontents.get_toppar_from_psf(filename: str)[source]¶
Extracts the topology file names from a PSF file. This function reads the PSF file and looks for lines that contain topology information, specifically those that start with ‘ REMARKS topology’. It collects the unique topology file names and returns them as a list. Such lines are written by the psfgen program, so this function expects to operate on a PSF file generated by psfgen.