idx
int64
0
63k
question
stringlengths
53
5.28k
target
stringlengths
5
805
59,900
def pdbe_status_code ( code ) : url = 'http://www.ebi.ac.uk/pdbe/entry-files/download/{0}_1.mmol' . format ( code ) r = requests . head ( url = url ) return r . status_code
Check if a PDB code has structure files on the PDBE site .
59,901
def preferred_mmol ( code ) : if code in mmols_numbers . keys ( ) : mmol = mmols_numbers [ code ] [ 1 ] return mmol elif is_obsolete ( code ) : raise ValueError ( 'Obsolete PDB code {0}' . format ( code ) ) else : url_string = "http://www.ebi.ac.uk/pdbe/entry/pdb/{0}/analysis" . format ( code ) r = requests . get ( url...
Get mmol number of preferred biological assembly as listed in the PDBe .
59,902
def current_codes_from_pdb ( ) : url = 'http://www.rcsb.org/pdb/rest/getCurrent' r = requests . get ( url ) if r . status_code == 200 : pdb_codes = [ x . lower ( ) for x in r . text . split ( '"' ) if len ( x ) == 4 ] else : print ( 'Request for {0} failed with status code {1}' . format ( url , r . status_code ) ) retu...
Get list of all PDB codes currently listed in the PDB .
59,903
def mmols ( self ) : mmols_dict = { } mmol_dir = os . path . join ( self . parent_dir , 'structures' ) if not os . path . exists ( mmol_dir ) : os . makedirs ( mmol_dir ) mmol_file_names = [ '{0}_{1}.mmol' . format ( self . code , i ) for i in range ( 1 , self . number_of_mmols + 1 ) ] mmol_files = [ os . path . join (...
Dict of filepaths for all mmol files associated with code .
59,904
def dssps ( self ) : dssps_dict = { } dssp_dir = os . path . join ( self . parent_dir , 'dssp' ) if not os . path . exists ( dssp_dir ) : os . makedirs ( dssp_dir ) for i , mmol_file in self . mmols . items ( ) : dssp_file_name = '{0}.dssp' . format ( os . path . basename ( mmol_file ) ) dssp_file = os . path . join ( ...
Dict of filepaths for all dssp files associated with code .
59,905
def fastas ( self , download = False ) : fastas_dict = { } fasta_dir = os . path . join ( self . parent_dir , 'fasta' ) if not os . path . exists ( fasta_dir ) : os . makedirs ( fasta_dir ) for i , mmol_file in self . mmols . items ( ) : mmol_name = os . path . basename ( mmol_file ) fasta_file_name = '{0}.fasta' . for...
Dict of filepaths for all fasta files associated with code .
59,906
def mmcif ( self ) : mmcif_dir = os . path . join ( self . parent_dir , 'mmcif' ) if not os . path . exists ( mmcif_dir ) : os . makedirs ( mmcif_dir ) mmcif_file_name = '{0}.cif' . format ( self . code ) mmcif_file = os . path . join ( mmcif_dir , mmcif_file_name ) if not os . path . exists ( mmcif_file ) : get_mmcif ...
Filepath for mmcif file associated with code .
59,907
def categories ( self ) : category_dict = { } for ligand in self : if ligand . category in category_dict : category_dict [ ligand . category ] . append ( ligand ) else : category_dict [ ligand . category ] = [ ligand ] return category_dict
Returns the categories of Ligands in LigandGroup .
59,908
def category_count ( self ) : category_dict = self . categories count_dict = { category : len ( category_dict [ category ] ) for category in category_dict } return count_dict
Returns the number of categories in categories .
59,909
def sequence_molecular_weight ( seq ) : if 'X' in seq : warnings . warn ( _nc_warning_str , NoncanonicalWarning ) return sum ( [ residue_mwt [ aa ] * n for aa , n in Counter ( seq ) . items ( ) ] ) + water_mass
Returns the molecular weight of the polypeptide sequence .
59,910
def sequence_molar_extinction_280 ( seq ) : if 'X' in seq : warnings . warn ( _nc_warning_str , NoncanonicalWarning ) return sum ( [ residue_ext_280 [ aa ] * n for aa , n in Counter ( seq ) . items ( ) ] )
Returns the molar extinction coefficient of the sequence at 280 nm .
59,911
def partial_charge ( aa , pH ) : difference = pH - residue_pka [ aa ] if residue_charge [ aa ] > 0 : difference *= - 1 ratio = ( 10 ** difference ) / ( 1 + 10 ** difference ) return ratio
Calculates the partial charge of the amino acid .
59,912
def sequence_charge ( seq , pH = 7.4 ) : if 'X' in seq : warnings . warn ( _nc_warning_str , NoncanonicalWarning ) adj_protein_charge = sum ( [ partial_charge ( aa , pH ) * residue_charge [ aa ] * n for aa , n in Counter ( seq ) . items ( ) ] ) adj_protein_charge += ( partial_charge ( 'N-term' , pH ) * residue_charge [...
Calculates the total charge of the input polypeptide sequence .
59,913
def charge_series ( seq , granularity = 0.1 ) : if 'X' in seq : warnings . warn ( _nc_warning_str , NoncanonicalWarning ) ph_range = numpy . arange ( 1 , 13 , granularity ) charge_at_ph = [ sequence_charge ( seq , ph ) for ph in ph_range ] return ph_range , charge_at_ph
Calculates the charge for pH 1 - 13 .
59,914
def sequence_isoelectric_point ( seq , granularity = 0.1 ) : if 'X' in seq : warnings . warn ( _nc_warning_str , NoncanonicalWarning ) ph_range , charge_at_ph = charge_series ( seq , granularity ) abs_charge_at_ph = [ abs ( ch ) for ch in charge_at_ph ] pi_index = min ( enumerate ( abs_charge_at_ph ) , key = lambda x :...
Calculates the isoelectric point of the sequence for ph 1 - 13 .
59,915
def measure_sidechain_torsion_angles ( residue , verbose = True ) : chi_angles = [ ] aa = residue . mol_code if aa not in side_chain_dihedrals : if verbose : print ( "Amino acid {} has no known side-chain dihedral" . format ( aa ) ) else : for set_atoms in side_chain_dihedrals [ aa ] : required_for_dihedral = set_atoms...
Calculates sidechain dihedral angles for a residue
59,916
def measure_torsion_angles ( residues ) : if len ( residues ) < 2 : torsion_angles = [ ( None , None , None ) ] * len ( residues ) else : torsion_angles = [ ] for i in range ( len ( residues ) ) : if i == 0 : res1 = residues [ i ] res2 = residues [ i + 1 ] omega = None phi = None try : psi = dihedral ( res1 [ 'N' ] . _...
Calculates the dihedral angles for a list of backbone atoms .
59,917
def cc_to_local_params ( pitch , radius , oligo ) : rloc = numpy . sin ( numpy . pi / oligo ) * radius alpha = numpy . arctan ( ( 2 * numpy . pi * radius ) / pitch ) alphaloc = numpy . cos ( ( numpy . pi / 2 ) - ( ( numpy . pi ) / oligo ) ) * alpha pitchloc = ( 2 * numpy . pi * rloc ) / numpy . tan ( alphaloc ) return ...
Returns local parameters for an oligomeric assembly .
59,918
def residues_per_turn ( p ) : cas = p . get_reference_coords ( ) prim_cas = p . primitive . coordinates dhs = [ abs ( dihedral ( cas [ i ] , prim_cas [ i ] , prim_cas [ i + 1 ] , cas [ i + 1 ] ) ) for i in range ( len ( prim_cas ) - 1 ) ] rpts = [ 360.0 / dh for dh in dhs ] rpts . append ( None ) return rpts
The number of residues per turn at each Monomer in the Polymer .
59,919
def polymer_to_reference_axis_distances ( p , reference_axis , tag = True , reference_axis_name = 'ref_axis' ) : if not len ( p ) == len ( reference_axis ) : raise ValueError ( "The reference axis must contain the same number of points " "as the Polymer primitive." ) prim_cas = p . primitive . coordinates ref_points = ...
Returns distances between the primitive of a Polymer and a reference_axis .
59,920
def crick_angles ( p , reference_axis , tag = True , reference_axis_name = 'ref_axis' ) : if not len ( p ) == len ( reference_axis ) : raise ValueError ( "The reference axis must contain the same number of points" " as the Polymer primitive." ) prim_cas = p . primitive . coordinates p_cas = p . get_reference_coords ( )...
Returns the Crick angle for each CA atom in the Polymer .
59,921
def alpha_angles ( p , reference_axis , tag = True , reference_axis_name = 'ref_axis' ) : if not len ( p ) == len ( reference_axis ) : raise ValueError ( "The reference axis must contain the same number of points " "as the Polymer primitive." ) prim_cas = p . primitive . coordinates ref_points = reference_axis . coordi...
Alpha angle calculated using points on the primitive of helix and axis .
59,922
def reference_axis_from_chains ( chains ) : if not len ( set ( [ len ( x ) for x in chains ] ) ) == 1 : raise ValueError ( "All chains must be of the same length" ) coords = [ numpy . array ( chains [ 0 ] . primitive . coordinates ) ] orient_vector = polypeptide_vector ( chains [ 0 ] ) for i , c in enumerate ( chains [...
Average coordinates from a set of primitives calculated from Chains .
59,923
def flip_reference_axis_if_antiparallel ( p , reference_axis , start_index = 0 , end_index = - 1 ) : p_vector = polypeptide_vector ( p , start_index = start_index , end_index = end_index ) if is_acute ( p_vector , reference_axis [ end_index ] - reference_axis [ start_index ] ) : reference_axis = numpy . flipud ( refere...
Flips reference axis if direction opposes the direction of the Polymer .
59,924
def make_primitive ( cas_coords , window_length = 3 ) : if len ( cas_coords ) >= window_length : primitive = [ ] count = 0 for _ in cas_coords [ : - ( window_length - 1 ) ] : group = cas_coords [ count : count + window_length ] average_x = sum ( [ x [ 0 ] for x in group ] ) / window_length average_y = sum ( [ y [ 1 ] f...
Calculates running average of cas_coords with a fixed averaging window_length .
59,925
def make_primitive_smoothed ( cas_coords , smoothing_level = 2 ) : try : s_primitive = make_primitive ( cas_coords ) for x in range ( smoothing_level ) : s_primitive = make_primitive ( s_primitive ) except ValueError : raise ValueError ( 'Smoothing level {0} too high, try reducing the number of rounds' ' or give a long...
Generates smoothed primitive from a list of coordinates .
59,926
def make_primitive_extrapolate_ends ( cas_coords , smoothing_level = 2 ) : try : smoothed_primitive = make_primitive_smoothed ( cas_coords , smoothing_level = smoothing_level ) except ValueError : smoothed_primitive = make_primitive_smoothed ( cas_coords , smoothing_level = smoothing_level - 1 ) if len ( smoothed_primi...
Generates smoothed helix primitives and extrapolates lost ends .
59,927
def extend ( self , ampal_container ) : if isinstance ( ampal_container , AmpalContainer ) : self . _ampal_objects . extend ( ampal_container ) else : raise TypeError ( 'Only AmpalContainer objects may be merged with ' 'an AmpalContainer.' ) return
Extends an AmpalContainer with another AmpalContainer .
59,928
def pdb ( self ) : header_title = '{:<80}\n' . format ( 'HEADER {}' . format ( self . id ) ) data_type = '{:<80}\n' . format ( 'EXPDTA ISAMBARD Model' ) pdb_strs = [ ] for ampal in self : if isinstance ( ampal , Assembly ) : pdb_str = ampal . make_pdb ( header = False , footer = False ) else : pdb_str = ampal . m...
Compiles the PDB strings for each state into a single file .
59,929
def sort_by_tag ( self , tag ) : return AmpalContainer ( sorted ( self , key = lambda x : x . tags [ tag ] ) )
Sorts the AmpalContainer by a tag on the component objects .
59,930
def append ( self , item ) : if isinstance ( item , Polymer ) : self . _molecules . append ( item ) else : raise TypeError ( 'Only Polymer objects can be appended to an Assembly.' ) return
Adds a Polymer to the Assembly .
59,931
def extend ( self , assembly ) : if isinstance ( assembly , Assembly ) : self . _molecules . extend ( assembly ) else : raise TypeError ( 'Only Assembly objects may be merged with an Assembly.' ) return
Extends the Assembly with the contents of another Assembly .
59,932
def get_monomers ( self , ligands = True , pseudo_group = False ) : base_filters = dict ( ligands = ligands , pseudo_group = pseudo_group ) restricted_mol_types = [ x [ 0 ] for x in base_filters . items ( ) if not x [ 1 ] ] in_groups = [ x for x in self . filter_mol_types ( restricted_mol_types ) ] monomers = itertools...
Retrieves all the Monomers from the Assembly object .
59,933
def get_ligands ( self , solvent = True ) : if solvent : ligand_list = [ x for x in self . get_monomers ( ) if isinstance ( x , Ligand ) ] else : ligand_list = [ x for x in self . get_monomers ( ) if isinstance ( x , Ligand ) and not x . is_solvent ] return LigandGroup ( monomers = ligand_list )
Retrieves all ligands from the Assembly .
59,934
def get_atoms ( self , ligands = True , pseudo_group = False , inc_alt_states = False ) : atoms = itertools . chain ( * ( list ( m . get_atoms ( inc_alt_states = inc_alt_states ) ) for m in self . get_monomers ( ligands = ligands , pseudo_group = pseudo_group ) ) ) return atoms
Flat list of all the Atoms in the Assembly .
59,935
def is_within ( self , cutoff_dist , point , ligands = True ) : return find_atoms_within_distance ( self . get_atoms ( ligands = ligands ) , cutoff_dist , point )
Returns all atoms in AMPAL object within cut - off distance from the point .
59,936
def relabel_polymers ( self , labels = None ) : if labels : if len ( self . _molecules ) == len ( labels ) : for polymer , label in zip ( self . _molecules , labels ) : polymer . id = label else : raise ValueError ( 'Number of polymers ({}) and number of labels ({}) must be equal.' . format ( len ( self . _molecules ) ...
Relabels the component Polymers either in alphabetical order or using a list of labels .
59,937
def relabel_atoms ( self , start = 1 ) : counter = start for atom in self . get_atoms ( ligands = True ) : atom . id = counter counter += 1 return
Relabels all Atoms in numerical order offset by the start parameter .
59,938
def make_pdb ( self , ligands = True , alt_states = False , pseudo_group = False , header = True , footer = True ) : base_filters = dict ( ligands = ligands , pseudo_group = pseudo_group ) restricted_mol_types = [ x [ 0 ] for x in base_filters . items ( ) if not x [ 1 ] ] in_groups = [ x for x in self . filter_mol_type...
Generates a PDB string for the Assembly .
59,939
def backbone ( self ) : bb_molecules = [ p . backbone for p in self . _molecules if hasattr ( p , 'backbone' ) ] bb_assembly = Assembly ( bb_molecules , assembly_id = self . id ) return bb_assembly
Generates a new Assembly containing only the backbone atoms .
59,940
def primitives ( self ) : prim_molecules = [ p . primitive for p in self . _molecules if hasattr ( p , 'primitive' ) ] prim_assembly = Assembly ( molecules = prim_molecules , assembly_id = self . id ) return prim_assembly
Generates a new Assembly containing the primitives of each Polymer .
59,941
def sequences ( self ) : seqs = [ x . sequence for x in self . _molecules if hasattr ( x , 'sequence' ) ] return seqs
Returns the sequence of each Polymer in the Assembly as a list .
59,942
def fasta ( self ) : fasta_str = '' max_line_length = 79 for p in self . _molecules : if hasattr ( p , 'sequence' ) : fasta_str += '>{0}:{1}|PDBID|CHAIN|SEQUENCE\n' . format ( self . id . upper ( ) , p . id ) seq = p . sequence split_seq = [ seq [ i : i + max_line_length ] for i in range ( 0 , len ( seq ) , max_line_le...
Generates a FASTA string for the Assembly .
59,943
def get_interaction_energy ( self , assign_ff = True , ff = None , mol2 = False , force_ff_assign = False ) : if not ff : ff = global_settings [ 'buff' ] [ 'force_field' ] if assign_ff : for molecule in self . _molecules : if hasattr ( molecule , 'update_ff' ) : molecule . update_ff ( ff , mol2 = mol2 , force_ff_assign...
Calculates the interaction energy of the AMPAL object .
59,944
def pack_new_sequences ( self , sequences ) : from ampal . pdb_parser import convert_pdb_to_ampal assembly_bb = self . backbone total_seq_len = sum ( [ len ( x ) for x in sequences ] ) total_aa_len = sum ( [ len ( x ) for x in assembly_bb ] ) if total_seq_len != total_aa_len : raise ValueError ( 'Total sequence length ...
Packs a new sequence onto each Polymer in the Assembly using Scwrl4 .
59,945
def repack_all ( self ) : non_na_sequences = [ s for s in self . sequences if ' ' not in s ] self . pack_new_sequences ( non_na_sequences ) return
Repacks the side chains of all Polymers in the Assembly .
59,946
def tag_secondary_structure ( self , force = False ) : for polymer in self . _molecules : if polymer . molecule_type == 'protein' : polymer . tag_secondary_structure ( force = force ) return
Tags each Monomer in the Assembly with it s secondary structure .
59,947
def tag_dssp_solvent_accessibility ( self , force = False ) : for polymer in self . _molecules : polymer . tag_dssp_solvent_accessibility ( force = force ) return
Tags each Monomer in the Assembly with its solvent accessibility .
59,948
def tag_torsion_angles ( self , force = False ) : for polymer in self . _molecules : if polymer . molecule_type == 'protein' : polymer . tag_torsion_angles ( force = force ) return
Tags each Monomer in the Assembly with its torsion angles .
59,949
def tag_ca_geometry ( self , force = False , reference_axis = None , reference_axis_name = 'ref_axis' ) : for polymer in self . _molecules : if polymer . molecule_type == 'protein' : polymer . tag_ca_geometry ( force = force , reference_axis = reference_axis , reference_axis_name = reference_axis_name ) return
Tags each Monomer in the Assembly with its helical geometry .
59,950
def tag_atoms_unique_ids ( self , force = False ) : tagged = [ 'unique_id' in x . tags . keys ( ) for x in self . get_atoms ( ) ] if ( not all ( tagged ) ) or force : for m in self . get_monomers ( ) : for atom_type , atom in m . atoms . items ( ) : atom . tags [ 'unique_id' ] = ( m . unique_id , atom_type ) return
Tags each Atom in the Assembly with its unique_id .
59,951
def convert_pro_to_hyp ( pro ) : with open ( str ( REF_PATH / 'hydroxyproline_ref_1bkv_0_6.pickle' ) , 'rb' ) as inf : hyp_ref = pickle . load ( inf ) align_nab ( hyp_ref , pro ) to_remove = [ 'CB' , 'CG' , 'CD' ] for ( label , atom ) in pro . atoms . items ( ) : if atom . element == 'H' : to_remove . append ( label ) ...
Converts a pro residue to a hydroxypro residue .
59,952
def align_nab ( tar , ref ) : rot_trans_1 = find_transformations ( tar [ 'N' ] . array , tar [ 'CA' ] . array , ref [ 'N' ] . array , ref [ 'CA' ] . array ) apply_trans_rot ( tar , * rot_trans_1 ) rot_ang_ca_cb = dihedral ( tar [ 'CB' ] , ref [ 'CA' ] , ref [ 'N' ] , ref [ 'CB' ] ) tar . rotate ( rot_ang_ca_cb , ref [ ...
Aligns the N - CA and CA - CB vector of the target monomer .
59,953
def apply_trans_rot ( ampal , translation , angle , axis , point , radians = False ) : if not numpy . isclose ( angle , 0.0 ) : ampal . rotate ( angle = angle , axis = axis , point = point , radians = radians ) ampal . translate ( vector = translation ) return
Applies a translation and rotation to an AMPAL object .
59,954
def find_ss_regions_polymer ( polymer , ss ) : if isinstance ( ss , str ) : ss = [ ss [ : ] ] tag_key = 'secondary_structure' monomers = [ x for x in polymer if tag_key in x . tags . keys ( ) ] if len ( monomers ) == 0 : return Assembly ( ) if ( len ( ss ) == 1 ) and ( all ( [ m . tags [ tag_key ] == ss [ 0 ] for m in ...
Returns an Assembly of regions tagged as secondary structure .
59,955
def flat_list_to_polymer ( atom_list , atom_group_s = 4 ) : atom_labels = [ 'N' , 'CA' , 'C' , 'O' , 'CB' ] atom_elements = [ 'N' , 'C' , 'C' , 'O' , 'C' ] atoms_coords = [ atom_list [ x : x + atom_group_s ] for x in range ( 0 , len ( atom_list ) , atom_group_s ) ] atoms = [ [ Atom ( x [ 0 ] , x [ 1 ] ) for x in zip ( ...
Takes a flat list of atomic coordinates and converts it to a Polymer .
59,956
def backbone ( self ) : bb_poly = Polypeptide ( [ x . backbone for x in self . _monomers ] , self . id ) return bb_poly
Returns a new Polymer containing only the backbone atoms .
59,957
def pack_new_sequence ( self , sequence ) : from ampal . pdb_parser import convert_pdb_to_ampal polymer_bb = self . backbone if len ( sequence ) != len ( polymer_bb ) : raise ValueError ( 'Sequence length ({}) does not match Polymer length ({}).' . format ( len ( sequence ) , len ( polymer_bb ) ) ) scwrl_out = pack_sid...
Packs a new sequence onto the polymer using Scwrl4 .
59,958
def sequence ( self ) : seq = [ x . mol_letter for x in self . _monomers ] return '' . join ( seq )
Returns the sequence of the Polymer as a string .
59,959
def backbone_bond_lengths ( self ) : bond_lengths = dict ( n_ca = [ distance ( r [ 'N' ] , r [ 'CA' ] ) for r in self . get_monomers ( ligands = False ) ] , ca_c = [ distance ( r [ 'CA' ] , r [ 'C' ] ) for r in self . get_monomers ( ligands = False ) ] , c_o = [ distance ( r [ 'C' ] , r [ 'O' ] ) for r in self . get_mo...
Dictionary containing backbone bond lengths as lists of floats .
59,960
def backbone_bond_angles ( self ) : bond_angles = dict ( n_ca_c = [ angle_between_vectors ( r [ 'N' ] - r [ 'CA' ] , r [ 'C' ] - r [ 'CA' ] ) for r in self . get_monomers ( ligands = False ) ] , ca_c_o = [ angle_between_vectors ( r [ 'CA' ] - r [ 'C' ] , r [ 'O' ] - r [ 'C' ] ) for r in self . get_monomers ( ligands = ...
Dictionary containing backbone bond angles as lists of floats .
59,961
def tag_secondary_structure ( self , force = False ) : tagged = [ 'secondary_structure' in x . tags . keys ( ) for x in self . _monomers ] if ( not all ( tagged ) ) or force : dssp_out = run_dssp ( self . pdb , path = False ) if dssp_out is None : return dssp_ss_list = extract_all_ss_dssp ( dssp_out , path = False ) fo...
Tags each Residue of the Polypeptide with secondary structure .
59,962
def tag_residue_solvent_accessibility ( self , tag_type = False , tag_total = False , force = False , include_hetatms = False ) : if tag_type : tag_type = tag_type else : tag_type = 'residue_solvent_accessibility' tagged = [ tag_type in x . tags . keys ( ) for x in self . _monomers ] if ( not all ( tagged ) ) or force ...
Tags Residues wirh relative residue solvent accessibility .
59,963
def tag_dssp_solvent_accessibility ( self , force = False ) : tagged = [ 'dssp_acc' in x . tags . keys ( ) for x in self . _monomers ] if ( not all ( tagged ) ) or force : dssp_out = run_dssp ( self . pdb , path = False ) if dssp_out is None : return dssp_acc_list = extract_solvent_accessibility_dssp ( dssp_out , path ...
Tags each Residues Polymer with its solvent accessibility .
59,964
def tag_sidechain_dihedrals ( self , force = False ) : tagged = [ 'chi_angles' in x . tags . keys ( ) for x in self . _monomers ] if ( not all ( tagged ) ) or force : for monomer in self . _monomers : chi_angles = measure_sidechain_torsion_angles ( monomer , verbose = False ) monomer . tags [ 'chi_angles' ] = chi_angle...
Tags each monomer with side - chain dihedral angles
59,965
def tag_torsion_angles ( self , force = False ) : tagged = [ 'omega' in x . tags . keys ( ) for x in self . _monomers ] if ( not all ( tagged ) ) or force : tas = measure_torsion_angles ( self . _monomers ) for monomer , ( omega , phi , psi ) in zip ( self . _monomers , tas ) : monomer . tags [ 'omega' ] = omega monome...
Tags each Monomer of the Polymer with its omega phi and psi torsion angle .
59,966
def tag_ca_geometry ( self , force = False , reference_axis = None , reference_axis_name = 'ref_axis' ) : tagged = [ 'rise_per_residue' in x . tags . keys ( ) for x in self . _monomers ] if ( not all ( tagged ) ) or force : if len ( self ) < 7 : rprs = [ None ] * len ( self ) rocs = [ None ] * len ( self ) rpts = [ Non...
Tags each Residue with rise_per_residue radius_of_curvature and residues_per_turn .
59,967
def valid_backbone_bond_lengths ( self , atol = 0.1 ) : bond_lengths = self . backbone_bond_lengths a1 = numpy . allclose ( bond_lengths [ 'n_ca' ] , [ ideal_backbone_bond_lengths [ 'n_ca' ] ] * len ( self ) , atol = atol ) a2 = numpy . allclose ( bond_lengths [ 'ca_c' ] , [ ideal_backbone_bond_lengths [ 'ca_c' ] ] * l...
True if all backbone bonds are within atol Angstroms of the expected distance .
59,968
def valid_backbone_bond_angles ( self , atol = 20 ) : bond_angles = self . backbone_bond_angles omegas = [ x [ 0 ] for x in measure_torsion_angles ( self ) ] trans = [ 'trans' if ( omega is None ) or ( abs ( omega ) >= 90 ) else 'cis' for omega in omegas ] ideal_n_ca_c = [ ideal_backbone_bond_angles [ x ] [ 'n_ca_c' ] ...
True if all backbone bond angles are within atol degrees of their expected values .
59,969
def backbone ( self ) : try : backbone = OrderedDict ( [ ( 'N' , self . atoms [ 'N' ] ) , ( 'CA' , self . atoms [ 'CA' ] ) , ( 'C' , self . atoms [ 'C' ] ) , ( 'O' , self . atoms [ 'O' ] ) ] ) except KeyError : missing_atoms = filter ( lambda x : x not in self . atoms . keys ( ) , ( 'N' , 'CA' , 'C' , 'O' ) ) raise Key...
Returns a new Residue containing only the backbone atoms .
59,970
def unique_id ( self ) : if self . is_hetero : if self . mol_code == 'HOH' : hetero_flag = 'W' else : hetero_flag = 'H_{0}' . format ( self . mol_code ) else : hetero_flag = ' ' return self . ampal_parent . id , ( hetero_flag , self . id , self . insertion_code )
Generates a tuple that uniquely identifies a Monomer in an Assembly .
59,971
def side_chain_environment ( self , cutoff = 4 , include_neighbours = True , inter_chain = True , include_ligands = False , include_solvent = False ) : if self . mol_code == 'GLY' : return [ self ] side_chain_dict = { x : { y : self . states [ x ] [ y ] for y in self . states [ x ] if self . states [ x ] [ y ] in self ...
Finds Residues with any atom within the cutoff distance of side - chain .
59,972
def load_global_settings ( ) : with open ( settings_path , 'r' ) as settings_f : global global_settings settings_json = json . loads ( settings_f . read ( ) ) if global_settings is None : global_settings = settings_json global_settings [ u'package_path' ] = package_dir else : for k , v in settings_json . items ( ) : if...
Loads settings file containing paths to dependencies and other optional configuration elements .
59,973
def build ( self ) : for i in range ( 2 ) : self . _molecules . append ( self . make_helix ( self . aas [ i ] , self . axis_distances [ i ] , self . z_shifts [ i ] , self . phis [ i ] , self . splays [ i ] , self . off_plane [ i ] ) ) return
Builds a HelixPair using the defined attributes .
59,974
def make_helix ( aa , axis_distance , z_shift , phi , splay , off_plane ) : start = numpy . array ( [ axis_distance , 0 + z_shift , 0 ] ) end = numpy . array ( [ axis_distance , ( aa * 1.52 ) + z_shift , 0 ] ) mid = ( start + end ) / 2 helix = Helix . from_start_and_end ( start , end , aa = aa ) helix . rotate ( splay ...
Builds a helix for a given set of parameters .
59,975
def build ( self ) : self . _molecules = [ ] if self . handedness == 'l' : handedness = - 1 else : handedness = 1 rot_ang = self . rot_ang * handedness for i in range ( self . num_of_repeats ) : dup_unit = copy . deepcopy ( self . repeat_unit ) z = ( self . rise * i ) * numpy . array ( [ 0 , 0 , 1 ] ) dup_unit . transl...
Builds a Solenoid using the defined attributes .
59,976
def from_start_and_end ( cls , start , end , sequence , helix_type = 'b_dna' , phos_3_prime = False ) : start = numpy . array ( start ) end = numpy . array ( end ) instance = cls ( sequence , helix_type = helix_type , phos_3_prime = phos_3_prime ) instance . move_to ( start = start , end = end ) return instance
Generates a helical Polynucleotide that is built along an axis .
59,977
def move_to ( self , start , end ) : start = numpy . array ( start ) end = numpy . array ( end ) if numpy . allclose ( start , end ) : raise ValueError ( 'start and end must NOT be identical' ) translation , angle , axis , point = find_transformations ( self . helix_start , self . helix_end , start , end ) if not numpy...
Moves the Polynucleotide to lie on the start and end vector .
59,978
def fit_heptad_register ( crangles ) : crangles = [ x if x > 0 else 360 + x for x in crangles ] hept_p = [ x * ( 360.0 / 7.0 ) + ( ( 360.0 / 7.0 ) / 2.0 ) for x in range ( 7 ) ] ideal_crangs = [ hept_p [ 0 ] , hept_p [ 2 ] , hept_p [ 4 ] , hept_p [ 6 ] , hept_p [ 1 ] , hept_p [ 3 ] , hept_p [ 5 ] ] full_hept = len ( cr...
Attempts to fit a heptad repeat to a set of Crick angles .
59,979
def gather_layer_info ( self ) : for i in range ( len ( self . cc [ 0 ] ) ) : layer_radii = [ x [ i ] . tags [ 'distance_to_ref_axis' ] for x in self . cc ] self . radii_layers . append ( layer_radii ) layer_alpha = [ x [ i ] . tags [ 'alpha_angle_ref_axis' ] for x in self . cc ] self . alpha_layers . append ( layer_al...
Extracts the tagged coiled - coil parameters for each layer .
59,980
def calc_average_parameters ( parameter_layers ) : mean_layers = [ numpy . mean ( x ) if x [ 0 ] else 0 for x in parameter_layers ] overall_mean = numpy . mean ( [ x for x in mean_layers if x ] ) return mean_layers , overall_mean
Takes a group of equal length lists and averages them across each index .
59,981
def heptad_register ( self ) : base_reg = 'abcdefg' exp_base = base_reg * ( self . cc_len // 7 + 2 ) ave_ca_layers = self . calc_average_parameters ( self . ca_layers ) [ 0 ] [ : - 1 ] reg_fit = fit_heptad_register ( ave_ca_layers ) hep_pos = reg_fit [ 0 ] [ 0 ] return exp_base [ hep_pos : hep_pos + self . cc_len ] , r...
Returns the calculated register of the coiled coil and the fit quality .
59,982
def generate_report ( self ) : lines = [ 'Register Assignment\n-------------------' ] register , fit = self . heptad_register ( ) lines . append ( '{}\n{}\n' . format ( register , '\n' . join ( self . cc . sequences ) ) ) lines . append ( 'Fit Quality - Mean Angular Discrepancy = {:3.2f} (Std Dev = {:3.2f})\n' . format...
Generates a report on the coiled coil parameters .
59,983
def buff_interaction_eval ( cls , specification , sequences , parameters , ** kwargs ) : instance = cls ( specification , sequences , parameters , build_fn = default_build , eval_fn = buff_interaction_eval , ** kwargs ) return instance
Creates optimizer with default build and BUFF interaction eval .
59,984
def rmsd_eval ( cls , specification , sequences , parameters , reference_ampal , ** kwargs ) : eval_fn = make_rmsd_eval ( reference_ampal ) instance = cls ( specification , sequences , parameters , build_fn = default_build , eval_fn = eval_fn , mp_disabled = True , ** kwargs ) return instance
Creates optimizer with default build and RMSD eval .
59,985
def parse_individual ( self , individual ) : scaled_ind = [ ] for i in range ( len ( self . value_means ) ) : scaled_ind . append ( self . value_means [ i ] + ( individual [ i ] * self . value_ranges [ i ] ) ) fullpars = list ( self . arrangement ) for k in range ( len ( self . variable_parameters ) ) : for j in range ...
Converts a deap individual into a full list of parameters .
59,986
def run_opt ( self , pop_size , generations , cores = 1 , plot = False , log = False , log_path = None , run_id = None , store_params = True , ** kwargs ) : self . _cores = cores self . _store_params = store_params self . parameter_log = [ ] self . _model_count = 0 self . halloffame = tools . HallOfFame ( 1 ) self . st...
Runs the optimizer .
59,987
def _make_parameters ( self ) : self . value_means = [ ] self . value_ranges = [ ] self . arrangement = [ ] self . variable_parameters = [ ] current_var = 0 for parameter in self . parameters : if parameter . type == ParameterType . DYNAMIC : self . value_means . append ( parameter . value [ 0 ] ) if parameter . value ...
Converts a list of Parameters into DEAP format .
59,988
def assign_fitnesses ( self , targets ) : self . _evals = len ( targets ) px_parameters = zip ( [ self . specification ] * len ( targets ) , [ self . sequences ] * len ( targets ) , [ self . parse_individual ( x ) for x in targets ] ) if ( self . _cores == 1 ) or ( self . mp_disabled ) : models = map ( self . build_fn ...
Assigns fitnesses to parameters .
59,989
def dynamic ( cls , label , val_mean , val_range ) : return cls ( label , ParameterType . DYNAMIC , ( val_mean , val_range ) )
Creates a static parameter .
59,990
def run_scwrl ( pdb , sequence , path = True ) : if path : with open ( pdb , 'r' ) as inf : pdb = inf . read ( ) pdb = pdb . encode ( ) sequence = sequence . encode ( ) try : with tempfile . NamedTemporaryFile ( delete = False ) as scwrl_tmp , tempfile . NamedTemporaryFile ( delete = False ) as scwrl_seq , tempfile . N...
Runs SCWRL on input PDB strong or path to PDB and a sequence string .
59,991
def parse_scwrl_out ( scwrl_std_out , scwrl_pdb ) : score = re . findall ( r'Total minimal energy of the graph = ([-0-9.]+)' , scwrl_std_out ) [ 0 ] split_scwrl = scwrl_pdb . splitlines ( ) fixed_scwrl = [ ] for line in split_scwrl : if len ( line ) < 80 : line += ' ' * ( 80 - len ( line ) ) if re . search ( r'H?E?T?AT...
Parses SCWRL output and returns PDB and SCWRL score .
59,992
def pack_sidechains ( pdb , sequence , path = False ) : scwrl_std_out , scwrl_pdb = run_scwrl ( pdb , sequence , path = path ) return parse_scwrl_out ( scwrl_std_out , scwrl_pdb )
Packs sidechains onto a given PDB file or string .
59,993
def parse_pdb_file ( self ) : self . pdb_parse_tree = { 'info' : { } , 'data' : { self . state : { } } } try : for line in self . pdb_lines : self . current_line = line record_name = line [ : 6 ] . strip ( ) if record_name in self . proc_functions : self . proc_functions [ record_name ] ( ) else : if record_name not in...
Runs the PDB parser .
59,994
def proc_atom ( self ) : atom_data = self . proc_line_coordinate ( self . current_line ) ( at_type , at_ser , at_name , alt_loc , res_name , chain_id , res_seq , i_code , x , y , z , occupancy , temp_factor , element , charge ) = atom_data a_state = self . pdb_parse_tree [ 'data' ] [ self . state ] res_id = ( res_seq ,...
Processes an ATOM or HETATM record .
59,995
def make_ampal ( self ) : data = self . pdb_parse_tree [ 'data' ] if len ( data ) > 1 : ac = AmpalContainer ( id = self . id ) for state , chains in sorted ( data . items ( ) ) : if chains : ac . append ( self . proc_state ( chains , self . id + '_state_{}' . format ( state + 1 ) ) ) return ac elif len ( data ) == 1 : ...
Generates an AMPAL object from the parse tree .
59,996
def proc_state ( self , state_data , state_id ) : assembly = Assembly ( assembly_id = state_id ) for k , chain in sorted ( state_data . items ( ) ) : assembly . _molecules . append ( self . proc_chain ( chain , assembly ) ) return assembly
Processes a state into an Assembly .
59,997
def proc_chain ( self , chain_info , parent ) : hetatom_filters = { 'nc_aas' : self . check_for_non_canonical } polymer = False chain_labels , chain_data = chain_info chain_label = list ( chain_labels ) [ 0 ] monomer_types = { x [ 2 ] for x in chain_labels if x [ 2 ] } if ( 'P' in monomer_types ) and ( 'N' in monomer_t...
Converts a chain into a Polymer type object .
59,998
def proc_monomer ( self , monomer_info , parent , mon_cls = False ) : monomer_labels , monomer_data = monomer_info if len ( monomer_labels ) > 1 : raise ValueError ( 'Malformed PDB, single monomer id with ' 'multiple labels. {}' . format ( monomer_labels ) ) else : monomer_label = list ( monomer_labels ) [ 0 ] if mon_c...
Processes a records into a Monomer .
59,999
def generate_antisense_sequence ( sequence ) : dna_antisense = { 'A' : 'T' , 'T' : 'A' , 'C' : 'G' , 'G' : 'C' } antisense = [ dna_antisense [ x ] for x in sequence [ : : - 1 ] ] return '' . join ( antisense )
Creates the antisense sequence of a DNA strand .