use of de.bioforscher.jstructure.feature.sse.GenericSecondaryStructure in project jstructure by JonStargaryen.
the class A06_WriteStructuralInformationByResidueCsv method handleLine.
private static Optional<String> handleLine(String line) {
try {
System.out.println(line);
String[] split = line.split(";");
String entryId = split[0];
String pdbId = split[1];
List<Integer> experimentIds = Pattern.compile(",").splitAsStream(split[2].replaceAll("\\[", "").replaceAll("]", "")).map(Integer::valueOf).collect(Collectors.toList());
// boolean sane = split[6].equalsIgnoreCase("true");
Structure structure = StructureParser.fromPdbId(pdbId).parse();
Chain chain = structure.chains().findFirst().get();
Path start2foldXml = Start2FoldConstants.XML_DIRECTORY.resolve(entryId + ".xml");
Start2FoldXmlParser.parseStability(chain, start2foldXml);
Start2FoldXmlParser.parseSpecificExperiment(chain, start2foldXml, experimentIds);
try {
EvolutionaryCouplingParser.parseHotSpotFile(chain, Start2FoldConstants.COUPLING_DIRECTORY.resolve(entryId.toUpperCase() + "_hs.html"));
} catch (Exception e) {
}
boolean ecAnnotation = chain.aminoAcids().anyMatch(residue -> residue.getFeature(HotSpotScoring.class).getEcCount() > 0);
List<AminoAcid> topScoringResidues;
if (ecAnnotation) {
double fraction = 0.4;
int residuesToSelect = (int) (fraction * chain.aminoAcids().count());
topScoringResidues = chain.aminoAcids().sorted(Comparator.comparingDouble((AminoAcid aminoAcid) -> aminoAcid.getFeature(HotSpotScoring.class).getCumStrength()).reversed()).limit(residuesToSelect).collect(Collectors.toList());
} else {
topScoringResidues = new ArrayList<>();
}
EQuantParser.parseEQuantFile(chain, Start2FoldConstants.EQUANT_DIRECTORY.resolve(entryId.toLowerCase() + ".equant-small.txt"));
List<AminoAcid> earlyFoldingResidues = chain.aminoAcids().filter(aminoAcid -> aminoAcid.getFeature(Start2FoldResidueAnnotation.class).isEarly()).collect(Collectors.toList());
List<AminoAcid> strongResidues = chain.aminoAcids().filter(aminoAcid -> aminoAcid.getFeature(Start2FoldResidueAnnotation.class).isStrong()).collect(Collectors.toList());
List<Integer> functionalResidueNumbers = Start2FoldConstants.extractFunctionalResidueNumbers(split);
List<AminoAcid> functionalResidues = new ArrayList<>();
// do nothing if no annotation of functional residues exists
if (!functionalResidueNumbers.isEmpty()) {
FunctionalResidueParser.parse(chain, functionalResidueNumbers);
chain.aminoAcids().filter(aminoAcid -> aminoAcid.getFeature(FunctionalResidueAnnotation.class).isFunctional()).forEach(functionalResidues::add);
}
List<AminoAcid> aminoAcids = chain.aminoAcids().collect(Collectors.toList());
List<ContactStructuralInformation> contactStructuralInformation = StructuralInformationParserService.getInstance().parseContactStructuralInformation(Start2FoldConstants.DATA_DIRECTORY.resolve("si").resolve("raw").resolve(entryId.toUpperCase() + ".out"), chain, earlyFoldingResidues);
List<ResidueStructuralInformation> residueStructuralInformation = StructuralInformationParserService.getInstance().composeResidueStructuralInformation(aminoAcids, earlyFoldingResidues, contactStructuralInformation);
ResidueGraph conventionalProteinGraph = ResidueGraph.createResidueGraph(chain, ContactDefinitionFactory.createAlphaCarbonContactDefinition(8.0));
List<AminoAcid> residuesInEarlyFoldingSecondaryStructureElements = chain.aminoAcids().filter(aminoAcid -> !aminoAcid.getFeature(GenericSecondaryStructure.class).getSecondaryStructure().isCoilType()).filter(aminoAcid -> {
GenericSecondaryStructure.SecondaryStructureElement surroundingSecondaryStructureElement = aminoAcid.getFeature(GenericSecondaryStructure.class).getSurroundingSecondaryStructureElement(aminoAcid);
List<AminoAcid> surroundingAminoAcids = chain.getAminoAcids().subList(surroundingSecondaryStructureElement.getStart(), surroundingSecondaryStructureElement.getEnd() + 1);
return surroundingAminoAcids.stream().anyMatch(earlyFoldingResidues::contains);
}).collect(Collectors.toList());
System.out.println("efr: " + (earlyFoldingResidues.size() > 0) + " strong: " + (strongResidues.size() > 0) + " functional: " + (functionalResidues.size() > 0));
return Optional.of(chain.aminoAcids().filter(AminoAcid::isStandardAminoAcid).map(aminoAcid -> {
GenericSecondaryStructure sse = aminoAcid.getFeature(GenericSecondaryStructure.class);
HotSpotScoring hotSpotScoring = aminoAcid.getFeature(HotSpotScoring.class);
PLIPInteractionContainer plipInteractionContainer = aminoAcid.getFeature(PLIPInteractionContainer.class);
PLIPInteractionContainer nonLocalPlipInteractionContainer = new PLIPInteractionContainer(null, plipInteractionContainer.getInteractions().stream().filter(inter -> Math.abs(inter.getPartner1().getResidueIndex() - inter.getPartner2().getResidueIndex()) > 5).collect(Collectors.toList()));
PLIPInteractionContainer localPlipInteractionContainer = new PLIPInteractionContainer(null, plipInteractionContainer.getInteractions().stream().filter(inter -> !nonLocalPlipInteractionContainer.getInteractions().contains(inter)).collect(Collectors.toList()));
String equantScore = "NA";
try {
equantScore = StandardFormat.format(aminoAcid.getFeature(EQuantScore.class).getEvaluation());
} catch (ComputationException e) {
logger.warn("missing equant scoring for {}", aminoAcid);
}
String functionalAnnotation = "NA";
if (functionalResidues.size() > 0) {
functionalAnnotation = functionalResidues.contains(aminoAcid) ? "functional" : "non-functional";
}
ResidueTopologicPropertiesContainer residueTopologicPropertiesContainer = aminoAcid.getFeature(ResidueTopologicPropertiesContainer.class);
double terminusDistance = aminoAcids.indexOf(aminoAcid);
terminusDistance = Math.min(terminusDistance, aminoAcids.size() - terminusDistance);
terminusDistance /= (double) aminoAcids.size();
ResidueStructuralInformation residueStructuralInformationEntry = residueStructuralInformation.get(aminoAcid.getAminoAcidIndex());
GenericSecondaryStructure.SecondaryStructureElement surroundingSecondaryStructureElement = sse.getSurroundingSecondaryStructureElement(aminoAcid);
int sseSize = surroundingSecondaryStructureElement.getSize();
if (sse.getSecondaryStructure().isCoilType()) {
sseSize = 0;
}
int sseTerminusDistance = surroundingSecondaryStructureElement.getTerminusDistance();
if (sse.getSecondaryStructure().isCoilType()) {
sseTerminusDistance = -1;
}
return pdbId + "," + "A" + "," + aminoAcid.getResidueIdentifier() + "," + aminoAcid.getOneLetterCode() + "," + sse.getSecondaryStructure().getReducedRepresentation() + "," + sse.getSecondaryStructure().getOneLetterRepresentation() + "," + (sse.getSecondaryStructure().isHelixType() ? "true" : "false") + "," + (sse.getSecondaryStructure().isStrandType() ? "true" : "false") + "," + (sse.getSecondaryStructure().isCoilType() ? "true" : "false") + "," + sseSize + "," + sseTerminusDistance + "," + (aminoAcid.getFeature(AccessibleSurfaceArea.class).isExposed() ? "exposed" : "buried") + "," + StandardFormat.format(aminoAcid.getFeature(GeometricProperties.class).getDistanceToCentroid()) + "," + StandardFormat.format(terminusDistance) + "," + plipInteractionContainer.getHydrogenBonds().size() + "," + plipInteractionContainer.getHydrophobicInteractions().size() + "," + plipInteractionContainer.getBackboneInteractions().size() + "," + plipInteractionContainer.getInteractions().size() + "," + localPlipInteractionContainer.getHydrogenBonds().size() + "," + localPlipInteractionContainer.getHydrophobicInteractions().size() + "," + localPlipInteractionContainer.getBackboneInteractions().size() + "," + localPlipInteractionContainer.getInteractions().size() + "," + nonLocalPlipInteractionContainer.getHydrogenBonds().size() + "," + nonLocalPlipInteractionContainer.getHydrophobicInteractions().size() + "," + nonLocalPlipInteractionContainer.getBackboneInteractions().size() + "," + nonLocalPlipInteractionContainer.getInteractions().size() + "," + StandardFormat.format(aminoAcid.getFeature(EnergyProfile.class).getSolvationEnergy()) + "," + StandardFormat.format(aminoAcid.getFeature(EgorAgreement.class).getEgorPrediction()) + "," + equantScore + "," + StandardFormat.format(aminoAcid.getFeature(AccessibleSurfaceArea.class).getRelativeAccessibleSurfaceArea()) + "," + StandardFormat.format(aminoAcid.getFeature(LoopFraction.class).getLoopFraction()) + "," + hotSpotScoring.getEcCount() + "," + StandardFormat.format(hotSpotScoring.getCumStrength()) + "," + StandardFormat.format(hotSpotScoring.getEcStrength()) + "," + hotSpotScoring.getConservation() + "," + topScoringResidues.contains(aminoAcid) + "," + StandardFormat.format(residueTopologicPropertiesContainer.getFullPlip().getBetweenness()) + "," + StandardFormat.format(residueTopologicPropertiesContainer.getFullPlip().getCloseness()) + "," + StandardFormat.format(residueTopologicPropertiesContainer.getFullPlip().getClusteringCoefficient()) + "," + StandardFormat.format(residueTopologicPropertiesContainer.getHydrogenPlip().getBetweenness()) + "," + StandardFormat.format(residueTopologicPropertiesContainer.getHydrogenPlip().getCloseness()) + "," + StandardFormat.format(residueTopologicPropertiesContainer.getHydrogenPlip().getClusteringCoefficient()) + "," + StandardFormat.format(residueTopologicPropertiesContainer.getHydrophobicPlip().getBetweenness()) + "," + StandardFormat.format(residueTopologicPropertiesContainer.getHydrophobicPlip().getCloseness()) + "," + StandardFormat.format(residueTopologicPropertiesContainer.getHydrophobicPlip().getClusteringCoefficient()) + "," + conventionalProteinGraph.getContactsOf(aminoAcid).size() + "," + conventionalProteinGraph.getLocalContactsOf(aminoAcid).size() + "," + conventionalProteinGraph.getNonLocalContactsOf(aminoAcid).size() + "," + StandardFormat.format(residueTopologicPropertiesContainer.getConventional().getBetweenness()) + "," + StandardFormat.format(residueTopologicPropertiesContainer.getConventional().getCloseness()) + "," + StandardFormat.format(residueTopologicPropertiesContainer.getConventional().getClusteringCoefficient()) + "," + StandardFormat.format(residueTopologicPropertiesContainer.getFullPlip().getDistinctNeighborhoodCount()) + "," + StandardFormat.format(residueTopologicPropertiesContainer.getConventional().getDistinctNeighborhoodCount()) + "," + StandardFormat.format(residueStructuralInformationEntry.getAverageRmsdIncrease()) + "," + StandardFormat.format(residueStructuralInformationEntry.getAverageTmScoreIncrease()) + "," + StandardFormat.format(residueStructuralInformationEntry.getAverageQIncrease()) + "," + StandardFormat.format(residueStructuralInformationEntry.getMaximumRmsdIncrease()) + "," + StandardFormat.format(residueStructuralInformationEntry.getMaximumTmScoreIncrease()) + "," + StandardFormat.format(residueStructuralInformationEntry.getMaximumQIncrease()) + "," + StandardFormat.format(residueStructuralInformationEntry.getAverageRmsdIncreaseZScore()) + "," + StandardFormat.format(residueStructuralInformationEntry.getFractionOfTopScoringContacts()) + "," + (earlyFoldingResidues.contains(aminoAcid) ? "early" : "late") + "," + (residuesInEarlyFoldingSecondaryStructureElements.contains(aminoAcid) ? "true" : "false") + "," + functionalAnnotation + "," + (strongResidues.contains(aminoAcid) ? "strong" : "weak") + "," + (earlyFoldingResidues.size() > 0) + "," + (strongResidues.size() > 0) + "," + (functionalResidues.size() > 0) + "," + ecAnnotation;
}).collect(Collectors.joining(System.lineSeparator())));
} catch (Exception e) {
logger.info("calculation failed for {}\nby: {}", line, e.getMessage());
return Optional.empty();
}
}
use of de.bioforscher.jstructure.feature.sse.GenericSecondaryStructure in project jstructure by JonStargaryen.
the class A02_WriteDatasetCsv method handleLine.
private static Optional<String> handleLine(String line) {
try {
System.out.println(line);
String[] split = line.split(";");
String entryId = split[0];
String pdbId = split[1];
List<Integer> experimentIds = Pattern.compile(",").splitAsStream(split[2].replaceAll("\\[", "").replaceAll("]", "")).map(Integer::valueOf).collect(Collectors.toList());
Structure structure = StructureParser.fromPdbId(pdbId).parse();
Chain chain = structure.chains().findFirst().get();
Start2FoldXmlParser.parseStability(chain, Start2FoldConstants.XML_DIRECTORY.resolve(entryId + ".xml"));
Start2FoldXmlParser.parseSpecificExperiment(chain, Start2FoldConstants.XML_DIRECTORY.resolve(entryId + ".xml"), experimentIds);
EvolutionaryCouplingParser.parseHotSpotFile(chain, Start2FoldConstants.COUPLING_DIRECTORY.resolve(entryId.toUpperCase() + "_hs.html"));
EQuantParser.parseEQuantFile(chain, Start2FoldConstants.EQUANT_DIRECTORY.resolve(entryId.toLowerCase() + ".equant-small.txt"));
List<AminoAcid> earlyFoldingResidues = chain.aminoAcids().filter(aminoAcid -> aminoAcid.getFeature(Start2FoldResidueAnnotation.class).isEarly()).collect(Collectors.toList());
List<AminoAcid> stableResidues = chain.aminoAcids().filter(aminoAcid -> aminoAcid.getFeature(Start2FoldResidueAnnotation.class).isStrong()).collect(Collectors.toList());
List<Integer> functionalResidueNumbers = Start2FoldConstants.extractFunctionalResidueNumbers(split);
List<AminoAcid> functionalResidues = new ArrayList<>();
// do nothing if no annotation of functional residues exists
if (!functionalResidueNumbers.isEmpty()) {
FunctionalResidueParser.parse(chain, functionalResidueNumbers);
chain.aminoAcids().filter(aminoAcid -> aminoAcid.getFeature(FunctionalResidueAnnotation.class).isFunctional()).forEach(functionalResidues::add);
}
List<AminoAcid> aminoAcids = chain.aminoAcids().collect(Collectors.toList());
ResidueGraph conventionalProteinGraph = ResidueGraph.createResidueGraph(chain, ContactDefinitionFactory.createAlphaCarbonContactDefinition(8));
return Optional.of(chain.aminoAcids().map(aminoAcid -> {
GenericSecondaryStructure sse = aminoAcid.getFeature(GenericSecondaryStructure.class);
HotSpotScoring hotSpotScoring = aminoAcid.getFeature(HotSpotScoring.class);
PLIPInteractionContainer plipInteractionContainer = aminoAcid.getFeature(PLIPInteractionContainer.class);
PLIPInteractionContainer nonLocalPlipInteractionContainer = new PLIPInteractionContainer(null, plipInteractionContainer.getInteractions().stream().filter(inter -> Math.abs(inter.getPartner1().getResidueIndex() - inter.getPartner2().getResidueIndex()) > 5).collect(Collectors.toList()));
PLIPInteractionContainer localPlipInteractionContainer = new PLIPInteractionContainer(null, plipInteractionContainer.getInteractions().stream().filter(inter -> !nonLocalPlipInteractionContainer.getInteractions().contains(inter)).collect(Collectors.toList()));
String equantScore = "NA";
try {
equantScore = StandardFormat.format(aminoAcid.getFeature(EQuantScore.class).getEvaluation());
} catch (ComputationException e) {
logger.warn("missing equant scoring for {}", aminoAcid);
}
String functionalAnnotation = "NA";
if (functionalResidues.size() > 0) {
functionalAnnotation = functionalResidues.contains(aminoAcid) ? "functional" : "non-functional";
}
ResidueTopologicPropertiesContainer residueTopologicPropertiesContainer = aminoAcid.getFeature(ResidueTopologicPropertiesContainer.class);
double terminusDistance = aminoAcids.indexOf(aminoAcid);
terminusDistance = Math.min(terminusDistance, aminoAcids.size() - terminusDistance);
terminusDistance /= (double) aminoAcids.size();
return pdbId + "," + "A" + "," + aminoAcid.getResidueIdentifier() + "," + aminoAcid.getOneLetterCode() + "," + sse.getSecondaryStructure().getReducedRepresentation() + "," + sse.getSecondaryStructure().getOneLetterRepresentation() + "," + sse.getSurroundingSecondaryStructureElement(aminoAcid).getSize() + "," + (aminoAcid.getFeature(AccessibleSurfaceArea.class).isExposed() ? "exposed" : "buried") + "," + StandardFormat.format(aminoAcid.getFeature(GeometricProperties.class).getDistanceToCentroid()) + "," + StandardFormat.format(terminusDistance) + "," + plipInteractionContainer.getHydrogenBonds().size() + "," + plipInteractionContainer.getHydrophobicInteractions().size() + "," + plipInteractionContainer.getBackboneInteractions().size() + "," + plipInteractionContainer.getInteractions().size() + "," + localPlipInteractionContainer.getHydrogenBonds().size() + "," + localPlipInteractionContainer.getHydrophobicInteractions().size() + "," + localPlipInteractionContainer.getBackboneInteractions().size() + "," + localPlipInteractionContainer.getInteractions().size() + "," + nonLocalPlipInteractionContainer.getHydrogenBonds().size() + "," + nonLocalPlipInteractionContainer.getHydrophobicInteractions().size() + "," + nonLocalPlipInteractionContainer.getBackboneInteractions().size() + "," + nonLocalPlipInteractionContainer.getInteractions().size() + "," + StandardFormat.format(aminoAcid.getFeature(EnergyProfile.class).getSolvationEnergy()) + "," + StandardFormat.format(aminoAcid.getFeature(EgorAgreement.class).getEgorPrediction()) + "," + equantScore + "," + StandardFormat.format(aminoAcid.getFeature(AccessibleSurfaceArea.class).getRelativeAccessibleSurfaceArea()) + "," + StandardFormat.format(aminoAcid.getFeature(LoopFraction.class).getLoopFraction()) + "," + hotSpotScoring.getEcCount() + "," + StandardFormat.format(hotSpotScoring.getCumStrength()) + "," + StandardFormat.format(hotSpotScoring.getEcStrength()) + "," + hotSpotScoring.getConservation() + "," + StandardFormat.format(residueTopologicPropertiesContainer.getFullPlip().getBetweenness()) + "," + StandardFormat.format(residueTopologicPropertiesContainer.getFullPlip().getCloseness()) + "," + StandardFormat.format(residueTopologicPropertiesContainer.getFullPlip().getClusteringCoefficient()) + "," + StandardFormat.format(residueTopologicPropertiesContainer.getHydrogenPlip().getBetweenness()) + "," + StandardFormat.format(residueTopologicPropertiesContainer.getHydrogenPlip().getCloseness()) + "," + StandardFormat.format(residueTopologicPropertiesContainer.getHydrogenPlip().getClusteringCoefficient()) + "," + StandardFormat.format(residueTopologicPropertiesContainer.getHydrophobicPlip().getBetweenness()) + "," + StandardFormat.format(residueTopologicPropertiesContainer.getHydrophobicPlip().getCloseness()) + "," + StandardFormat.format(residueTopologicPropertiesContainer.getHydrophobicPlip().getClusteringCoefficient()) + "," + conventionalProteinGraph.getContactsOf(aminoAcid).size() + "," + conventionalProteinGraph.getLocalContactsOf(aminoAcid).size() + "," + conventionalProteinGraph.getNonLocalContactsOf(aminoAcid).size() + "," + StandardFormat.format(residueTopologicPropertiesContainer.getConventional().getBetweenness()) + "," + StandardFormat.format(residueTopologicPropertiesContainer.getConventional().getCloseness()) + "," + StandardFormat.format(residueTopologicPropertiesContainer.getConventional().getClusteringCoefficient()) + "," + StandardFormat.format(residueTopologicPropertiesContainer.getFullPlip().getDistinctNeighborhoodCount()) + "," + StandardFormat.format(residueTopologicPropertiesContainer.getConventional().getDistinctNeighborhoodCount()) + "," + (earlyFoldingResidues.contains(aminoAcid) ? "early" : "late") + "," + functionalAnnotation + "," + (stableResidues.contains(aminoAcid) ? "stable" : "unstable");
}).collect(Collectors.joining(System.lineSeparator())));
} catch (Exception e) {
logger.info("calculation failed for {}", line, e);
return Optional.empty();
}
}
use of de.bioforscher.jstructure.feature.sse.GenericSecondaryStructure in project jstructure by JonStargaryen.
the class RawFeatureVector method assignRawFeatureVector.
public static void assignRawFeatureVector(AminoAcid aminoAcid) {
GenericSecondaryStructure sse = aminoAcid.getFeature(GenericSecondaryStructure.class);
PLIPInteractionContainer plipInteractionContainer = aminoAcid.getFeature(PLIPInteractionContainer.class);
PLIPInteractionContainer nonLocalPlipInteractionContainer = new PLIPInteractionContainer(null, plipInteractionContainer.getInteractions().stream().filter(inter -> Math.abs(inter.getPartner1().getResidueIndex() - inter.getPartner2().getResidueIndex()) > 5).collect(Collectors.toList()));
PLIPInteractionContainer localPlipInteractionContainer = new PLIPInteractionContainer(null, plipInteractionContainer.getInteractions().stream().filter(inter -> !nonLocalPlipInteractionContainer.getInteractions().contains(inter)).collect(Collectors.toList()));
ResidueTopologicPropertiesContainer residueTopologicPropertiesContainer = aminoAcid.getFeature(ResidueTopologicPropertiesContainer.class);
// assign features to smooth
RawFeatureVector featureVector = new RawFeatureVector(sse.getSurroundingSecondaryStructureElement(aminoAcid).getSize(), localPlipInteractionContainer.getHydrogenBonds().size(), localPlipInteractionContainer.getHydrophobicInteractions().size(), localPlipInteractionContainer.getBackboneInteractions().size(), localPlipInteractionContainer.getInteractions().size(), nonLocalPlipInteractionContainer.getHydrogenBonds().size(), nonLocalPlipInteractionContainer.getHydrophobicInteractions().size(), nonLocalPlipInteractionContainer.getBackboneInteractions().size(), nonLocalPlipInteractionContainer.getInteractions().size(), aminoAcid.getFeature(EnergyProfile.class).getSolvationEnergy(), aminoAcid.getFeature(EgorAgreement.class).getEgorPrediction(), aminoAcid.getFeature(AccessibleSurfaceArea.class).getRelativeAccessibleSurfaceArea(), residueTopologicPropertiesContainer.getFullPlip().getBetweenness(), residueTopologicPropertiesContainer.getFullPlip().getCloseness(), residueTopologicPropertiesContainer.getFullPlip().getClusteringCoefficient(), residueTopologicPropertiesContainer.getHydrogenPlip().getBetweenness(), residueTopologicPropertiesContainer.getHydrogenPlip().getCloseness(), residueTopologicPropertiesContainer.getHydrogenPlip().getClusteringCoefficient(), residueTopologicPropertiesContainer.getHydrophobicPlip().getBetweenness(), residueTopologicPropertiesContainer.getHydrophobicPlip().getCloseness(), residueTopologicPropertiesContainer.getHydrophobicPlip().getClusteringCoefficient(), residueTopologicPropertiesContainer.getConventional().getBetweenness(), residueTopologicPropertiesContainer.getConventional().getCloseness(), residueTopologicPropertiesContainer.getConventional().getClusteringCoefficient(), residueTopologicPropertiesContainer.getFullPlip().getDistinctNeighborhoodCount(), residueTopologicPropertiesContainer.getConventional().getDistinctNeighborhoodCount());
aminoAcid.getFeatureContainer().addFeature(featureVector);
}
use of de.bioforscher.jstructure.feature.sse.GenericSecondaryStructure in project jstructure by JonStargaryen.
the class A03_WriteDatasetCsv method handleLine.
private static Optional<String> handleLine(String line) {
try {
System.out.println(line);
String[] split = line.split(";");
String entryId = split[0];
String pdbId = split[1];
List<Integer> experimentIds = Pattern.compile(",").splitAsStream(split[2].replaceAll("\\[", "").replaceAll("]", "")).map(Integer::valueOf).collect(Collectors.toList());
Structure structure = StructureParser.fromPdbId(pdbId).parse();
Chain chain = structure.chains().findFirst().get();
Start2FoldXmlParser.parseSpecificExperiment(chain, Start2FoldConstants.XML_DIRECTORY.resolve(entryId + ".xml"), experimentIds);
EvolutionaryCouplingParser.parseHotSpotFile(chain, Start2FoldConstants.COUPLING_DIRECTORY.resolve(entryId.toUpperCase() + "_hs.html"));
EQuantParser.parseEQuantFile(chain, Start2FoldConstants.EQUANT_DIRECTORY.resolve(entryId.toLowerCase() + ".equant-small.txt"));
List<AminoAcid> earlyFoldingResidues = chain.aminoAcids().filter(aminoAcid -> aminoAcid.getFeature(Start2FoldResidueAnnotation.class).isEarly()).collect(Collectors.toList());
List<Integer> functionalResidueNumbers = Start2FoldConstants.extractFunctioanlResidueNumbers(split);
List<AminoAcid> functionalResidues = new ArrayList<>();
// do nothing if no annotation of functional residues exists
if (!functionalResidueNumbers.isEmpty()) {
FunctionalResidueParser.parse(chain, functionalResidueNumbers);
chain.aminoAcids().filter(aminoAcid -> aminoAcid.getFeature(FunctionalResidueAnnotation.class).isFunctional()).forEach(functionalResidues::add);
}
List<AminoAcid> aminoAcids = chain.aminoAcids().collect(Collectors.toList());
ProteinGraph conventionalProteinGraph = ProteinGraphFactory.createProteinGraph(chain, ProteinGraphFactory.InteractionScheme.CALPHA8);
return Optional.of(chain.aminoAcids().map(aminoAcid -> {
GenericSecondaryStructure sse = aminoAcid.getFeature(GenericSecondaryStructure.class);
HotSpotScoring hotSpotScoring = aminoAcid.getFeature(HotSpotScoring.class);
PLIPInteractionContainer plipInteractionContainer = aminoAcid.getFeature(PLIPInteractionContainer.class);
PLIPInteractionContainer nonLocalPlipInteractionContainer = new PLIPInteractionContainer(null, plipInteractionContainer.getInteractions().stream().filter(inter -> Math.abs(inter.getPartner1().getResidueIndex() - inter.getPartner2().getResidueIndex()) > 5).collect(Collectors.toList()));
PLIPInteractionContainer localPlipInteractionContainer = new PLIPInteractionContainer(null, plipInteractionContainer.getInteractions().stream().filter(inter -> !nonLocalPlipInteractionContainer.getInteractions().contains(inter)).collect(Collectors.toList()));
String equantScore = "NA";
try {
equantScore = StandardFormat.format(aminoAcid.getFeature(EQuantScore.class).getEvaluation());
} catch (ComputationException e) {
logger.warn("missing equant scoring for {}", aminoAcid);
}
String functionalAnnotation = "NA";
if (functionalResidues.size() > 0) {
functionalAnnotation = functionalResidues.contains(aminoAcid) ? "functional" : "non-functional";
}
ResidueTopologicPropertiesContainer residueTopologicPropertiesContainer = aminoAcid.getFeature(ResidueTopologicPropertiesContainer.class);
double terminusDistance = aminoAcids.indexOf(aminoAcid);
terminusDistance = Math.min(terminusDistance, aminoAcids.size() - terminusDistance);
terminusDistance /= (double) aminoAcids.size();
return pdbId + "," + "A" + "," + aminoAcid.getResidueIdentifier() + "," + aminoAcid.getOneLetterCode() + "," + sse.getSecondaryStructure().getReducedRepresentation() + "," + sse.getSecondaryStructure().getOneLetterRepresentation() + "," + sse.getSurroundingSecondaryStructureElement(aminoAcid).getSize() + "," + (aminoAcid.getFeature(AccessibleSurfaceArea.class).isExposed() ? "exposed" : "buried") + "," + StandardFormat.format(aminoAcid.getFeature(GeometricProperties.class).getDistanceToCentroid()) + "," + StandardFormat.format(terminusDistance) + "," + plipInteractionContainer.getHydrogenBonds().size() + "," + plipInteractionContainer.getHydrophobicInteractions().size() + "," + plipInteractionContainer.getBackboneInteractions().size() + "," + plipInteractionContainer.getInteractions().size() + "," + localPlipInteractionContainer.getHydrogenBonds().size() + "," + localPlipInteractionContainer.getHydrophobicInteractions().size() + "," + localPlipInteractionContainer.getBackboneInteractions().size() + "," + localPlipInteractionContainer.getInteractions().size() + "," + nonLocalPlipInteractionContainer.getHydrogenBonds().size() + "," + nonLocalPlipInteractionContainer.getHydrophobicInteractions().size() + "," + nonLocalPlipInteractionContainer.getBackboneInteractions().size() + "," + nonLocalPlipInteractionContainer.getInteractions().size() + "," + StandardFormat.format(aminoAcid.getFeature(EnergyProfile.class).getSolvationEnergy()) + "," + StandardFormat.format(aminoAcid.getFeature(EgorAgreement.class).getEgorPrediction()) + "," + equantScore + "," + StandardFormat.format(aminoAcid.getFeature(AccessibleSurfaceArea.class).getRelativeAccessibleSurfaceArea()) + "," + StandardFormat.format(aminoAcid.getFeature(LoopFraction.class).getLoopFraction()) + "," + hotSpotScoring.getEcCount() + "," + StandardFormat.format(hotSpotScoring.getCumStrength()) + "," + StandardFormat.format(hotSpotScoring.getEcStrength()) + "," + hotSpotScoring.getConservation() + "," + StandardFormat.format(residueTopologicPropertiesContainer.getFullPlip().getBetweenness()) + "," + StandardFormat.format(residueTopologicPropertiesContainer.getFullPlip().getCloseness()) + "," + StandardFormat.format(residueTopologicPropertiesContainer.getFullPlip().getClusteringCoefficient()) + "," + StandardFormat.format(residueTopologicPropertiesContainer.getHydrogenPlip().getBetweenness()) + "," + StandardFormat.format(residueTopologicPropertiesContainer.getHydrogenPlip().getCloseness()) + "," + StandardFormat.format(residueTopologicPropertiesContainer.getHydrogenPlip().getClusteringCoefficient()) + "," + StandardFormat.format(residueTopologicPropertiesContainer.getHydrophobicPlip().getBetweenness()) + "," + StandardFormat.format(residueTopologicPropertiesContainer.getHydrophobicPlip().getCloseness()) + "," + StandardFormat.format(residueTopologicPropertiesContainer.getHydrophobicPlip().getClusteringCoefficient()) + "," + conventionalProteinGraph.getContactsOf(aminoAcid).size() + "," + conventionalProteinGraph.getLocalContactsOf(aminoAcid).size() + "," + conventionalProteinGraph.getNonLocalContactsOf(aminoAcid).size() + "," + StandardFormat.format(residueTopologicPropertiesContainer.getConventional().getBetweenness()) + "," + StandardFormat.format(residueTopologicPropertiesContainer.getConventional().getCloseness()) + "," + StandardFormat.format(residueTopologicPropertiesContainer.getConventional().getClusteringCoefficient()) + "," + StandardFormat.format(residueTopologicPropertiesContainer.getFullPlip().getDistinctNeighborhoodCount()) + "," + StandardFormat.format(residueTopologicPropertiesContainer.getConventional().getDistinctNeighborhoodCount()) + "," + (earlyFoldingResidues.contains(aminoAcid) ? "early" : "late") + "," + functionalAnnotation;
}).collect(Collectors.joining(System.lineSeparator())));
} catch (Exception e) {
logger.info("calculation failed for {}", line, e);
return Optional.empty();
}
}
use of de.bioforscher.jstructure.feature.sse.GenericSecondaryStructure in project jstructure by JonStargaryen.
the class A01_CreateContactMaps method handleFile.
private static void handleFile(String line) {
String[] split = line.split(";");
String stfId = split[0];
String pdbId = split[1];
List<Integer> experimentIds = Pattern.compile(",").splitAsStream(split[2].replaceAll("\\[", "").replaceAll("]", "")).map(Integer::valueOf).collect(Collectors.toList());
Structure structure = StructureParser.fromPath(BASE_PATH.resolve("pdb").resolve(stfId + ".pdb")).parse();
Chain chain = structure.chainsWithAminoAcids().findFirst().get();
String sequence = chain.getAminoAcidSequence();
String secondaryStructureString = chain.aminoAcids().map(aminoAcid -> aminoAcid.getFeature(GenericSecondaryStructure.class)).map(GenericSecondaryStructure::getSecondaryStructure).map(SecondaryStructureType::getReducedRepresentation).collect(Collectors.joining()).toUpperCase();
Start2FoldConstants.write(BASE_PATH.resolve("reconstruction").resolve("fasta").resolve(stfId + ".fasta"), ">" + stfId + System.lineSeparator() + sequence);
Start2FoldConstants.write(BASE_PATH.resolve("reconstruction").resolve("sse").resolve(stfId + ".sse"), ">" + stfId + System.lineSeparator() + secondaryStructureString);
Start2FoldXmlParser.parseSpecificExperiment(chain, Start2FoldConstants.XML_DIRECTORY.resolve(stfId + ".xml"), experimentIds);
List<AminoAcid> aminoAcids = chain.aminoAcids().collect(Collectors.toList());
List<AminoAcid> earlyFoldingResidues = chain.aminoAcids().filter(aminoAcid -> aminoAcid.getFeature(Start2FoldResidueAnnotation.class).isEarly()).collect(Collectors.toList());
List<Pair<AminoAcid, AminoAcid>> contacts = SetOperations.unorderedPairsOf(aminoAcids).filter(pair -> areNonCovalentGroups(pair.getLeft(), pair.getRight())).filter(pair -> ProteinGraphFactory.InteractionScheme.CALPHA8.areInContact(pair.getLeft(), pair.getRight())).collect(Collectors.toList());
List<Pair<AminoAcid, AminoAcid>> earlyFoldingContacts = contacts.stream().filter(pair -> earlyFoldingResidues.contains(pair.getLeft()) && earlyFoldingResidues.contains(pair.getRight())).collect(Collectors.toList());
String percentage = StandardFormat.formatToInteger(100 * earlyFoldingContacts.size() / (double) contacts.size());
System.out.println("fraction of EFR contacts is " + percentage + "%: " + earlyFoldingContacts.size() + " " + contacts.size());
Start2FoldConstants.write(MAP_PATH.resolve(stfId + "-sampled-100-1.rr"), composeRRString(contacts, sequence));
Start2FoldConstants.write(MAP_PATH.resolve(stfId + "-efr-" + percentage + "-1.rr"), composeRRString(earlyFoldingContacts, sequence));
for (int i = 5; i < 100; i = i + 5) {
int numberOfContactsToSelect = (int) (i / (double) 100 * contacts.size());
for (int j = 1; j < 6; j++) {
Collections.shuffle(contacts);
List<Pair<AminoAcid, AminoAcid>> selectedContacts = contacts.subList(0, numberOfContactsToSelect);
Start2FoldConstants.write(MAP_PATH.resolve(stfId + "-random-" + i + "-" + j + ".rr"), composeRRString(selectedContacts, sequence));
}
}
// create samplings of random residues
for (int i = 5; i < 100; i = i + 5) {
int numberOfResiduesToSelect = (int) (i / (double) 100 * aminoAcids.size());
for (int j = 1; j < 6; j++) {
Collections.shuffle(aminoAcids);
List<AminoAcid> selectedAminoAcids = aminoAcids.subList(0, numberOfResiduesToSelect);
Start2FoldConstants.write(MAP_PATH.resolve(stfId + "-residues-" + i + "-" + j + ".rr"), composeRRString(contacts.stream().filter(contact -> selectedAminoAcids.contains(contact.getLeft()) && selectedAminoAcids.contains(contact.getRight())).collect(Collectors.toList()), sequence));
}
}
// create samplings of comparable nature of EFR contacts
for (int j = 1; j < 6; j++) {
int numberOfResiduesToSelect = earlyFoldingResidues.size();
List<AminoAcid> interactingResidues = getInteractingResidues(aminoAcids, contacts, numberOfResiduesToSelect);
Start2FoldConstants.write(MAP_PATH.resolve(stfId + "-interacting-" + percentage + "-" + j + ".rr"), composeRRString(contacts.stream().filter(contact -> interactingResidues.contains(contact.getLeft()) && interactingResidues.contains(contact.getRight())).collect(Collectors.toList()), sequence));
}
// create bin samplings of comparable nature of EFR contacts
for (int i = 5; i < 100; i = i + 5) {
int numberOfResiduesToSelect = (int) (i / (double) 100 * aminoAcids.size());
for (int j = 1; j < 6; j++) {
List<AminoAcid> interactingResidues = getInteractingResidues(aminoAcids, contacts, numberOfResiduesToSelect);
Start2FoldConstants.write(MAP_PATH.resolve(stfId + "-interacting2-" + percentage + "-" + j + ".rr"), composeRRString(contacts.stream().filter(contact -> interactingResidues.contains(contact.getLeft()) && interactingResidues.contains(contact.getRight())).collect(Collectors.toList()), sequence));
}
}
}
Aggregations