io.github.WeronikaJargielo.protein_interaction_finder.AminoAromaticInteractionFinder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of protein-interaction-finder Show documentation
Show all versions of protein-interaction-finder Show documentation
Library for finding possible interactions in proteins.
The newest version!
package io.github.WeronikaJargielo.protein_interaction_finder;
import org.biojava.nbio.structure.Atom;
import org.biojava.nbio.structure.Calc;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Function;
final class AminoAromaticInteractionFinder {
private final class Cation {
public final String[] atoms;
public final List aminoAcid;
public final Function> cationFilter;
public final Boolean specialTreatment;
public Cation(String[] atoms, List aminoAcid) {
this.atoms = atoms;
this.aminoAcid = aminoAcid;
this.cationFilter = null;
this.specialTreatment = false;
}
public Cation(String[] atoms, List aminoAcid, Function> cationFilter) {
this.atoms = atoms;
this.aminoAcid = aminoAcid;
this.cationFilter = cationFilter;
this.specialTreatment = true;
}
}
private PdbStructureParser pdbStructureParser;
public AminoAromaticInteractionFinder(PdbStructureParser pdbStructureParser) {
this.pdbStructureParser = pdbStructureParser;
}
final private Function> getHisAtomsIfIsChargedFilter = (cation -> {
List histidineCationsAtoms = new ArrayList<>();
final List foundCE1s = pdbStructureParser.getAtoms(cation.atoms, cation.aminoAcid);
if (foundCE1s.isEmpty()) { return histidineCationsAtoms; }
// If histidine is charged it should have those two hydrogen atom: HD1 and HE2.
final String[] hisHsAtoms = new String[]{"HD1" ,"HE2"};
final List foundHs = pdbStructureParser.getAtoms(hisHsAtoms, cation.aminoAcid);
foundCE1s.forEach(CE1 -> {
final Integer CE1SeqNum = CE1.getGroup().getResidueNumber().getSeqNum();
final String CE1Chain = CE1.getGroup().getChain().getName();
final long counterMatchingHs = foundHs.stream()
.filter(H -> CE1SeqNum.equals(H.getGroup().getResidueNumber().getSeqNum())
&& CE1Chain.equals(H.getGroup().getChain().getName()) )
.count();
if (counterMatchingHs == hisHsAtoms.length) {
histidineCationsAtoms.add(CE1);
}
});
return histidineCationsAtoms;
});
private final List desiredCations = Arrays.asList(new Cation(new String[] {"CZ"}, Arrays.asList(AminoAcidAbbreviations.ARG)),
new Cation(new String[] {"CE1"}, Arrays.asList(AminoAcidAbbreviations.HIS), getHisAtomsIfIsChargedFilter),
new Cation(new String[] {"NZ"}, Arrays.asList(AminoAcidAbbreviations.LYS)),
new Cation(new String[] {"ND2"}, Arrays.asList(AminoAcidAbbreviations.ASN)),
new Cation(new String[] {"NE2"}, Arrays.asList(AminoAcidAbbreviations.GLN)));
public List findAminoAromaticInteractions(AminoAromaticInteractionCriteria criteria) {
List cations = new ArrayList<>();
desiredCations.forEach(cation -> {
if (cation.specialTreatment) {
cations.addAll(cation.cationFilter.apply(cation));
} else {
cations.addAll(pdbStructureParser.getAtoms(cation.atoms, cation.aminoAcid));
}
});
List foundAminoAromaticInteractions = new ArrayList<>();
final ArrayList aromaticRings = pdbStructureParser.getAromaticRings();
aromaticRings.forEach(aromaticRing -> {
cations.forEach(cation -> {
final AminoAromaticInteraction aminoAromaticInteraction = this.obtainAminoAromaticInteraction(cation, aromaticRing, criteria);
if (aminoAromaticInteraction != null) {
foundAminoAromaticInteractions.add(aminoAromaticInteraction);
}
});
});
return foundAminoAromaticInteractions;
}
private AminoAromaticInteraction obtainAminoAromaticInteraction(Atom cation, AromaticRing aromaticRing, AminoAromaticInteractionCriteria criteria) {
final double distanceBtwCationRing = Calc.getDistance(cation, aromaticRing.getRingCentroid());
if ( ! (distanceBtwCationRing > criteria.getMinDistanceBtwCationRing() && distanceBtwCationRing < criteria.getMaxDistanceBtwCationRing())) {
return null;
}
final double polarAngle = aromaticRing.calculatePolarAngleOfAtom(cation);
if ( ! (polarAngle >= criteria.getMinPolarAngle() && polarAngle <= criteria.getMaxPolarAngle())) {
return null;
}
final double azimuthalAngle = aromaticRing.calculateAzimuthalAngleOfAtom(cation);
if ( ! (azimuthalAngle >= criteria.getMinAzimuthalAngle() && azimuthalAngle <= criteria.getMaxAzimuthalAngle())) {
return null;
}
return new AminoAromaticInteraction(aromaticRing.getAminoAcid(),
new AminoAcid(cation.getGroup()),
distanceBtwCationRing, polarAngle, azimuthalAngle);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy