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
PdbRecord
will get the equivalent slice of the record text, only stripped, and converted toint
orfloat
if 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
PdbRecord
of a given name.Parameters: record_name (str) – record name to search by. Return type: PdbRecord
orNone
if there is no match.
-
get_records_by_name
(record_name)[source]¶ Gets all
PdbRecord
objects of a given name.Parameters: record_name (str) – record name to search by. Returns: list
ofPdbRecord
objects.
-
add_record
(record)[source]¶ Adds a
PdbRecord
to the end of the list of records.Parameters: record (PdbRecord) – The PdbRecord
to add.
-
remove_record
(record)[source]¶ Removes a
PdbRecord
from the list of records.Parameters: record (PdbRecord) – The PdbRecord
to remove.
-
to_pdb_data_file
()[source]¶ Converts the PdbFile to a
PdbDataFile
.
-