13.1. bpforms package¶
13.1.1. Subpackages¶
13.1.2. Submodules¶
13.1.3. bpforms.__main__ module¶
bpforms command line interface
- Author
Jonathan Karr <karr@mssm.edu>
- Date
2019-01-31
- Copyright
2019, Karr Lab
- License
MIT
-
class
bpforms.__main__.
App
(label=None, **kw)[source]¶ Bases:
cement.core.foundation.App
Command line application
-
class
Meta
[source]¶ Bases:
object
-
handlers
= [<class 'bpforms.__main__.BaseController'>, <class 'bpforms.__main__.ValidateController'>, <class 'bpforms.__main__.GetPropertiesController'>, <class 'bpforms.__main__.GetMajorMicroSpeciesController'>, <class 'bpforms.__main__.BuildAlphabetsController'>, <class 'bpforms.__main__.VizAlphabetController'>, <class 'bpforms.__main__.ExportOntosController'>][source]¶
-
-
class
-
class
bpforms.__main__.
BaseController
(*args, **kw)[source]¶ Bases:
cement.ext.ext_argparse.ArgparseController
Base controller for command line application
-
class
bpforms.__main__.
BuildAlphabetsController
(*args, **kw)[source]¶ Bases:
cement.ext.ext_argparse.ArgparseController
Build DNA, RNA, and protein alphabets from DNAmod, MODOMICS, the PDB Chemical Component Dictionary, RESID, and the RNA Modification Database
-
class
Meta
[source]¶ Bases:
object
-
arguments
= [(['--ph'], {'type': <class 'float'>, 'default': 7.4, 'help': 'pH at which calculate major protonation state of each monomeric form'}), (['--major-tautomer'], {'action': 'store_true', 'default': False, 'help': 'If set, calculate the major tautomer'}), (['--dearomatize'], {'action': 'store_true', 'default': False, 'help': 'If set, dearomatize molecule'}), (['--max-monomers'], {'type': <class 'float'>, 'default': inf, 'help': 'Maximum number of monomeric forms to build. Used for testing'}), (['--alphabet'], {'type': <class 'str'>, 'default': None, 'dest': 'alphabets', 'action': 'append', 'help': 'Id of alphabet to build. Defualt: build all alphabets'})][source]¶
-
description
= 'Build DNA, RNA, and protein alphabets from DNAmod, MODOMICS, the PDB Chemical Component Dictionary, RESID, and the RNA Modification Database'[source]¶
-
-
class
-
class
bpforms.__main__.
ExportOntosController
(*args, **kw)[source]¶ Bases:
cement.ext.ext_argparse.ArgparseController
Export alphabets of residues and ontology of crosslinks to OBO file
-
class
Meta
[source]¶ Bases:
object
-
arguments
= [(['filename'], {'type': <class 'str'>, 'help': 'Path to save ontology'}), (['--alphabet'], {'type': <class 'str'>, 'default': None, 'dest': 'alphabets', 'action': 'append', 'help': 'Id of alphabet to export. Defualt: export all alphabets'}), (['--max-monomers'], {'type': <class 'int'>, 'default': None, 'help': 'Maximum number of monomers to export'}), (['--max-xlinks'], {'type': <class 'int'>, 'default': None, 'help': 'Maximum number of crosslinks to export'})][source]¶
-
-
class
-
class
bpforms.__main__.
GetMajorMicroSpeciesController
(*args, **kw)[source]¶ Bases:
cement.ext.ext_argparse.ArgparseController
Calculate the major protonation and tautomerization
-
class
Meta
[source]¶ Bases:
object
-
arguments
= [(['alphabet'], {'type': <class 'str'>, 'help': 'Biopolymer alphabet'}), (['seq'], {'type': <class 'str'>, 'help': 'Sequence of monomeric forms'}), (['--circular'], {'action': 'store_true', 'default': False, 'help': 'Biopolymer circularity'}), (['ph'], {'type': <class 'float'>, 'help': 'pH'}), (['--major-tautomer'], {'action': 'store_true', 'default': False, 'help': 'If set, calculate the major tautomer'}), (['--dearomatize'], {'action': 'store_true', 'default': False, 'help': 'If set, dearomatize molecule'})][source]¶
-
description
= 'Calculate the major protonation and tautomerization state of a biopolymer form to a specific pH'[source]¶
-
-
class
-
class
bpforms.__main__.
GetPropertiesController
(*args, **kw)[source]¶ Bases:
cement.ext.ext_argparse.ArgparseController
Calculate physical properties such as length, chemical formula, molecular weight, and charge
-
class
Meta
[source]¶ Bases:
object
-
arguments
= [(['alphabet'], {'type': <class 'str'>, 'help': 'Biopolymer alphabet'}), (['seq'], {'type': <class 'str'>, 'help': 'Sequence of monomeric forms'}), (['--circular'], {'action': 'store_true', 'default': False, 'help': 'Biopolymer circularity'}), (['--ph'], {'default': None, 'type': <class 'float'>, 'help': 'pH at which calculate major protonation state of each monomeric form'}), (['--major-tautomer'], {'action': 'store_true', 'default': False, 'help': 'If set, calculate the major tautomer'}), (['--dearomatize'], {'action': 'store_true', 'default': False, 'help': 'If set, dearomatize molecule'})][source]¶
-
description
= 'Calculate physical properties such as length, chemical formula, molecular weight, and charge'[source]¶
-
-
class
-
class
bpforms.__main__.
ValidateController
(*args, **kw)[source]¶ Bases:
cement.ext.ext_argparse.ArgparseController
Validate a biopolymer form
-
class
bpforms.__main__.
VizAlphabetController
(*args, **kw)[source]¶ Bases:
cement.ext.ext_argparse.ArgparseController
Visualize an alphabet
13.1.4. bpforms._version module¶
13.1.5. bpforms.core module¶
Classes to represent modified forms of DNA, RNA, and proteins
- Author
Jonathan Karr <karr@mssm.edu>
- Date
2019-01-31
- Copyright
2019, Karr Lab
- License
MIT
-
class
bpforms.core.
Alphabet
(id=None, name=None, description=None, monomers=None)[source]¶ Bases:
object
Alphabet for monomeric forms
-
from_dict
(dict)[source]¶ Create alphabet from a dictionary representation
- Parameters
dict (
dict
) – dictionary representation of alphabet- Returns
alphabet
- Return type
-
from_yaml
(path)[source]¶ Read alphabet from YAML file
- Parameters
path (
str
) – path to YAML file which defines alphabet- Returns
alphabet
- Return type
-
get_major_micro_species
(ph, major_tautomer=False, dearomatize=False)[source]¶ Calculate the major protonation and tautomerization of each monomeric form
- Parameters
ph (
float
) – pHmajor_tautomer (
bool
, optional) – ifTrue
, calculate the major tautomerdearomatize (
bool
, optional) – ifTrue
, dearomatize molecule
-
get_monomer_code
(monomer)[source]¶ Get the code for a monomeric form in the alphabet
- Parameters
monomer (
Monomer
) – monomeric form- Returns
code for monomeric form
- Return type
str
- Raises
ValueError – if monomeric form is not in alphabet
-
is_equal
(other)[source]¶ Determine two alphabets are semantically equal
- Parameters
other (
type
) – other alphabet- Returns
True, if the alphabets are semantically equal
- Return type
bool
-
property
monomers
[source] Get the monomeric forms
- Returns
monomeric forms
- Return type
-
-
class
bpforms.core.
AlphabetBuilder
(_max_monomers=inf)[source]¶ Bases:
abc.ABC
Builder for alphabets
-
_max_monomers
[source]¶ maximum number of monomeric forms to build; used to limit length of tests
- Type
float
-
abstract
build
(ph=None, major_tautomer=False, dearomatize=False)[source]¶ Build alphabet
- Parameters
ph (
float
, optional) – pH at which to calculate the major protonation state of each monomeric formmajor_tautomer (
bool
, optional) – ifTrue
, calculate the major tautomerdearomatize (
bool
, optional) – ifTrue
, dearomatize molecule
- Returns
alphabet
- Return type
-
run
(ph=None, major_tautomer=False, dearomatize=False, path=None)[source]¶ Build alphabet and, optionally, save to YAML file
- Parameters
ph (
float
, optional) – pH at which to calculate the major protonation state of each monomeric formmajor_tautomer (
bool
, optional) – ifTrue
, calculate the major tautomerdearomatize (
bool
, optional) – ifTrue
, dearomatize moleculepath (
str
, optional) – path to save alphabet
- Returns
alphabet
- Return type
-
-
class
bpforms.core.
Atom
(molecule, element, position=None, charge=0, monomer=None)[source]¶ Bases:
object
An atom in a compound or bond
-
position
[source]¶ position of the atom within the molecule, which should use canonical SMILES atom numbers
- Type
int
-
property
charge
[source] Get the charge
- Returns
charge
- Return type
str
-
property
element
[source] Get the element
- Returns
element
- Return type
str
-
from_dict
(dict)[source]¶ Load from dictionary representation
- Parameters
dict (
dict
) – dictionary representation- Returns
atom
- Return type
-
is_equal
(other)[source]¶ Determine if two atoms are semantically equal
- Parameters
other (
Atom
) – other atom- Returns
obj:True if the atoms are semantically equal
- Return type
bool
-
property
molecule
[source] Get type of parent molecule
- Returns
type of parent molecule
- Return type
type
-
property
monomer
[source] Get the index of the parent monomer within the sequence
- Returns
index of the parent monomer within the sequence
- Return type
int
-
property
position
[source] Get the position
- Returns
position
- Return type
int
-
-
class
bpforms.core.
AtomList
(atoms=None)[source]¶ Bases:
list
List of atoms
-
append
(atom)[source]¶ Add a atom
- Parameters
atom (
Atom
) – atom- Raises
ValueError – if the atom is not an instance of Atom
-
from_list
(list)[source]¶ Load from list representation
- Parameters
list (
list
) – list representation- Returns
atom list
- Return type
-
insert
(i, atom)[source]¶ Insert an atom at a position
- Parameters
i (
int
) – position to insert atomatom (
Atom
) – atom
-
-
class
bpforms.core.
Backbone
(structure=None, monomer_bond_atoms=None, monomer_displaced_atoms=None)[source]¶ Bases:
object
Backbone of a monomeric form
-
export
(format, options=())[source]¶ Export structure to format
- Parameters
format (
str
) – formatoptions (
list
ofstr
, optional) – export options
- Returns
format representation of structure
- Return type
str
-
is_equal
(other)[source]¶ Determine if two backbones are semantically equal
- Parameters
other (
Backbone
) – other backbone- Returns
True
if the backbones are semantically equal- Return type
bool
-
property
monomer_bond_atoms
[source] Get the backbone bond atoms
- Returns
backbone bond atoms
- Return type
-
property
monomer_displaced_atoms
[source] Get the backbone displaced atoms
- Returns
backbone displaced atoms
- Return type
-
property
structure
[source] Get the structure
- Returns
structure
- Return type
openbabel.OBMol
-
-
class
bpforms.core.
Bond
(id=None, name=None, synonyms=None, l_monomer=None, r_monomer=None, l_bond_atoms=None, r_bond_atoms=None, l_displaced_atoms=None, r_displaced_atoms=None, order=<BondOrder.single: 1>, stereo=None, comments=None)[source]¶ Bases:
bpforms.core.BondBase
Bond between monomeric forms (inter-residue bond or crosslink)
-
__str__
()[source]¶ Generate string representation of bond
- Returns
string representation of bond
- Return type
str
-
property
comments
[source] Get comments
- Returns
comments
- Return type
str
-
get_l_displaced_atoms
()[source]¶ Get left displaced atoms
- Returns
left bond atoms
- Return type
list
ofAtom
-
get_r_displaced_atoms
()[source]¶ Get right displaced atoms
- Returns
left bond atoms
- Return type
list
ofAtom
-
property
id
[source] Get id
- Returns
id
- Return type
str
-
is_equal
(other)[source]¶ Determine if two bonds are semantically equal
- Parameters
other (
Bond
) – other bond- Returns
True
if the bond are semantically equal- Return type
bool
-
property
l_displaced_atoms
[source] Get the left displaced atoms
- Returns
left displaced atoms
- Return type
-
property
l_monomer
[source] Get the left monomeric form
- Returns
left monomeric form
- Return type
-
property
name
[source] Get name
- Returns
name
- Return type
str
-
property
r_bond_atoms
[source] Get the right bond atoms
- Returns
right bond atoms
- Return type
-
property
r_displaced_atoms
[source] Get the right displaced atoms
- Returns
right displaced atoms
- Return type
-
property
r_monomer
[source] Get the right monomeric form
- Returns
right monomeric form
- Return type
-
property
stereo
[source] Get the stereochemistry
- Returns
stereochemistry
- Return type
-
property
synonyms
[source] Get synonyms
- Returns
synonyms
- Return type
-
-
class
bpforms.core.
BondBase
[source]¶ Bases:
abc.ABC
-
get_charge
(none_position=True)[source]¶ Get the charge
- Parameters
none_position (
bool
, optional) – include atoms whose position isNone
- Returns
charge
- Return type
int
-
get_formula
(none_position=True)[source]¶ Get the formula
- Parameters
none_position (
bool
, optional) – include atoms whose position isNone
- Returns
formula
- Return type
EmpiricalFormula
-
abstract
get_l_bond_atoms
()[source]¶ Get left bond atoms
- Returns
left bond atoms
- Return type
list
ofAtom
-
abstract
get_l_displaced_atoms
()[source]¶ Get left displaced atoms
- Returns
left bond atoms
- Return type
list
ofAtom
-
get_mol_wt
(none_position=True)[source]¶ Get the molecular weight
- Parameters
none_position (
bool
, optional) – include atoms whose position isNone
- Returns
molecular weight
- Return type
float
-
abstract
get_r_bond_atoms
()[source]¶ Get right bond atoms
- Returns
left bond atoms
- Return type
list
ofAtom
-
abstract
get_r_displaced_atoms
()[source]¶ Get right displaced atoms
- Returns
left bond atoms
- Return type
list
ofAtom
-
-
class
bpforms.core.
BondSet
[source]¶ Bases:
set
Set of bonds
-
add
(bond)[source]¶ Add a bond
- Parameters
bond (
BondBase
) – bond- Raises
ValueError – if the bond is not an instance of Bond
-
is_equal
(other)[source]¶ Check if two sets of bonds are semantically equal
- Parameters
other (
BondSet
) – other set of bonds- Returns
True
, if the bond sets are semantically equal- Return type
bool
-
-
class
bpforms.core.
BpForm
(seq=None, alphabet=None, backbone=None, bond=None, circular=False, crosslinks=None, nicks=None)[source]¶ Bases:
object
Biopolymer form
-
__contains__
(monomer)[source]¶ Determine if a monomeric form is in the biopolymer form
- Parameters
monomer (
Monomer
) – monomeric form- Returns
true if the monomeric form is in the sequence
- Return type
bool
-
__delitem__
(slice)[source]¶ Delete monomeric form(s) at slice
- Parameters
slice (
int
orslice
) – position(s)
-
__getitem__
(slice)[source]¶ Get monomeric form(s) at slice
- Parameters
slice (
int
orslice
) – position(s)- Returns
monomeric form(s)
- Return type
Monomer
orMonomers
-
__iter__
()[source]¶ Get iterator over sequence of monomeric forms
- Returns
iterator of monomeric forms
- Return type
iterator
ofMonomer
-
__reversed__
()[source]¶ Get reverse iterator over sequence of monomeric forms
- Returns
iterator of monomeric forms
- Return type
iterator
ofMonomer
-
__setitem__
(slice, monomer)[source]¶ Set monomeric form(s) at slice
- Parameters
slice (
int
orslice
) – position(s)monomer (
Monomer
orMonomers
) – monomeric forms(s)
-
__str__
()[source]¶ Get a string representation of the biopolymer form
- Returns
string representation of the biopolymer form
- Return type
str
-
can_monomer_bond_left
(monomer)[source]¶ Check if monomeric form can bond to the left
- Parameters
monomer (
Monomer
) – monomeric form- Returns
True
, if the monomeric form can bond to the left- Return type
bool
-
can_monomer_bond_right
(monomer)[source]¶ Check if monomeric form can bond to right
- Parameters
monomer (
Monomer
) – monomeric form- Returns
True
, if the monomeric form can bond to the right- Return type
bool
-
property
circular
[source] Get the circularity
- Returns
circularity
- Return type
bool
-
property
crosslinks
[source] Get the crosslinking intrachain bonds
- Returns
crosslinking intrachain bonds
- Return type
-
diff
(other)[source]¶ Determine the semantic difference between two biopolymer forms
- Parameters
other (
BpForm
) – another biopolymer form- Returns
- description of the semantic difference between
two biopolymer forms
- Return type
str
-
export
(format, include_all_hydrogens=False, options=())[source]¶ Export structure to format
- Parameters
format (
str
) – formatinclude_all_hydrogens (
bool
, optional) – ifTrue
, explicitly include all hydrogensoptions (
list
ofstr
, optional) – export options
- Returns
format representation of structure
- Return type
str
-
property
features
[source] Get the features
- Returns
features
- Return type
-
file
= <_io.TextIOWrapper name='/root/project/bpforms/grammar.lark' mode='r' encoding='UTF-8'>[source]¶
-
from_str
(string)[source]¶ Create biopolymer form its string representation
- Parameters
string (
str
) – string representation of the biopolymer- Returns
biopolymer form
- Return type
-
get_canonical_seq
(monomer_codes=None)[source]¶ Get IUPAC/IUBMB representation of a polymer with bases represented by the character codes of their parent monomers (e.g. methyl-2-adenosine is represented by ‘A’)
- Parameters
monomer_codes (
dict
, optional) – dictionary that maps monomers to their codes- Returns
IUPAC/IUBMB representation of a polymer
- Return type
str
-
get_formula
()[source]¶ Get the chemical formula
- Returns
chemical formula
- Return type
EmpiricalFormula
-
get_genomic_image
(label=None, seq_features=None, **kwargs)[source]¶ Get a genomic visualization of the
BpForm
- Parameters
label (
str
, optional) – titleseq_features (
dict
) –list of features each represented by a dictionary with three keys
label (
str
): description of the type of featurecolor (
str
): colorpositions (
list
oflist
ofint
): list of position ranges of the type of feature
- The method also accepts the same arguments as
- Returns
SVG image
- Return type
str
-
get_image
(monomer_color=0, backbone_color=16711680, left_right_bond_color=65280, crosslink_bond_color=255, include_all_hydrogens=True, show_atom_nums=False, atom_label_font_size=0.6, width=200, height=200, image_format='svg', include_xml_header=True)[source]¶ Get molecular visualization
- Parameters
monomer_color (
int
, optional) – color to paint atoms involved in monomeric formsbackbone_color (
int
, optional) – color to paint atoms involved in backbonesleft_right_bond_color (
int
, optional) – color to paint atoms involved in bond with monomeric form to leftcrosslink_bond_color (
int
, optional) – color to paint atoms involved in crosslinksinclude_all_hydrogens (
bool
, optional) – ifTrue
, show all hydrogensshow_atom_nums (
bool
, optional) – ifTrue
, show the numbers of the atomsatom_label_font_size (
float
, optional) – relative atom label font sizewidth (
int
, optional) – width in pixelsheight (
int
, optional) – height in pixelsimage_format (
str
, optional) – format of generated image {emf, eps, jpeg, msbmp, pdf, png, or svg}include_xml_header (
bool
, optional) – ifTrue
, include XML header at the beginning of the SVG
- Returns
image
- Return type
object
-
get_major_micro_species
(ph, major_tautomer=False, dearomatize=False)[source]¶ Get the major protonation and tautomerization state
- Parameters
ph (
float
) – pHmajor_tautomer (
bool
, optional) – ifTrue
, calculate the major tautomerdearomatize (
bool
, optional) – ifTrue
, dearomatize molecule
- Returns
major protonation and tautomerization state
- Return type
openbabel.OBMol
-
get_monomer_counts
()[source]¶ Get the frequency of each monomeric form within the biopolymer
- Returns
dictionary that maps monomeric forms to their counts
- Return type
dict
-
get_structure
(include_all_hydrogens=False)[source]¶ Get an Open Babel molecule of the structure
- Parameters
include_all_hydrogens (
bool
, optional) – ifTrue
, explicitly include all hydrogens- Returns
openbabel.OBMol
: Open Babel molecule of the structuredict
ofdict
: dictionary which maps indices (1-based) of monomeric formsto dictionaries which map types of components of monomeric forms (‘monomer’ or ‘backbone’) to dictionaries which map indices (1-based) of atoms to atoms (instances of
openbabel.OBAtom
)
- Return type
tuple
-
is_equal
(other)[source]¶ Check if two biopolymer forms are semantically equal
- Parameters
other (
BpForm
) – another biopolymer form- Returns
True
, if the objects have the same structure- Return type
bool
-
property
seq
[source] Get the sequence of monomeric forms
- Returns
sequence of monomeric forms
- Return type
-
validate
()[source]¶ Check that the biopolymer form is valid and return any errors
Check that monomeric forms \(1 \ldots L-1\) can bond to the right (their right bonding attributes are set)
Check that monomeric forms \(2 \ldots L\) can bond to the left (their left bonding attributes are set)
No atom is involved in multiple bonds
- Returns
list of errors, if any
- Return type
list
ofstr
-
-
class
bpforms.core.
BpFormFeature
(form, start_position, end_position)[source]¶ Bases:
object
A region (start and end positions) of a BpForm
-
property
end_position
[source] Get the end position
- Returns
end position
- Return type
int
-
property
start_position
[source] Get the start position
- Returns
start position
- Return type
int
-
property
-
class
bpforms.core.
BpFormFeatureSet
(form)[source]¶ Bases:
set
Set of features
-
add
(feature)[source]¶ Add a feature
- Parameters
feature (
BpFormFeature
) – feature- Raises
ValueError – if the feature is not an instance of BpFormFeature
-
remove
(feature)[source]¶ Remove a feature
- Parameters
feature (
BpFormFeature
) – feature
-
symmetric_difference_update
(other)[source]¶ Remove common elements with other and add elements from other not in self
- Parameters
other (
BpFormFeatureSet
) – other set of features
-
update
(features)[source]¶ Add a set of features
- Parameters
features (iterable of
BpFormFeature
) – features
-
-
class
bpforms.core.
Identifier
(ns, id)[source]¶ Bases:
object
A identifier in a namespace for an external database
-
__eq__
(other)[source]¶ Check if two identifiers are semantically equal
- Parameters
other (
Identifier
) – another identifier- Returns
True, if the identifiers are semantically equal
- Return type
bool
-
property
id
[source] Get the id
- Returns
id
- Return type
str
-
property
ns
[source] Get the namespace
- Returns
namespace
- Return type
str
-
-
class
bpforms.core.
IdentifierSet
(identifiers=None)[source]¶ Bases:
set
Set of identifiers
-
add
(identifier)[source]¶ Add an identifier
- Parameters
identifier (
Identifier
) – identifier- Raises
ValueError – if the identifier is not an instance of Indentifier
-
symmetric_difference_update
(other)[source]¶ Remove common elements with other and add elements from other not in self
- Parameters
other (
IdentifierSet
) – other set of identifiers
-
update
(identifiers)[source]¶ Add a set of identifiers
- Parameters
identifiers (iterable of
Identifier
) – identifiers
-
-
class
bpforms.core.
Monomer
(id=None, name=None, synonyms=None, identifiers=None, structure=None, delta_mass=None, delta_charge=None, start_position=None, end_position=None, monomers_position=None, base_monomers=None, backbone_bond_atoms=None, backbone_displaced_atoms=None, r_bond_atoms=None, l_bond_atoms=None, r_displaced_atoms=None, l_displaced_atoms=None, comments=None)[source]¶ Bases:
object
A monomeric form in a biopolymer
-
identifiers
[source]¶ identifiers in namespaces for external databases
- Type
set
ofIdentifier
, optional
-
monomers_position
[source]¶ originating monomers within
start_position
toend_position
where the monomeric form may be located- Type
set
ofMonomer
-
r_displaced_atoms
[source]¶ atoms displaced by bond with right/suceeding/following/forward monomeric form
- Type
-
l_displaced_atoms
[source]¶ atoms displaced by bond with left/preceding/previous/backward monomeric form
- Type
-
IMAGE_URL_PATTERN
= 'https://cactus.nci.nih.gov/chemical/structure/{}/image?format=gif&bgcolor=transparent&antialiasing=0'[source]¶
-
__str__
(alphabet=None)[source]¶ Get a string representation of the monomeric form
- Parameters
alphabet (
Alphabet
, optional) – alphabet- Returns
string representation of the monomeric form
- Return type
str
-
property
backbone_bond_atoms
[source] Get the atoms from the monomeric form that bond to backbone
- Returns
atoms from the monomeric form that bond to backbone
- Return type
-
property
backbone_displaced_atoms
[source] Get the atoms from the monomeric form displaced by the bond to the backbone
- Returns
atoms from the monomeric form displaced by the bond to the backbone
- Return type
-
property
base_monomers
[source] Get base monomeric forms
- Returns
base monomeric forms
- Return type
set
ofMonomer
-
property
comments
[source] Get comments
- Returns
comments
- Return type
str
-
property
delta_charge
[source] Get extra charge
- Returns
extra charge
- Return type
int
-
property
delta_mass
[source] Get extra mass
- Returns
extra mass
- Return type
float
-
property
end_position
[source] Get end position
- Returns
end position
- Return type
int
-
export
(format, options=())[source]¶ Export structure to format
- Parameters
format (
str
) – formatoptions (
list
ofstr
, optional) – export options
- Returns
format representation of structure
- Return type
str
-
get_canonical_code
(monomer_codes, default_code='?')[source]¶ Get IUPAC/IUBMB representation of a monomeric form using the character code of its parent monomer (e.g. ‘methyl-2-adenosine’ is represented by ‘A’)
- Parameters
monomer_codes (
dict
) – dictionary that maps monomeric forms to codesdefault_code (
str
) – default code
- Returns
IUPAC/IUBMB representation of monomeric form
- Return type
str
-
get_formula
()[source]¶ Get the chemical formula
- Returns
chemical formula
- Return type
EmpiricalFormula
-
get_image
(bond_label='', displaced_label='', bond_opacity=255, displaced_opacity=63, backbone_bond_color=16711680, left_bond_color=65280, right_bond_color=255, include_all_hydrogens=True, show_atom_nums=False, atom_label_font_size=0.6, width=200, height=200, image_format='svg', include_xml_header=True)[source]¶ Get image
- Parameters
bond_label (
str
, optional) – label for atoms involved in bondsdisplaced_label (
str
, optional) – labels for atoms displaced by bond formationbond_opacity (
int
, optional) – opacity of atoms involved in bondsdisplaced_opacity (
int
, optional) – opacity of atoms dislaced by bond formationbackbone_bond_color (
int
, optional) – color to paint atoms involved in bond with backboneleft_bond_color (
int
, optional) – color to paint atoms involved in bond with monomeric form to leftright_bond_color (
int
, optional) – color to paint atoms involved in bond with monomeric form to rightinclude_all_hydrogens (
bool
, optional) – ifTrue
, show all hydrogensshow_atom_nums (
bool
, optional) – ifTrue
, show the numbers of the atomsatom_label_font_size (
float
, optional) – relative atom label font sizewidth (
int
, optional) – width in pixelsheight (
int
, optional) – height in pixelsimage_format (
str
, optional) – format of generated image {emf, eps, jpeg, msbmp, pdf, png, or svg}include_xml_header (
bool
, optional) – ifTrue
, include XML header at the beginning of the SVG
- Returns
image
- Return type
object
-
get_image_url
()[source]¶ Get URL for image of structure
- Returns
URL for image of structure
- Return type
str
-
get_major_micro_species
(ph, major_tautomer=False, dearomatize=False)[source]¶ Update to the major protonation and tautomerization state at the pH
- Parameters
ph (
float
) – pHmajor_tautomer (
bool
, optional) – ifTrue
, calculate the major tautomerdearomatize (
bool
, optional) – ifTrue
, dearomatize molecule
-
get_root_monomers
()[source]¶ Get root monomeric forms
- Returns
root monomeric forms
- Return type
set
ofMonomer
-
property
id
[source] Get id
- Returns
id
- Return type
str
-
property
identifiers
[source] Get identifiers
- Returns
identifiers
- Return type
-
is_equal
(other)[source]¶ Check if two monomeric forms are semantically equal
- Parameters
other (
Monomer
) – another monomeric form- Returns
True
, if the objects have the same structure- Return type
bool
-
property
l_bond_atoms
[source] Get the right bond atoms
- Returns
right bond atoms
- Return type
-
property
l_displaced_atoms
[source] Get the right displaced atoms
- Returns
right displaced atoms
- Return type
-
property
monomers_position
[source] Get the originating monomers within
start_position
toend_position
where the monomeric form may be located- Returns
- originating monomers within
start_position
to end_position
where the monomeric form may be located
- originating monomers within
- Return type
set
ofMonomer
-
property
name
[source] Get name
- Returns
name
- Return type
str
-
property
r_displaced_atoms
[source] Get the left displaced atoms
- Returns
left displaced atoms
- Return type
-
property
start_position
[source] Get start position
- Returns
start position
- Return type
int
-
property
structure
[source] Get structure
- Returns
structure
- Return type
openbabel.OBMol
-
property
synonyms
[source] Get synonyms
- Returns
synonyms
- Return type
-
-
class
bpforms.core.
MonomerDict
(*args, **kwargs)[source]¶ Bases:
attrdict.dictionary.AttrDict
Dictionary for monomeric forms
-
class
bpforms.core.
MonomerSequence
(monomers=None)[source]¶ Bases:
list
Sequence of monomeric forms
-
append
(monomer)[source]¶ Add a monomeric form
- Parameters
monomer (
Monomer
) – monomeric form- Raises
ValueError – if the monomer is not an instance of Monomer
-
extend
(monomers)[source]¶ Add a list of monomeric forms
- Parameters
monomers (iterable of
Monomer
) – iterable of monomeric forms
-
get_monomer_counts
()[source]¶ Get the frequency of each monomeric form within the sequence
- Returns
dictionary that maps monomeric forms to their counts
- Return type
dict
-
insert
(i, monomer)[source]¶ Insert a monomeric form at a position
- Parameters
i (
int
) – position to insert monomeric formmonomer (
Monomer
) – monomeric form
-
is_equal
(other)[source]¶ Determine if two sequences of monomeric forms are semantically equal
- Parameters
other (
MonomerSequence
) – other sequence- Returns
True, of the sequences are semantically equal
- Return type
bool
-
-
class
bpforms.core.
Nick
(position=None)[source]¶ Bases:
object
Nick between adjacent monomeric forms
-
position
[source]¶ position of nick (\(1 \ldots L-1\)) where \(1\) indicates a nick between the first and second residues, \(2\) indicates a nick between the second and third residues, etc.
- Type
int
-
property
position
[source] Get the position
- Returns
position
- Return type
int
-
-
class
bpforms.core.
NickSet
[source]¶ Bases:
set
Set of nicks
-
add
(nick)[source]¶ Add a nick
- Parameters
nick (
Nick
) – nick- Raises
ValueError – if the nick is not an instance of Nick
-
is_equal
(other)[source]¶ Check if two sets of nicks are semantically equal
- Parameters
other (
NickSet
) – other set of nicks- Returns
True
, if the nicks sets are semantically equal- Return type
bool
-
-
class
bpforms.core.
OntoBond
(type=None, l_monomer=None, r_monomer=None)[source]¶ Bases:
bpforms.core.BondBase
A crosslinking bond whose molecular details are defined in an ontology of crosslinks
-
__str__
()[source]¶ Generate string representation of bond
- Returns
string representation of bond
- Return type
str
-
get_l_displaced_atoms
()[source]¶ Get left displaced atoms
- Returns
left bond atoms
- Return type
list
ofAtom
-
get_r_displaced_atoms
()[source]¶ Get right displaced atoms
- Returns
left bond atoms
- Return type
list
ofAtom
-
is_equal
(other)[source]¶ Determine if two bonds are semantically equal
- Parameters
other (
Bond
) – other bond- Returns
True
if the bond are semantically equal- Return type
bool
-
property
l_monomer
[source] Get location of left monomeric form
- Returns
location of left monomeric form
- Return type
int
-
property
r_monomer
[source] Get location of right monomeric form
- Returns
location of right monomeric form
- Return type
int
-
-
class
bpforms.core.
SynonymSet
(synonyms=None)[source]¶ Bases:
set
Set of synonyms
-
add
(synonym)[source]¶ Add an synonym
- Parameters
synonym (
str
) – synonym- Raises
ValueError – if the synonym is not an instance of Indentifier
-
symmetric_difference_update
(other)[source]¶ Remove common synonyms with other and add synonyms from other not in self
- Parameters
other (
SynonymSet
) – other set of synonyms
-
update
(synonyms)[source]¶ Add a set of synonyms
- Parameters
synonyms (iterable of
SynonymSet
) – synonyms
-
-
bpforms.core.
get_hydrogen_atom
(parent_atom, bonding_hydrogens, i_monomer)[source]¶ Get a hydrogen atom attached to a parent atom
- Parameters
parent_atom (
openbabel.OBAtom
) – parent atombonding_hydrogens (
list
) – hydrogens that have already been gotteni_monomer (
int
) – index of parent monomer in sequence
- Returns
hydrogen atom
- Return type
openbabel.OBAtom
13.1.6. bpforms.rest module¶
REST JSON API
- Author
Jonathan Karr <karr@mssm.edu>
- Date
2019-02-05
- Copyright
2019, Karr Lab
- License
MIT
-
class
bpforms.rest.
AlpabetResource
(api=None, *args, **kwargs)[source]¶ Bases:
flask_restplus.resource.Resource
Get alphabets
-
class
bpforms.rest.
AlphabetsResource
(api=None, *args, **kwargs)[source]¶ Bases:
flask_restplus.resource.Resource
Get list of alphabets
-
class
bpforms.rest.
Bpform
(api=None, *args, **kwargs)[source]¶ Bases:
flask_restplus.resource.Resource
Optionally, calculate the major protonation and tautomerization form a biopolymer form and calculate its properties
-
class
bpforms.rest.
MonomerResource
(api=None, *args, **kwargs)[source]¶ Bases:
flask_restplus.resource.Resource
Get information about a monomer
-
bpforms.rest.
get_alphabet
(id)[source]¶ Get an alphabet
- Parameters
id (
str
) – id of alphabet- Returns
dictionary representation of an alphabet
- Return type
dict
-
bpforms.rest.
get_monomer
(alphabet, monomer, format)[source]¶ Get a monomeric form
- Parameters
alphabet (
str
) – id of the alphabetmonomer (
str
) – code of a monomeric formformat (
str
) – output format (“emf”, “eps”, “jpeg”, “json”, “msbmp”, “pdf”, “png” or “svg”)
- Returns
dictionary representation of an monomer or SVG-encoded image of a monomer
- Return type
object
13.1.7. bpforms.util module¶
Utilities for BpForms
- Author
Jonathan Karr <karr@mssm.edu>
- Date
2019-02-05
- Copyright
2019, Karr Lab
- License
MIT
-
bpforms.util.
build_alphabets
(ph=None, major_tautomer=False, dearomatize=False, _max_monomers=inf, alphabets=None)[source]¶ Build DNA, RNA, and protein alphabets
- Parameters
ph (
float
, optional) – pH at which calculate major protonation state of each monomeric formmajor_tautomer (
bool
, optional) – ifTrue
, calculate the major tautomerdearomatize (
bool
, optional) – ifTrue
, dearomatize molecule_max_monomers (
float
, optional) – maximum number of monomeric forms to build; used for testingalphabets (
list
ofstr
orNone
, optional) – ids of alphabets to build. IfNone
, build all alphabets
-
bpforms.util.
export_ontos_to_obo
(alphabets=None, filename=None, _max_monomers=None, _max_xlinks=None)[source]¶ Exports alphabets of residues and ontology of crosslinks to OBO format
- Parameters
alphabets (
list
ofcore.Alphabet
, optional) – alphabets to exportfilename (
str
, optional) – path to export alphabets_max_monomers (
int
, optional) – maximum number of monomers to export_max_xlinks (
int
, optional) – maximum number of crosslinks to export
-
bpforms.util.
gen_genomic_viz
(polymers, inter_crosslinks=None, polymer_labels=None, seq_features=None, width=800, cols=1, polymer_margin=25, nt_per_track=100, track_sep=10, polymer_label_font_size=15, seq_font_size=13, tick_label_font_size=10, legend_font_size=13, tooltip_font_size=13, x_link_stroke_width=2, x_link_radius=4, nick_stroke_width=2, axis_stroke_width=0.5, seq_color='#000000', non_canonical_color='#e74624', intra_x_link_color='#2daae1', inter_x_link_color='#90e227', nick_color='#dabe2e', axis_color='#000000', polymer_label_color='#000000')[source]¶ Get a genomic visualization of the
BpForm
- Parameters
polymers (
list
ofcore.BpForm
) – polymersinter_crosslinks (
list
) – list of inter-polymer crosslinkspolymer_labels (
dict
, optional) – dictionary that maps polymers to their labelsseq_features (
list
ofdict
, optional) –list of features each represented by a dictionary with three keys
label (
str
): description of the type of featurecolor (
str
): colorpositions (
list
ofdict
): dictionary which maps indices of polymers to a list of position ranges of the type of feature
width (
int
, optional) – widthcols (
int
, optional) – number of columns of polymerspolymer_margin (
int
, optional) – horizontal and vertical spacing between polymersnt_per_track (
int
, optional) – number of nucleotides per tracktrack_sep (
int
, optional) – vertical separation between tracks in pixelspolymer_label_font_size (
float
, optional) – font size of polymer labelseq_font_size (
float
, optional) – font size of sequencetick_label_font_size (
float
, optional) – font size of tick labelslegend_font_size (
float
, optional) – font size of legendtooltip_font_size (
float
, optional) – font size of tooltipx_link_stroke_width (
float
, optional) – stroke width of crosslinksx_link_radius (
float
, optional) – radius of crosslinks linenick_stroke_width (
float
, optional) – stroke width of nicksaxis_stroke_width (
float
, optional) – stroke width of axisseq_color (
str
, optional) – color of canonical monomersnon_canonical_color (
str
, optional) – color of non-canonical monomersintra_x_link_color (
str
, optional) – colors of intrastrand crosslinksinter_x_link_color (
str
, optional) – colors of interstrand crosslinksnick_color (
str
, optional) – colors of nicksaxis_color (
str
, optional) – color of axispolymer_label_color (
str
, optional) – color of polymer labels
- Returns
SVG image
- Return type
str
-
bpforms.util.
gen_html_viz_alphabet
(bpform_type, filename)[source]¶ Create and save an HTML document with images of the monomeric forms in an alphabet
- Parameters
bpform_type (
type
) – subclass ofcore.BpForm
filename (
str
) – path to save HTML document with images of monomeric forms
-
bpforms.util.
get_alphabet
(alphabet)[source]¶ Get an alphabet
- Parameters
alphabet (
str
) – alphabet- Returns
alphabet
- Return type
core.Alphabet
-
bpforms.util.
get_alphabets
()[source]¶ Get a list of available alphabets
- Returns
dictionary which maps the ids of alphabets to alphabets
- Return type
dict
-
bpforms.util.
get_form
(alphabet)[source]¶ Get a subclass of BpFrom
- Parameters
alphabet (
str
) – alphabet- Returns
subclass of BpForm
- Return type
type
-
bpforms.util.
read_from_fasta
(filename, alphabet)[source]¶ Read BpForms from a FASTA-formatted file
- Parameters
filename (
str
) – path to FASTA-formatted filealphabet (
str
) – alphabet of BpForms in file
- Returns
- dictionary which maps the ids of molecules to their BpForms-encoded
sequences
- Return type
dict