molecupy.pdb.pdbfile (PDB File)¶
This module is used to provide a container to the PDB file itself and its records - but not the data contained within them.
-
class
molecupy.pdb.pdbfile.PdbRecord(text, pdb_file=None)[source]¶ Represents the lines, or ‘records’ in a PDB file.
Indexing a
PdbRecordwill get the equivalent slice of the record text, only stripped, and converted tointorfloatif possible. Empty sub-strings will returnNone.Parameters: -
get_as_string(start, end)[source]¶ Indexing a record will automatically convert the value to an integer or float if it can - using this method instead will force it to return a string.
Parameters: - start (int) – The start of the subsection.
- end (int) – The end of the subsection.
Return type: str
-
number()[source]¶ The record’s line number in its associated
PdbFile. If there is no file associated, this will returnNone.Return type: int
-
name(name=None)[source]¶ The record’s name (the first six characters). If a string value is supplied, the name will be set to the new value, and the text will also be updated.
Parameters: name (str) – (optional) A new name to change to. Return type: str
-
content(content=None)[source]¶ The record’s text exlcuding the first six characters. If a string value is supplied, the content will be set to the new value, and the text will also be updated.
Parameters: content (str) – (optional) A new content to change to. Return type: str
-
-
class
molecupy.pdb.pdbfile.PdbFile(file_string='')[source]¶ A PDB File - a representation of the file itself, with no processing of the data it contains (other than reading record names from the start of each line).
Parameters: file_string (str) – The raw text of a PDB file. -
get_record_by_name(record_name)[source]¶ Gets the first
PdbRecordof a given name.Parameters: record_name (str) – record name to search by. Return type: PdbRecordorNoneif there is no match.
-
get_records_by_name(record_name)[source]¶ Gets all
PdbRecordobjects of a given name.Parameters: record_name (str) – record name to search by. Returns: listofPdbRecordobjects.
-
add_record(record)[source]¶ Adds a
PdbRecordto the end of the list of records.Parameters: record (PdbRecord) – The PdbRecordto add.
-
remove_record(record)[source]¶ Removes a
PdbRecordfrom the list of records.Parameters: record (PdbRecord) – The PdbRecordto remove.
-
to_pdb_data_file()[source]¶ Converts the PdbFile to a
PdbDataFile.
-