Пример #1
0
    def __init__(self, pdb_data, chainA='A', chainB='B'):
        """Compute the burried surface area feature.

        Freesasa is required for this feature.
        From Freesasa version 2.0.3 the Python bindings are released
        as a separate module. They can be installed using
        >>> pip install freesasa

        Args :
            pdb_data (list(byte) or str): pdb data or pdb filename
            chainA (str, optional): name of the first chain
            chainB (str, optional): name of the second chain

        Example :
        >>> bsa = BSA('1AK4.pdb')
        >>> bsa.get_structure()
        >>> bsa.get_contact_residue_sasa()
        >>> bsa.sql._close()
        """
        self.pdb_data = pdb_data
        self.sql = pdb2sql.interface(pdb_data)
        self.chains_label = [chainA, chainB]

        self.feature_data = {}
        self.feature_data_xyz = {}

        freesasa.setVerbosity(freesasa.nowarnings)
Пример #2
0
    def __init__(self,
                 config,
                 wsas_params,
                 tmp_dir,
                 nonstandard_residue_files,
                 nonstandard_residue,
                 ligand_topology,
                 options=None,
                 parameters=None):
        """Wrapper for freesasa

        config: str
            Path to configuration file containing residue composition
            and atomic parameters - freesasa format.
        options: dict, optional
            Options to change how PDBs are parsed by freesasa.
        parameters: dict, optional
            Parameters to alter how freesasa computes surface area.

        """

        # Hide warnings (as the load of multiple structures is two step and
        # extended config is not read in first step).
        freesasa.setVerbosity(1)

        config = self._update_sasa_config(config, wsas_params, tmp_dir,
                                          nonstandard_residue_files,
                                          nonstandard_residue, ligand_topology)

        self.classifier = freesasa.Classifier(bytes(str(config), 'utf-8'))

        self.options = options or _DEFAULT_OPTIONS

        self.parameters = parameters or _DEFAULT_PARAMETERS
Пример #3
0
def calcSASA(Latm, selection):
    """Calcule la surface accessible au solvent (SAS) des acides aminés de la selecion
	Retourne la SAS pour une sélection donnée
	"""
    freesasa.setVerbosity(1)
    structure = freesasa.Structure()
    for a in Latm:
        structure.addAtom(a.ty, a.resname, a.resN, a.chain, a.traj[0],
                          a.traj[1], a.traj[2])
    result = freesasa.calc(structure)
    selections = freesasa.selectArea((selection, 'all, resn ala'), structure,
                                     result)
    return selections[selection.split()[0][:-1]]
Пример #4
0
    def __init__(self,pdb_data,chainA='A',chainB='B'):

        '''Compute the burried surface area feature

        Freesasa is required for this feature.

        Install Freesasa option 1

        >>> git clone https://github.com/mittinatten/freesasa.git
        >>> cd freesasa
        >>> autoconf -i configure.ac``

        Install Freesasa option 2 (preferred)

        >>> wget http://freesasa.github.io/freesasa-2.0.2.tar.gz
        >>> tar -xvf freesasa-2.0.2.tar.gz
        >>> cd freesasa
        >>> ./configure --enable-python-bindings CFLAGS=-fPIC
        >>> make
        >>> make install

        If the install of the python bindings fails because no python (problem with anaconda)

        >>> cd ./bindings/python
        >>> python setup.py install

        Args :
            pdb_data (list(byte) or str): pdb data or filename of the pdb
            chainA (str, optional): name of the first chain
            chainB (str, optional): name of the second chain

        Example :

        >>> bsa = BSA('1AK4.pdb')
        >>> bsa.get_structure()
        >>> bsa.get_contact_residue_sasa()
        >>> bsa.sql.close()

        '''

        self.pdb_data = pdb_data
        self.sql = pdb2sql(pdb_data)
        self.chains_label =  [chainA,chainB]

        self.feature_data = {}
        self.feature_data_xyz = {}


        freesasa.setVerbosity(freesasa.nowarnings)
Пример #5
0
    def calculate_SA_energy(self):
        fs.setVerbosity(fs.nowarnings)
        self.SA_whole, self.SA_obj1, self.SA_obj2 = self.run_freesasa_custom(
            100)

        g = 0.00542  # gamma -> kcal/(mol‚A2)
        b = 0.92  # beta  -> kcal/mol

        energy_whole = (self.SA_whole * g + b)
        energy_obj1 = (self.SA_obj1 * g + b)
        energy_obj2 = (self.SA_obj2 * g + b)

        self.nonpolar_energy = (energy_whole -
                                (energy_obj1 + energy_obj2)) * 4.184  # kJ/mol
        print("Nonpolar Solvation Energy (kJ/mol):", self.nonpolar_energy)
Пример #6
0
    def __init__(self, pdb_data, sqldb=None, chainA='A', chainB='B'):
        '''Compute the burried surface area feature

        Freesasa is required for this feature.

        https://freesasa.github.io

        >>> wget http://freesasa.github.io/freesasa-2.0.2.tar.gz
        >>> tar -xvf freesasa-2.0.3.tar.gz
        >>> cd freesasa
        >>> ./configure CFLAGS=-fPIC (--prefix /home/<user>/)
        >>> make
        >>> make install

        Since release 2.0.3 the python bindings are separate module
        >>> pip install freesasa

        Args :
            pdb_data (list(byte) or str): pdb data or filename of the pdb
            sqldb (pdb2sql.interface instance or None, optional) if the sqldb is None the sqldb will be created
            chainA (str, optional): name of the first chain
            chainB (str, optional): name of the second chain

        Example :

        >>> bsa = BSA('1AK4.pdb')
        >>> bsa.get_structure()
        >>> bsa.get_contact_residue_sasa()
        >>> bsa.sql.close()

        '''

        self.pdb_data = pdb_data
        if sqldb is None:
            self.sql = interface(pdb_data)
        else:
            self.sql = sqldb
        self.chains_label = [chainA, chainB]

        freesasa.setVerbosity(freesasa.nowarnings)
import numpy as np
import rmsd
from Bio.PDB import is_aa, NeighborSearch
from Bio.PDB.Chain import Chain
from Bio.PDB.Entity import Entity
from Bio.PDB.Model import Model
from Bio.PDB.Residue import Residue

from apo_holo_structure_stats.input.download import get_secondary_structure, get_domains
from .base_analyses import CachedAnalyzer, SerializableCachedAnalyzer, SerializableAnalyzer
from .dataclasses import SSForChain, SSForStructure, SetOfResidueData, SetOfResidues, DomainResidueMapping, \
    ScrewMotionResult
from .biopython_to_mmcif import ResidueId

freesasa.setVerbosity(
    freesasa.nowarnings
)  # FreeSASA: warning: guessing that atom 'CB' is symbol ' C' ..., or todo can set a custom classifier?


class AnalysisException(Exception):
    pass


class MissingDataException(AnalysisException):
    """ Can be raised for example as __cause__`d by APIException. """
    pass


def get_hetero_atom_residues(struct: Entity) -> Iterator[Residue]:
    """ non-polymer ligands, excl. water
Пример #8
0
import numpy as np
import freesasa
from freesasa import Structure
from lightdock.scoring.functions import ScoringFunction, ModelAdapter
from lightdock.structure.model import DockingModel
import lightdock.scoring.cpydock.energy.c.cpydock as cpydock
import lightdock.scoring.cpydock.energy.parameters as parameters
from lightdock.util.logger import LoggingManager
import lightdock.scoring.cpydock.data.amber as amber
import lightdock.scoring.cpydock.data.vdw as vdw
import lightdock.scoring.cpydock.data.solvation as solvation
from lightdock.constants import DEFAULT_CONTACT_RESTRAINTS_CUTOFF

log = LoggingManager.get_logger('cpydock')
freesasa.setVerbosity(freesasa.silent)


class CPyDockModel(DockingModel):
    """Prepares the structure necessary for the C-implementation of the pyDock scoring function"""
    def __init__(self,
                 objects,
                 coordinates,
                 restraints,
                 charges,
                 vdw_energy,
                 vdw_radii,
                 des_energy,
                 des_radii,
                 sasa,
                 hydrogens,
Пример #9
0
def	get_DNA_H_SASA(pdb_file,csvfileout,chain=None,resids=[],seq=None,probe_radius=1.4,slicen=100,vdw_set=None,Hcontrib=[1.0]*7,n_threads=1,verbose=False):
	"""
	Function is a warapper to the FREESASA library to calculate the Surface Accessible Surface Area out
	atoms in pdb_file, then expreacts the SASA deoxiribose hydrogen atoms and sums it up
	for every nucleotide with coefficients Hcontrib.
	chain - name of the DNA chain of interest in pdb_file, if chain has no name leave blank ('')
	resids - a list of resids to calculate H-SASA values.
	seq - seqeunce of the DNA strand, string or biopython Seq object.
	Hcontrib - coefficients for individual SASA of deoxyribose hydrogens for summing them up into H-SASA profile,
		order [H1' H2' H2'' H3' H4' H5' H5'']
	Note: chain, resids, seq, Hcontrib - can be also a list of two or more instances,
			to make calculation for several chains, spans of resids or combinations of Hcontrib at once.
			In this case number of elements in chain, resids, Hcontrib should be the same,
			and the algorithm will iterate through all list simultaneously (i.e. no combination will be tried).
			Chains should be of the same length.
	probe_radius - size of probe to roll.
	slicen - number of slices per atom, controls precision of the calculation.
	vdw_set - seleting the set of VdW radii:
		None - default for FREESASA used
		charmm36-rmin - rmin from charmm36 forcefield
		abmer10-rmin - rmin from AMBER10 forcefield


	Return
	--------
	CSV file csvfileout with columns of H-SASA profiles along the sequence.
	"""
	chain=[chain] if isinstance(chain,basestring) else list(chain)
	if len(chain)>1:
		assert len(chain)==len(resids)
		assert len(chain)==len(seq)
		assert len(chain)==len(Hcontrib)
	else:
		resids=[resids]
		seq=[seq]
		Hcontrib=[Hcontrib]

	if not verbose:
		freesasa.setVerbosity(freesasa.nowarnings)
	hatoms=['H1\'','H2\'','H2\'','H3\'','H4\'','H5\'','H5\'\'']

	if vdw_set=='charmm36-rmin':
		#Open config from package in a tricky way, independent of package installation mode
		temp2 = tempfile.NamedTemporaryFile(delete=False)
		conffile = pkgutil.get_data('hydroid', 'pkgdata/charmm36_rmin.config')
		temp2.write(conffile)
		temp2.seek(0)
		temp2.close()
		classifier = freesasa.Classifier(temp2.name)
		os.remove(temp2.name)
		####
		structure = freesasa.Structure(pdb_file,classifier, options={'hydrogen' : True,'hetatm' : True})
	elif vdw_set=='amber10-rmin':
		#Open config from package in a tricky way, independent of package installation mode
		temp2 = tempfile.NamedTemporaryFile(delete=False)
		conffile = pkgutil.get_data('hydroid', 'pkgdata/amber10_rmin.config')
		temp2.write(conffile)
		temp2.seek(0)
		temp2.close()

		classifier = freesasa.Classifier(temp2.name)
		os.remove(temp2.name)
		
		####
		structure = freesasa.Structure(pdb_file,classifier, options={'hydrogen' : True,'hetatm' : True})
	else:
		structure = freesasa.Structure(pdb_file, options={'hydrogen' : True,'hetatm' : True})
	print "Launching FreeSASA calculation..."
	result = freesasa.calc(structure,freesasa.Parameters({'algorithm' : freesasa.LeeRichards,'n-slices' : slicen,'probe-radius':probe_radius,'n-threads':n_threads}))
	# result = freesasa.calc(structure,freesasa.Parameters({'algorithm' : freesasa.ShrakeRupley,'n-slices' : slicen,'n-threads':n_threads}))
	print "Calculation done"
	
	print "Extracting SASA values ..."
	
	res=dict()
	
	for ch,rids,Hcont,i in zip(chain,resids,Hcontrib,range(len(chain))):
		res[i]=pd.Series()

		if (np.array(Hcont)==1.0).all():
		#simplified procedure, we can do it faster: we need to calculate all H-SASA at once
			sels=[]
			for resid in rids:
				if len(ch)>0:
					sels.append('%d,(chain %s) and (resi %s%d) and (name %s)'%(resid, ch,'\\' if resid<0 else '', resid, '+'.join(hatoms)))
				else:
					sels.append('%d,(resi %s%d) and (name %s)'%(resid,'\\' if resid<0 else '', resid, '+'.join(hatoms)))
			selections = freesasa.selectArea(sels,structure, result)
			res[i]=res[i].add(pd.Series(selections)*1.0,fill_value=0)
		else:
		#regular procedure
			for hat,hcont in zip(hatoms,Hcont):
				sels=[]
				if hcont!=0:
					for resid in rids:
						if len(ch)>0:
							sels.append('%d,(chain %s) and (resi %s%d) and (name %s)'%(resid, ch,'\\' if resid<0 else '', resid, hat))
						else:
							sels.append('%d,(resi %s%d) and (name %s)'%(resid,'\\' if resid<0 else '', resid, hat))
				selections = freesasa.selectArea(sels,structure, result)
				res[i]=res[i].add(pd.Series(selections)*float(hcont),fill_value=0)

	for i in range(len(chain)):
		res[i].index=res[i].index.map(int)
		res[i]=res[i].sort_index()
	if len(chain)==1:
		df=pd.DataFrame({'resid':res[0].index,'Site':['%d%s'%(n,l) for n,l in zip(range(1,1+len(seq[0])),seq[0])],'H-SASA':res[0].values})
	else:
		df=pd.DataFrame()
		for ch,i in zip(chain,range(len(chain))):
			# print res[i]
			# print seq[i]
			ndf=pd.DataFrame({'resid_%d'%i:res[i].index,'Site_%d'%i:['%d%s'%(n,l) for n,l in zip(range(1,1+len(seq[i])),seq[i])],'H-SASA_%d'%i:res[i].values})
			df=pd.concat([df,ndf],axis=1)
	print "Outputting H-SASA profile to %s"%csvfileout
	df.to_csv(csvfileout)
Пример #10
0
import click
import freesasa
import pandas as pd

import atom3d.datasets.ppi.neighbors as nb
import atom3d.shard.shard as sh
import atom3d.util.formats as dt

freesasa.setVerbosity(freesasa.nowarnings)


@click.command(help='Find buried surface area (bsa) for entry in sharded.')
@click.argument('sharded_path', type=click.Path())
@click.argument('ensemble')
def compute_all_bsa_main(sharded_path, ensemble):
    sharded = sh.Sharded.load(sharded_path)
    ensemble = sharded.read_ensemble(ensemble)
    _, (bdf0, bdf1, udf0, udf1) = nb.get_subunits(ensemble)
    print(compute_bsa(bdf0, bdf1))


def compute_bsa(df0, df1, asa0=None, asa1=None):
    """Given two subunits, compute bsa."""
    result = {}
    bound = _merge_dfs(df0, df1)
    complex_asa = _compute_asa(bound)
    if asa0 is None:
        asa0 = _compute_asa(df0)
    if asa1 is None:
        asa1 = _compute_asa(df1)
    buried_surface_area = asa0 + asa1 - complex_asa
Пример #11
0
"""

import numpy as np
import freesasa
from freesasa import Structure
from lightdock.scoring.functions import ScoringFunction, ModelAdapter
from lightdock.structure.model import DockingModel
import lightdock.scoring.cpydock.energy.c.cpydock as cpydock
import lightdock.scoring.cpydock.energy.parameters as parameters
from lightdock.util.logger import LoggingManager
import lightdock.scoring.cpydock.data.amber as amber
import lightdock.scoring.cpydock.data.vdw as vdw
import lightdock.scoring.cpydock.data.solvation as solvation

log = LoggingManager.get_logger('cpydock')
freesasa.setVerbosity(freesasa.silent)


class CPyDockModel(DockingModel):
    """Prepares the structure necessary for the C-implementation of the pyDock scoring function"""
    def __init__(self, objects, coordinates, restraints, charges, 
                 vdw_energy, vdw_radii, des_energy, des_radii, sasa, hydrogens,
                 reference_points=None, n_modes=None):
        super(CPyDockModel, self).__init__(objects, coordinates, restraints, reference_points)
        self.charges = charges
        self.vdw_energy = vdw_energy
        self.vdw_radii = vdw_radii
        self.des_energy = des_energy
        self.des_radii = des_radii
        self.sasa = sasa
        self.hydrogens = hydrogens