use of de.bioforscher.jstructure.model.structure.aminoacid.AminoAcid in project jstructure by JonStargaryen.
the class EnergyProfileCalculator method processInternally.
@Override
protected void processInternally(Protein protein) {
final double squaredDistanceCutoff = DEFAULT_INTERACTION_CUTOFF * DEFAULT_INTERACTION_CUTOFF;
final List<AminoAcid> aminoAcids = protein.aminoAcids().collect(Collectors.toList());
for (AminoAcid currentGroup : aminoAcids) {
Optional<Atom> currentGroupBetaCarbon = currentGroup.select().betaCarbonAtoms().asOptionalAtom();
double[] currentGroupCoordinates = currentGroupBetaCarbon.map(Atom::getCoordinates).orElseGet(() -> currentGroup.calculate().centroid().getValue());
double solvation = 0;
double currentGroupSolvationValue = resolve(globularSolvationData, currentGroup);
for (AminoAcid surroundingGroup : aminoAcids) {
if (currentGroup.equals(surroundingGroup)) {
continue;
}
Optional<Atom> surroundingGroupBetaCarbon = surroundingGroup.select().betaCarbonAtoms().asOptionalAtom();
double[] surroundingGroupCoordinates = surroundingGroupBetaCarbon.map(Atom::getCoordinates).orElseGet(() -> surroundingGroup.calculate().centroid().getValue());
if (LinearAlgebra.on(currentGroupCoordinates).distanceFast(surroundingGroupCoordinates) > squaredDistanceCutoff) {
continue;
}
solvation += currentGroupSolvationValue + resolve(globularSolvationData, surroundingGroup);
}
currentGroup.getFeatureContainer().addFeature(new EnergyProfile(this, solvation));
}
}
use of de.bioforscher.jstructure.model.structure.aminoacid.AminoAcid in project jstructure by JonStargaryen.
the class SequenceMotifAnnotator method processInternally.
@Override
protected void processInternally(Protein protein) {
SequenceMotifContainer globalList = new SequenceMotifContainer(this);
protein.chainsWithAminoAcids().forEach(chain -> {
List<AminoAcid> aminoAcids = chain.aminoAcids().collect(Collectors.toList());
aminoAcids.forEach(group -> group.getFeatureContainer().addFeature(new SequenceMotifContainer(this)));
int chainLength = aminoAcids.size();
for (int resNum = 0; resNum < chainLength; resNum++) {
AminoAcid startResidue = aminoAcids.get(resNum);
char startAminoAcid = startResidue.getOneLetterCode().charAt(0);
for (SequenceMotifDefinition candidate : SequenceMotifDefinition.values()) {
int motifLength = Integer.parseInt(candidate.name().substring(2));
char motifStart = candidate.name().charAt(0);
char motifEnd = candidate.name().charAt(1);
if (resNum + motifLength >= chainLength) {
continue;
}
if (startAminoAcid != motifStart) {
continue;
}
AminoAcid endResidue = aminoAcids.get(resNum + motifLength);
if (endResidue.getOneLetterCode().charAt(0) != motifEnd) {
continue;
}
if (startResidue.getResidueNumber().getResidueNumber() + motifLength != endResidue.getResidueNumber().getResidueNumber()) {
continue;
}
List<AminoAcid> residueList = aminoAcids.subList(resNum, resNum + motifLength + 1);
SequenceMotif sequenceMotif = new SequenceMotif(candidate, chain.getChainId().getChainId(), startResidue.getResidueNumber().getResidueNumber(), endResidue.getResidueNumber().getResidueNumber(), residueList.stream().map(AminoAcid::getOneLetterCode).collect(Collectors.joining()));
if (!globalList.containsSequenceMotif(sequenceMotif)) {
globalList.addSequenceMotif(sequenceMotif);
}
logger.debug("found sequence motif: {}", sequenceMotif);
}
}
});
// set global reference to all entries
protein.getFeatureContainer().addFeature(globalList);
}
use of de.bioforscher.jstructure.model.structure.aminoacid.AminoAcid in project jstructure by JonStargaryen.
the class SecondaryStructureAnnotator method findBridges.
/**
* Two nonoverlapping stretches of three residues each, i-1,i,i+1 and
* j-1,j,j+1, form either a parallel or antiparallel bridge, depending on
* which of two basic patterns is matched. We assign a bridge between
* residues i and j if there are two H bonds characteristic of beta-
* structure; in particular:
* <p>
* Parallel Bridge(i,j) =: [Hbond(i-1,j) and Hbond(j,i+1)]
* or [Hbond(j-1,i) and Hbond(i,j+1)]
* <p>
* Antiparallel Bridge(i,j) =: [Hbond(i,j) and Hbond(j,i)]
* or [Hbond(i-1,j+1) and Hbond(j-1,i+1)]
*
* Optimised to use the contact set
*/
private void findBridges(List<AminoAcid> residues, List<BetaBridge> bridges) {
List<int[]> outList = new ArrayList<>();
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 distance = LinearAlgebra.on(res1.getCa().getCoordinates()).distanceFast(res2.getCa().getCoordinates());
if (distance > CA_MIN_DIST_SQUARED) {
continue;
}
// If i>j switch them over
if (i > j) {
// Switch them over
int old = i;
i = j;
j = old;
}
// Only these
if (j < i + 3) {
continue;
}
// If it's the first
if (i == 0) {
continue;
}
if (j == 0) {
continue;
}
// If it's the last
if (i == residues.size() - 1) {
continue;
}
if (j == residues.size() - 1) {
continue;
}
int[] thisPair = new int[] { i, j };
outList.add(thisPair);
} catch (NullPointerException e) {
throw new SelectionException("missing alpha carbons for " + res1 + " or " + res2);
}
}
}
outList.sort((o1, o2) -> {
if (o1[0] < o2[0]) {
return -1;
} else if (o1[0] > o2[0]) {
return +1;
} else {
if (o1[1] < o2[1]) {
return -1;
} else if (o1[1] > o2[1]) {
return +1;
} else {
return 0;
}
}
});
for (int[] p : outList) {
int i = p[0];
int j = p[1];
BridgeType btype = null;
// Now do the bonding
if ((isBonded(residues, i - 1, j) && isBonded(residues, j, i + 1)) || (isBonded(residues, j - 1, i) && isBonded(residues, i, j + 1))) {
btype = BridgeType.PARALLEL;
} else if ((isBonded(residues, i, j) && isBonded(residues, j, i)) || (isBonded(residues, i - 1, j + 1) && (isBonded(residues, j - 1, i + 1)))) {
btype = BridgeType.ANTIPARALLEL;
}
if (btype != null) {
registerBridge(residues, bridges, i, j, btype);
}
}
}
use of de.bioforscher.jstructure.model.structure.aminoacid.AminoAcid in project jstructure by JonStargaryen.
the class SecondaryStructureAnnotator method calculateDihedralAngles.
private void calculateDihedralAngles(List<AminoAcid> residues) {
// Omega: CA-C-N-CA
for (int i = 0; i < residues.size() - 1; i++) {
AminoAcid res1 = residues.get(i);
AminoAcid res2 = residues.get(i + 1);
TorsionAngles torsionAngles = new TorsionAngles(res1, res2);
SecondaryStructure state1 = getState(res1);
SecondaryStructure state2 = getState(res2);
state2.setPhi(torsionAngles.getPhi());
state1.setPsi(torsionAngles.getPsi());
state1.setOmega(torsionAngles.getOmega());
}
}
use of de.bioforscher.jstructure.model.structure.aminoacid.AminoAcid in project jstructure by JonStargaryen.
the class BindingSiteExtractor method handleLine.
private void handleLine(String line, String className, String modeName) {
System.out.println(line);
// map to amino acid family
String aminoAcid = Stream.of(AminoAcid.Family.values()).filter(aminoAcidFamily -> aminoAcidFamily.name().equalsIgnoreCase(line.split(":")[0])).findFirst().map(AminoAcid.Family::getGroupPrototype).map(GroupPrototype::getThreeLetterCode).orElse("Pyr");
int[] residueNumbers = Pattern.compile(", ").splitAsStream(line.split("\\[")[1].split("]")[0]).mapToInt(Integer::valueOf).toArray();
AARSConstants.lines(Paths.get(AARSConstants.MAIN_TABLE_CATALYTIC_PATH)).filter(mainTableLine -> mainTableLine.split(",")[1].equalsIgnoreCase(aminoAcid)).filter(mainTableLine -> mainTableLine.endsWith("1")).forEach(mainTableLine -> {
String[] split = mainTableLine.split(",");
String pdbId = split[2];
String chainId = split[13];
Protein protein = ProteinParser.source(AARSConstants.RENUMBERED_STRUCTURES_PATH + className + "/renumbered_structures/" + pdbId + "_renum.pdb").parse();
String output = "HEADER LIGASE/RNA 15-JUL-99 " + pdbId.toUpperCase() + " " + System.lineSeparator() + protein.select().chainName(chainId).aminoAcids().residueNumber(residueNumbers).asGroupContainer().getPdbRepresentation();
AARSConstants.write(Paths.get(AARSConstants.BINDING_SITE_PATH + className + "/ligand_based/per_type/" + modeName + "/" + aminoAcid.substring(0, 1).toUpperCase() + aminoAcid.substring(1, 3).toLowerCase() + "/" + pdbId + "_" + chainId + "_renum.pdb"), output.getBytes());
});
}
Aggregations