use of de.bioforscher.jstructure.model.structure.aminoacid.AminoAcid in project jstructure by JonStargaryen.
the class A05_WriteEarlyFoldingContactCsv method handleInteraction.
private static String handleInteraction(PLIPInteraction plipInteraction) {
AminoAcid aa1 = (AminoAcid) plipInteraction.getPartner1();
AminoAcid aa2 = (AminoAcid) plipInteraction.getPartner2();
String pdbId = aa1.getParentStructure().getProteinIdentifier().getPdbId();
return pdbId + "," + "A" + "," + aa1.getOneLetterCode() + "," + aa1.getFeature(GenericSecondaryStructure.class).getSecondaryStructure().getOneLetterRepresentation() + "," + aa2.getOneLetterCode() + "," + aa2.getFeature(GenericSecondaryStructure.class).getSecondaryStructure().getOneLetterRepresentation() + "," + plipInteraction.getClass().getSimpleName() + "," + (Math.abs(aa1.getResidueIndex() - aa2.getResidueIndex()) > 5 ? "long-range" : "local") + "," + (earlyFoldingResidues.contains(aa1) && earlyFoldingResidues.contains(aa2) ? "efr" : "normal");
}
use of de.bioforscher.jstructure.model.structure.aminoacid.AminoAcid in project jstructure by JonStargaryen.
the class SecondaryStructureAnnotator method calculateHBondEnergy.
/**
* Calculate HBond energy of two groups in cal/mol see Creighton page 147 f
* <p>
* Jeffrey, George A., An introduction to hydrogen bonding, Oxford
* University Press, 1997. categorizes hbonds with donor-acceptor distances
* of 2.2-2.5 å as "strong, mostly covalent", 2.5-3.2 å as
* "moderate, mostly electrostatic", 3.2-4.0 å as "weak,
* electrostatic". Energies are given as 40-14, 15-4, and <4 kcal/mol
* respectively.
* @param residuePair
* @return the energy of this h-bond
*/
private double calculateHBondEnergy(Pair<AminoAcid, AminoAcid> residuePair) {
AminoAcid res1 = residuePair.getLeft();
AminoAcid res2 = residuePair.getRight();
try {
Atom nAtom = res1.getN();
double[] n = nAtom.getCoordinates();
double[] h = res1.getH().getCoordinates();
Atom oAtom = res2.getO();
double[] o = oAtom.getCoordinates();
double[] c = res2.getC().getCoordinates();
double dno = LinearAlgebra.on(o).distance(n);
double dhc = LinearAlgebra.on(c).distance(h);
double dho = LinearAlgebra.on(o).distance(h);
double dnc = LinearAlgebra.on(c).distance(n);
// there seems to be a contact!
if ((dno < MINDIST) || (dhc < MINDIST) || (dnc < MINDIST) || (dno < MINDIST)) {
return HBONDLOWENERGY;
}
double e1 = Q / dho - Q / dhc;
double e2 = Q / dnc - Q / dno;
double energy = e1 + e2;
// Avoid too strong energy
if (energy > HBONDLOWENERGY) {
return energy;
}
return HBONDLOWENERGY;
} catch (NullPointerException e) {
throw new SelectionException("missing backbone atoms for " + residuePair);
}
}
use of de.bioforscher.jstructure.model.structure.aminoacid.AminoAcid in project jstructure by JonStargaryen.
the class SecondaryStructureAnnotator method calculateHBonds.
/**
* Calculate the HBonds between different groups. see Creighton page 147 f
*/
private void calculateHBonds(List<AminoAcid> residues) {
for (int i = 0; i < residues.size() - 1; i++) {
for (int j = i + 1; j < residues.size(); j++) {
AminoAcid res1 = residues.get(i);
AminoAcid res2 = residues.get(j);
try {
double squaredDistance = LinearAlgebra.on(res1.getCa().getCoordinates()).distanceFast(res2.getCa().getCoordinates());
if (squaredDistance > CA_MIN_DIST_SQUARED) {
continue;
}
checkAddHBond(res1, res2);
if (j != (i + 1)) {
checkAddHBond(res2, res1);
}
} catch (NullPointerException e) {
throw new SelectionException("missing alpha carbons for " + res1 + " or " + res2);
}
}
}
}
use of de.bioforscher.jstructure.model.structure.aminoacid.AminoAcid in project jstructure by JonStargaryen.
the class SecondaryStructureAnnotator method trackHBondEnergy.
/**
* Store Hbonds in the Groups. DSSP allows two HBonds per amino acid to
* allow bifurcated bonds.
*/
private void trackHBondEnergy(Pair<AminoAcid, AminoAcid> residuePair, double energy) {
AminoAcid res1 = residuePair.getLeft();
AminoAcid res2 = residuePair.getRight();
if (isProline(res1)) {
logger.debug("Ignore: PRO {}", res1.getResidueNumber());
return;
}
// try to findAny entries or create new ones with coil secondary structure
SecondaryStructure state1 = getState(res1);
SecondaryStructure state2 = getState(res2);
double acc1e = state1.getAccept1().getEnergy();
double acc2e = state1.getAccept2().getEnergy();
double don1e = state2.getDonor1().getEnergy();
double don2e = state2.getDonor2().getEnergy();
// Acceptor: N-H-->O
if (energy < acc1e) {
logger.debug("{} < {}", energy, acc1e);
state1.setAccept2(state1.getAccept1());
HBond bond = new HBond();
bond.setEnergy(energy);
bond.setPartner(res2);
state1.setAccept1(bond);
} else if (energy < acc2e) {
logger.debug("{} < {}", energy, acc2e);
HBond bond = new HBond();
bond.setEnergy(energy);
bond.setPartner(res2);
state1.setAccept2(bond);
}
// The other side of the bond: donor O-->N-H
if (energy < don1e) {
logger.debug("{} < {}", energy, don1e);
state2.setDonor2(state2.getDonor1());
HBond bond = new HBond();
bond.setEnergy(energy);
bond.setPartner(res1);
state2.setDonor1(bond);
} else if (energy < don2e) {
logger.debug("{} < {}", energy, don2e);
HBond bond = new HBond();
bond.setEnergy(energy);
bond.setPartner(res1);
state2.setDonor2(bond);
}
}
use of de.bioforscher.jstructure.model.structure.aminoacid.AminoAcid in project jstructure by JonStargaryen.
the class Demo method test.
@Test
public void test() {
// fetch a structure or load from local PDB if setup
Structure structure = StructureParser.fromPdbId("1brr").parse();
// select a chain
Chain chainB = structure.select().chainId("B").asChain();
// or a residue
AminoAcid aminoAcid1 = chainB.select().residueNumber(60).asAminoAcid();
// and another one
AminoAcid aminoAcid2 = chainB.select().residueNumber(100).asAminoAcid();
// compute their distance
System.out.println("distance of " + aminoAcid1 + " and " + aminoAcid2 + ": " + StandardFormat.format(aminoAcid1.calculate().centroid().distance(aminoAcid2.calculate().centroid())));
// access amino acid-specific atoms
chainB.select().aminoAcids().groupName("TRP").asFilteredGroups().map(Tryptophan.class::cast).map(tryptophan -> tryptophan + " CG position: " + Arrays.toString(tryptophan.getCg().getCoordinates())).forEach(System.out::println);
// compute features on-the-fly and resolve dependencies
// e.g. assign some random value to each amino acid
structure.aminoAcids().forEach(aminoAcid -> aminoAcid.getFeatureContainer().addFeature(new Feature(new Random().nextDouble())));
chainB.aminoAcids().map(aminoAcid -> aminoAcid + " random feature: " + StandardFormat.format(aminoAcid.getFeature(Feature.class).getValue())).forEach(System.out::println);
System.out.println("averages among chains:");
structure.chainsWithAminoAcids().map(chain -> chain.getChainIdentifier() + "'s average random feature: " + StandardFormat.format(chain.aminoAcids().map(aminoAcid -> aminoAcid.getFeature(Feature.class)).mapToDouble(Feature::getValue).average().getAsDouble())).forEach(System.out::println);
}
Aggregations