Utils subpackage¶
This is SWAMP: Solving structures With Alpha Membrane Pairs
This module implements useful classes and methods used across all modules in SWAMP
-
SwampLibrary
(*args, **kwargs)[source]¶ SwampLibrary
instance
-
TargetSplit
(*args, **kwargs)[source]¶ TargetSplit
instance
-
ThreadResults
(*args, **kwargs)[source]¶ ThreadResults
instance
-
compress
(fname, out=None)[source]¶ Compress a text file into .gz
Parameters: Returns: compressed file name (str)
-
create_tempfile
(content, mode='w')[source]¶ Create a temporary file with a given set of contents
Parameters: Returns: the path to the temporary file name (str)
-
decompress
(fname, out=None)[source]¶ Decompress a .gz file into text file
Parameters: Returns: the decompressed file name (str)
-
extract_fragment_cmap
(pdb_hierarchy, helices)[source]¶ Method to extract the interhelical contact map of a given pdb file
:param
Structure
pdb_hierarchy: the pdb hierarchy of the fragment :param tuple helices: a nested list with the listed residues numbers of the helices of interest :returns: the contact map with the interhelical contacts (ContactMap
)
-
extract_hierarchy
(full_hierarchy, to_extract, chainID=None)[source]¶ Method to extract a given set of residues from a pdbfile in form of a gemmi structure hierarchy
:param
Structure
full_hierarchy: pdb hierarchy of interest :param tuple to_extract: list with the residue numbers to be extracted :param str chainID: the chain id where the residues to be extracted are located (default None) :returns: a newStructure
hierarchy containing the extracted residues
-
extract_hierarchy_seqnumber
(hierarchy, seq_numbers, chain_id='A')[source]¶ Extract the hierarchy corresponding with a given set of residue sequence numbers. Considers missing residues.
:argument
Structure
hierarchy: original hierarchy to trim :argument tuple seq_numbers: residue sequence number to extract :argument str chain_id: chain where the residues should be extracted from :returns: a newStructure
with the residues of interest:example
>>> import gemmi >>> from swamp.utils import extract_hierarchy_seqnumber >>> hierarchy = gemmi.read_structure('/mnt/sda1/MR_edge_cases/3txt_MR/3txt.pdb') >>> subtrgt_1 = extract_hierarchy_seqnumber(hierarchy, [x for x in range(104 ,125)] + [x for x in range(158, 179)]) >>> subtrgt_1.write_minimal_pdb('/home/filo/test.pdb')
-
extract_interhelical_cmap
(cmap, helices, residues, new_id, score_threshold=0.0)[source]¶ Method to extract the interhelical contacts
:param
ContactMap
cmap: the contact map of interest :param tuple helices: a nested list with the listed residue numbers of the two helices of interest :param str new_id: the new identifies given to the resulting contact map :param float score_threshold: the raw score threshold at which contacts will be included (default 0.0) :returns: inverted_cmap: the contact map containing only the inter-helical contacts between the pair of helices (ContactMap
)
-
get_missing_residues
(header_list)[source]¶ Get a dictionary with the missing residues described in the REMARK section of a pdb file
Parameters: header_list (tuple) – a list with the lines of the header section of the pdb file Returns: a dictionary with the missing residues present in each chain (chain ids are used as keys)
-
invert_contactmap
(cmap)[source]¶ Method to invert a contact map
:param
ContactMap
cmap: the contact map of interest :returns: and inverted_cmap: the contact map corresponding with the inverted sequence (1-res_seq) (ContactMap
)
-
invert_hiearchy
(hierarchy)[source]¶ Method to return the inverted hierarchy (1-res_seq)
:param
Structure
hierarchy: pdb hierarchy to be inverted :returns: theStructure
hierarchy corresponding with the inverted sequence (1-res_seq)
-
merge_hierarchies
(hiearchies, new_chain_id='A', new_model_id='1', renumber=False)[source]¶ Method to merge two given hierarchies into one (same chain and model)
Parameters: Returns: a new
Structure
hierarchy corresponding to the merged input hierarchies
-
merge_into_ensemble
(hierarchies)[source]¶ Method to merge a series of hierarchies into an ensemble where each of the original hierarchies is represented as a model
Parameters: hierarchies (tuple) – the hierarchies that will merged to form an ensemble Returns: a new Structure
hierarchy containing the ensemble
-
renumber_hierarchy
(hierarchy, start=1)[source]¶ Method to renumber a given hierarchy to start in a given value. Renumbered inplace
:param
Structure
hierarchy: pdb hierarchy to be renumbered :param int start: first residue to start renumbering of the hierarchy