
org.biojava.nbio.structure.asa.AsaCalculator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of biojava-structure Show documentation
Show all versions of biojava-structure Show documentation
The protein structure modules of BioJava.
/*
* BioJava development code
*
* This code may be freely distributed and modified under the
* terms of the GNU Lesser General Public Licence. This should
* be distributed with the code. If you do not have a copy,
* see:
*
* http://www.gnu.org/copyleft/lesser.html
*
* Copyright for this code is held jointly by the individual
* authors. These should be listed in @author doc comments.
*
* For more information on the BioJava project and its aims,
* or to join the biojava-l mailing list, visit the home page
* at:
*
* http://www.biojava.org/
*
*/
package org.biojava.nbio.structure.asa;
import org.biojava.nbio.structure.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.vecmath.Point3d;
import java.util.ArrayList;
import java.util.TreeMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* Class to calculate Accessible Surface Areas based on
* the rolling ball algorithm by Shrake and Rupley.
*
* The code is adapted from a python implementation at http://boscoh.com/protein/asapy
* (now source is available at https://github.com/boscoh/asa).
* Thanks to Bosco K. Ho for a great piece of code and for his fantastic blog.
*
* See
* Shrake, A., and J. A. Rupley. "Environment and Exposure to Solvent of Protein Atoms.
* Lysozyme and Insulin." JMB (1973) 79:351-371.
* Lee, B., and Richards, F.M. "The interpretation of Protein Structures: Estimation of
* Static Accessibility" JMB (1971) 55:379-400
* @author duarte_j
*
*/
public class AsaCalculator {
private static final Logger logger = LoggerFactory.getLogger(AsaCalculator.class);
// Bosco uses as default 960, Shrake and Rupley seem to use in their paper 92 (not sure if this is actually the same parameter)
public static final int DEFAULT_N_SPHERE_POINTS = 960;
public static final double DEFAULT_PROBE_SIZE = 1.4;
public static final int DEFAULT_NTHREADS = 1;
// Chothia's amino acid atoms vdw radii
public static final double TRIGONAL_CARBON_VDW = 1.76;
public static final double TETRAHEDRAL_CARBON_VDW = 1.87;
public static final double TRIGONAL_NITROGEN_VDW = 1.65;
public static final double TETRAHEDRAL_NITROGEN_VDW = 1.50;
public static final double SULFUR_VDW = 1.85;
public static final double OXIGEN_VDW = 1.40;
// Chothia's nucleotide atoms vdw radii
public static final double NUC_CARBON_VDW = 1.80;
public static final double NUC_NITROGEN_VDW = 1.60;
public static final double PHOSPHOROUS_VDW = 1.90;
private class AsaCalcWorker implements Runnable {
private int i;
private double[] asas;
public AsaCalcWorker(int i, double[] asas) {
this.i = i;
this.asas = asas;
}
@Override
public void run() {
asas[i] = calcSingleAsa(i);
}
}
private Atom[] atoms;
private double[] radii;
private double probe;
private int nThreads;
private Point3d[] spherePoints;
private double cons;
/**
* Constructs a new AsaCalculator. Subsequently call {@link #calculateAsas()}
* or {@link #getGroupAsas()} to calculate the ASAs
* Only non-Hydrogen atoms are considered in the calculation.
* @param structure
* @param probe
* @param nSpherePoints
* @param nThreads
* @param hetAtoms if true HET residues are considered, if false they aren't, equivalent to
* NACCESS' -h option
* @see StructureTools.getAllNonHAtomArray
*/
public AsaCalculator(Structure structure, double probe, int nSpherePoints, int nThreads, boolean hetAtoms) {
this.atoms = StructureTools.getAllNonHAtomArray(structure, hetAtoms);
this.probe = probe;
this.nThreads = nThreads;
// initialising the radii by looking them up through AtomRadii
radii = new double[atoms.length];
for (int i=0;i asas = new TreeMap();
double[] asasPerAtom = calculateAsas();
for (int i=0;i findNeighborIndices(int k) {
// looking at a typical protein case, number of neighbours are from ~10 to ~50, with an average of ~30
// Thus 40 seems to be a good compromise for the starting capacity
ArrayList neighbor_indices = new ArrayList(40);
double radius = radii[k] + probe + probe;
for (int i=0;i neighbor_indices = findNeighborIndices(i);
int n_neighbor = neighbor_indices.size();
int j_closest_neighbor = 0;
double radius = probe + radii[i];
int n_accessible_point = 0;
for (Point3d point: spherePoints){
boolean is_accessible = true;
Point3d test_point = new Point3d(point.x*radius + atom_i.getX(),
point.y*radius + atom_i.getY(),
point.z*radius + atom_i.getZ());
int[] cycled_indices = new int[n_neighbor];
int arind = 0;
for (int ind=j_closest_neighbor;ind
© 2015 - 2025 Weber Informatics LLC | Privacy Policy