use of de.bioforscher.jstructure.model.identifier.ResidueIdentifier in project jstructure by JonStargaryen.
the class A01_CreatePyMolRenderJobsForEarlyFoldingResidues method composePyMolCommand.
private static String composePyMolCommand(String 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);
List<Integer> earlyFoldingResidues = chain.aminoAcids().filter(aminoAcid -> aminoAcid.getFeature(Start2FoldResidueAnnotation.class).isEarly()).map(AminoAcid::getResidueIdentifier).map(ResidueIdentifier::getResidueNumber).collect(Collectors.toList());
return "delete all" + System.lineSeparator() + "fetch " + pdbId + ", async=0" + System.lineSeparator() + // hide non-relevant stuff
"hide everything" + System.lineSeparator() + "show cartoon, chain A" + System.lineSeparator() + // decolor everything
"color grey80" + System.lineSeparator() + "zoom (chain A)" + System.lineSeparator() + earlyFoldingResidues.stream().map(res -> "color efr, resi " + res).collect(Collectors.joining(System.lineSeparator())) + System.lineSeparator() + "ray" + System.lineSeparator() + "png " + Start2FoldConstants.PYMOL_DIRECTORY.resolve(entryId + "-efr.png") + System.lineSeparator();
}
use of de.bioforscher.jstructure.model.identifier.ResidueIdentifier in project jstructure by JonStargaryen.
the class A04_VisualizeAARSStructures method mapToOriginalResidueNumber.
private static Optional<Integer> mapToOriginalResidueNumber(int renumberedResidueNumber, Chain originalChain, Chain renumberedChain) {
try {
AminoAcid renumberedAminoAcid = renumberedChain.select().residueNumber(renumberedResidueNumber).asAminoAcid();
LinearAlgebra.PrimitiveDoubleArrayLinearAlgebra renumberedPosition = renumberedAminoAcid.calculate().centroid();
return originalChain.aminoAcids().filter(originalAminoAcid -> originalAminoAcid.calculate().centroid().distance(renumberedPosition) < 0.01).findFirst().map(Group::getResidueIdentifier).map(ResidueIdentifier::getResidueNumber);
} catch (Exception e) {
return Optional.empty();
}
}
use of de.bioforscher.jstructure.model.identifier.ResidueIdentifier in project jstructure by JonStargaryen.
the class A04_WriteTransitionStateCsv method handleLineLocally.
private static Optional<String> handleLineLocally(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 originalChain = structure.chains().findFirst().get();
ProteinGraph originalFullPlipGraph = ProteinGraphFactory.createProteinGraph(originalChain, ProteinGraphFactory.InteractionScheme.SALENTIN2015);
ProteinGraph originalHydrogenPlipGraph = ProteinGraphFactory.createProteinGraph(originalChain, ProteinGraphFactory.InteractionScheme.SALENTIN2015_HYDROGEN_BONDS);
ProteinGraph originalHydrophobicPlipGraph = ProteinGraphFactory.createProteinGraph(originalChain, ProteinGraphFactory.InteractionScheme.SALENTIN2015_HYDROPHOBIC_INTERACTION);
ProteinGraph originalConvGraph = ProteinGraphFactory.createProteinGraph(originalChain, ProteinGraphFactory.InteractionScheme.CALPHA8);
Start2FoldXmlParser.parseSpecificExperiment(originalChain, Start2FoldConstants.XML_DIRECTORY.resolve(entryId + ".xml"), experimentIds);
List<AminoAcid> earlyFoldingResidues = originalChain.aminoAcids().filter(aminoAcid -> aminoAcid.getFeature(Start2FoldResidueAnnotation.class).isEarly()).collect(Collectors.toList());
List<Chain> reconstructedChains = Files.list(Paths.get("/home/bittrich/git/phd_sb_repo/data/" + "reconstruction-start2fold/reconstructions/" + pdbId + "-early-conventional-1/stage1/")).filter(path -> path.toFile().getName().contains("_model")).map(path -> StructureParser.fromPath(path).forceProteinName(IdentifierFactory.createProteinIdentifier(pdbId, path.toFile().getName().split("_")[2].split("\\.")[0])).parse().getChains().get(0)).collect(Collectors.toList());
for (Chain reconstructedChain : reconstructedChains) {
Document document = PLIPRestServiceQuery.calculateIntraChainDocument(reconstructedChain);
PLIP_INTRA_MOLECULAR_ANNOTATOR.process(originalChain, document);
}
List<ProteinGraph> convGraphs = reconstructedChains.stream().map(c -> ProteinGraphFactory.createProteinGraph(c, ProteinGraphFactory.InteractionScheme.CALPHA8)).collect(Collectors.toList());
List<ProteinGraphCalculations> convGraphCalculations = convGraphs.stream().map(ProteinGraphCalculations::new).collect(Collectors.toList());
List<ProteinGraph> fullPlipGraphs = reconstructedChains.stream().map(c -> ProteinGraphFactory.createProteinGraph(c, ProteinGraphFactory.InteractionScheme.SALENTIN2015)).collect(Collectors.toList());
List<ProteinGraphCalculations> fullPlipGraphCalculations = fullPlipGraphs.stream().map(ProteinGraphCalculations::new).collect(Collectors.toList());
List<ProteinGraph> hydrogenPlipGraphs = reconstructedChains.stream().map(c -> ProteinGraphFactory.createProteinGraph(c, ProteinGraphFactory.InteractionScheme.SALENTIN2015_HYDROGEN_BONDS)).collect(Collectors.toList());
List<ProteinGraphCalculations> hydrogenPlipGraphCalculations = fullPlipGraphs.stream().map(ProteinGraphCalculations::new).collect(Collectors.toList());
List<ProteinGraph> hydrophobicPlipGraphs = reconstructedChains.stream().map(c -> ProteinGraphFactory.createProteinGraph(c, ProteinGraphFactory.InteractionScheme.SALENTIN2015_HYDROPHOBIC_INTERACTION)).collect(Collectors.toList());
List<ProteinGraphCalculations> hydrophobicPlipGraphCalculations = fullPlipGraphs.stream().map(ProteinGraphCalculations::new).collect(Collectors.toList());
return Optional.of(originalChain.aminoAcids().map(aminoAcid -> {
ResidueTopologicPropertiesContainer container = aminoAcid.getFeature(ResidueTopologicPropertiesContainer.class);
ResidueIdentifier residueIdentifier = aminoAcid.getResidueIdentifier();
return pdbId + "," + "A" + "," + aminoAcid.getResidueIdentifier() + "," + aminoAcid.getOneLetterCode() + "," + originalFullPlipGraph.getContactsOf(aminoAcid).size() + "," + originalFullPlipGraph.getLocalContactsOf(aminoAcid).size() + "," + originalFullPlipGraph.getNonLocalContactsOf(aminoAcid).size() + "," + StandardFormat.format(container.getFullPlip().getBetweenness()) + "," + StandardFormat.format(container.getFullPlip().getCloseness()) + "," + StandardFormat.format(container.getFullPlip().getClusteringCoefficient()) + "," + originalHydrogenPlipGraph.getContactsOf(aminoAcid).size() + "," + originalHydrogenPlipGraph.getLocalContactsOf(aminoAcid).size() + "," + originalHydrogenPlipGraph.getNonLocalContactsOf(aminoAcid).size() + "," + StandardFormat.format(container.getHydrogenPlip().getBetweenness()) + "," + StandardFormat.format(container.getHydrogenPlip().getCloseness()) + "," + StandardFormat.format(container.getHydrogenPlip().getClusteringCoefficient()) + "," + originalHydrophobicPlipGraph.getContactsOf(aminoAcid).size() + "," + originalHydrophobicPlipGraph.getLocalContactsOf(aminoAcid).size() + "," + originalHydrophobicPlipGraph.getNonLocalContactsOf(aminoAcid).size() + "," + StandardFormat.format(container.getHydrophobicPlip().getBetweenness()) + "," + StandardFormat.format(container.getHydrophobicPlip().getCloseness()) + "," + StandardFormat.format(container.getHydrophobicPlip().getClusteringCoefficient()) + "," + originalConvGraph.getContactsOf(aminoAcid).size() + "," + originalConvGraph.getLocalContactsOf(aminoAcid).size() + "," + originalConvGraph.getNonLocalContactsOf(aminoAcid).size() + "," + StandardFormat.format(container.getConventional().getBetweenness()) + "," + StandardFormat.format(container.getConventional().getCloseness()) + "," + StandardFormat.format(container.getConventional().getClusteringCoefficient()) + "," + container.getFullPlip().getDistinctNeighborhoodCount() + "," + container.getConventional().getDistinctNeighborhoodCount() + "," + StandardFormat.format(aminoAcid.getFeature(EnergyProfile.class).getSolvationEnergy()) + "," + StandardFormat.format(aminoAcid.getFeature(AccessibleSurfaceArea.class).getRelativeAccessibleSurfaceArea()) + "," + StandardFormat.format(aminoAcid.getFeature(LoopFraction.class).getLoopFraction()) + "," + (earlyFoldingResidues.contains(aminoAcid) ? "early" : "late") + "," + "native" + System.lineSeparator() + pdbId + "," + "A" + "," + aminoAcid.getResidueIdentifier() + "," + aminoAcid.getOneLetterCode() + "," + StandardFormat.format(fullPlipGraphs.stream().mapToInt(proteinGraph -> proteinGraph.getContactsOf(residueIdentifier).size()).average().getAsDouble()) + "," + StandardFormat.format(fullPlipGraphs.stream().mapToInt(proteinGraph -> proteinGraph.getLocalContactsOf(residueIdentifier).size()).average().getAsDouble()) + "," + StandardFormat.format(fullPlipGraphs.stream().mapToInt(proteinGraph -> proteinGraph.getNonLocalContactsOf(residueIdentifier).size()).average().getAsDouble()) + "," + StandardFormat.format(fullPlipGraphCalculations.stream().mapToDouble(proteinGraphCalculations -> proteinGraphCalculations.betweenness(residueIdentifier)).average().getAsDouble()) + "," + StandardFormat.format(fullPlipGraphCalculations.stream().mapToDouble(proteinGraphCalculations -> proteinGraphCalculations.closeness(residueIdentifier)).average().getAsDouble()) + "," + StandardFormat.format(fullPlipGraphCalculations.stream().mapToDouble(proteinGraphCalculations -> proteinGraphCalculations.clusteringCoefficient(residueIdentifier)).average().getAsDouble()) + "," + StandardFormat.format(hydrogenPlipGraphs.stream().mapToInt(proteinGraph -> proteinGraph.getContactsOf(residueIdentifier).size()).average().getAsDouble()) + "," + StandardFormat.format(hydrogenPlipGraphs.stream().mapToInt(proteinGraph -> proteinGraph.getLocalContactsOf(residueIdentifier).size()).average().getAsDouble()) + "," + StandardFormat.format(hydrogenPlipGraphs.stream().mapToInt(proteinGraph -> proteinGraph.getNonLocalContactsOf(residueIdentifier).size()).average().getAsDouble()) + "," + StandardFormat.format(hydrogenPlipGraphCalculations.stream().mapToDouble(proteinGraphCalculations -> proteinGraphCalculations.betweenness(residueIdentifier)).average().getAsDouble()) + "," + StandardFormat.format(hydrogenPlipGraphCalculations.stream().mapToDouble(proteinGraphCalculations -> proteinGraphCalculations.closeness(residueIdentifier)).average().getAsDouble()) + "," + StandardFormat.format(hydrogenPlipGraphCalculations.stream().mapToDouble(proteinGraphCalculations -> proteinGraphCalculations.clusteringCoefficient(residueIdentifier)).average().getAsDouble()) + "," + StandardFormat.format(hydrophobicPlipGraphs.stream().mapToInt(proteinGraph -> proteinGraph.getContactsOf(residueIdentifier).size()).average().getAsDouble()) + "," + StandardFormat.format(hydrophobicPlipGraphs.stream().mapToInt(proteinGraph -> proteinGraph.getLocalContactsOf(residueIdentifier).size()).average().getAsDouble()) + "," + StandardFormat.format(hydrophobicPlipGraphs.stream().mapToInt(proteinGraph -> proteinGraph.getNonLocalContactsOf(residueIdentifier).size()).average().getAsDouble()) + "," + StandardFormat.format(hydrophobicPlipGraphCalculations.stream().mapToDouble(proteinGraphCalculations -> proteinGraphCalculations.betweenness(residueIdentifier)).average().getAsDouble()) + "," + StandardFormat.format(hydrophobicPlipGraphCalculations.stream().mapToDouble(proteinGraphCalculations -> proteinGraphCalculations.closeness(residueIdentifier)).average().getAsDouble()) + "," + StandardFormat.format(hydrophobicPlipGraphCalculations.stream().mapToDouble(proteinGraphCalculations -> proteinGraphCalculations.clusteringCoefficient(residueIdentifier)).average().getAsDouble()) + "," + StandardFormat.format(convGraphs.stream().mapToInt(proteinGraph -> proteinGraph.getContactsOf(residueIdentifier).size()).average().getAsDouble()) + "," + StandardFormat.format(convGraphs.stream().mapToInt(proteinGraph -> proteinGraph.getLocalContactsOf(residueIdentifier).size()).average().getAsDouble()) + "," + StandardFormat.format(convGraphs.stream().mapToInt(proteinGraph -> proteinGraph.getNonLocalContactsOf(residueIdentifier).size()).average().getAsDouble()) + "," + StandardFormat.format(convGraphCalculations.stream().mapToDouble(proteinGraphCalculations -> proteinGraphCalculations.betweenness(residueIdentifier)).average().getAsDouble()) + "," + StandardFormat.format(convGraphCalculations.stream().mapToDouble(proteinGraphCalculations -> proteinGraphCalculations.closeness(residueIdentifier)).average().getAsDouble()) + "," + StandardFormat.format(convGraphCalculations.stream().mapToDouble(proteinGraphCalculations -> proteinGraphCalculations.clusteringCoefficient(residueIdentifier)).average().getAsDouble()) + "," + StandardFormat.format(fullPlipGraphCalculations.stream().mapToInt(proteinGraphCalculations -> proteinGraphCalculations.distinctNeighborhoodCount(residueIdentifier)).average().getAsDouble()) + "," + StandardFormat.format(convGraphCalculations.stream().mapToInt(proteinGraphCalculations -> proteinGraphCalculations.distinctNeighborhoodCount(residueIdentifier)).average().getAsDouble()) + "," + StandardFormat.format(reconstructedChains.stream().map(chain -> chain.select().residueIdentifier(aminoAcid.getResidueIdentifier()).asAminoAcid()).mapToDouble(aa -> aa.getFeature(EnergyProfile.class).getSolvationEnergy()).average().getAsDouble()) + "," + StandardFormat.format(reconstructedChains.stream().map(chain -> chain.select().residueIdentifier(aminoAcid.getResidueIdentifier()).asAminoAcid()).mapToDouble(aa -> aa.getFeature(AccessibleSurfaceArea.class).getRelativeAccessibleSurfaceArea()).average().getAsDouble()) + "," + StandardFormat.format(reconstructedChains.stream().map(chain -> chain.select().residueIdentifier(aminoAcid.getResidueIdentifier()).asAminoAcid()).mapToDouble(aa -> aa.getFeature(LoopFraction.class).getLoopFraction()).average().getAsDouble()) + "," + (earlyFoldingResidues.contains(aminoAcid) ? "early" : "late") + "," + "transition";
}).collect(Collectors.joining(System.lineSeparator())));
} catch (Exception e) {
e.printStackTrace();
logger.info("calculation failed for {}", line, e);
return Optional.empty();
}
}
use of de.bioforscher.jstructure.model.identifier.ResidueIdentifier in project jstructure by JonStargaryen.
the class A01_CreatePyMolRenderJobsForEarlyFoldingResidues method composePyMolCommand.
private static String composePyMolCommand(String 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);
List<Integer> earlyFoldingResidues = chain.aminoAcids().filter(aminoAcid -> aminoAcid.getFeature(Start2FoldResidueAnnotation.class).isEarly()).map(AminoAcid::getResidueIdentifier).map(ResidueIdentifier::getResidueNumber).collect(Collectors.toList());
return "delete all" + System.lineSeparator() + "fetch " + pdbId + ", async=0" + System.lineSeparator() + // hide non-relevant stuff
"hide everything" + System.lineSeparator() + "show cartoon, chain A" + System.lineSeparator() + // decolor everything
"color grey80" + System.lineSeparator() + "zoom (chain A)" + System.lineSeparator() + earlyFoldingResidues.stream().map(res -> "color efr, resi " + res).collect(Collectors.joining(System.lineSeparator())) + System.lineSeparator() + "ray" + System.lineSeparator() + "png " + Start2FoldConstants.PYMOL_DIRECTORY.resolve(entryId + "-efr.png") + System.lineSeparator();
}
use of de.bioforscher.jstructure.model.identifier.ResidueIdentifier in project jstructure by JonStargaryen.
the class A02_CreatePyMolRenderJobsForStrongResidues method composePyMolCommand.
private static Optional<String> composePyMolCommand(Path path) {
try {
String entryId = path.toFile().getName().split("\\.")[0];
String pdbId = Jsoup.parse(path.toFile(), "UTF-8").getElementsByTag("protein").attr("pdb_id");
Structure structure = StructureParser.fromPdbId(pdbId).parse();
Chain chain = structure.chains().findFirst().get();
Start2FoldXmlParser.parse(chain, Start2FoldConstants.XML_DIRECTORY.resolve(entryId + ".xml"));
List<Integer> strongResidues = chain.aminoAcids().filter(aminoAcid -> aminoAcid.getFeature(Start2FoldResidueAnnotation.class).isStrong()).map(AminoAcid::getResidueIdentifier).map(ResidueIdentifier::getResidueNumber).collect(Collectors.toList());
if (strongResidues.isEmpty()) {
return Optional.empty();
}
return Optional.of("delete all" + System.lineSeparator() + "fetch " + pdbId + ", async=0" + System.lineSeparator() + // hide non-relevant stuff
"hide everything" + System.lineSeparator() + "show cartoon, chain A" + System.lineSeparator() + // decolor everything
"color grey80" + System.lineSeparator() + "zoom (chain A)" + System.lineSeparator() + strongResidues.stream().map(res -> "color efr, resi " + res).collect(Collectors.joining(System.lineSeparator())) + System.lineSeparator() + "ray" + System.lineSeparator() + "png " + Start2FoldConstants.PYMOL_DIRECTORY.resolve(entryId + "-strong.png") + System.lineSeparator());
} catch (IOException e) {
return Optional.empty();
}
}
Aggregations