Search in sources :

Example 6 with ResidueIdentifier

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();
    }
}
Also used : Files(java.nio.file.Files) ResidueIdentifier(de.bioforscher.jstructure.model.identifier.ResidueIdentifier) Structure(de.bioforscher.jstructure.model.structure.Structure) IOException(java.io.IOException) StructureParser(de.bioforscher.jstructure.model.structure.StructureParser) Collectors(java.util.stream.Collectors) Start2FoldResidueAnnotation(de.bioforscher.start2fold.model.Start2FoldResidueAnnotation) List(java.util.List) Start2FoldConstants(de.bioforscher.start2fold.Start2FoldConstants) AminoAcid(de.bioforscher.jstructure.model.structure.aminoacid.AminoAcid) Start2FoldXmlParser(de.bioforscher.start2fold.parser.Start2FoldXmlParser) Chain(de.bioforscher.jstructure.model.structure.Chain) Optional(java.util.Optional) StandardFormat(de.bioforscher.jstructure.StandardFormat) Jsoup(org.jsoup.Jsoup) Path(java.nio.file.Path) Chain(de.bioforscher.jstructure.model.structure.Chain) AminoAcid(de.bioforscher.jstructure.model.structure.aminoacid.AminoAcid) Start2FoldResidueAnnotation(de.bioforscher.start2fold.model.Start2FoldResidueAnnotation) IOException(java.io.IOException) Structure(de.bioforscher.jstructure.model.structure.Structure)

Aggregations

StandardFormat (de.bioforscher.jstructure.StandardFormat)6 ResidueIdentifier (de.bioforscher.jstructure.model.identifier.ResidueIdentifier)6 Chain (de.bioforscher.jstructure.model.structure.Chain)6 Structure (de.bioforscher.jstructure.model.structure.Structure)6 StructureParser (de.bioforscher.jstructure.model.structure.StructureParser)6 AminoAcid (de.bioforscher.jstructure.model.structure.aminoacid.AminoAcid)6 IOException (java.io.IOException)6 Files (java.nio.file.Files)6 List (java.util.List)6 Collectors (java.util.stream.Collectors)6 Start2FoldConstants (de.bioforscher.start2fold.Start2FoldConstants)4 Optional (java.util.Optional)4 Start2FoldResidueAnnotation (de.bioforscher.start2fold.model.Start2FoldResidueAnnotation)3 Start2FoldXmlParser (de.bioforscher.start2fold.parser.Start2FoldXmlParser)3 Pattern (java.util.regex.Pattern)3 Start2FoldConstants (de.bioforscher.jstructure.efr.Start2FoldConstants)2 Start2FoldResidueAnnotation (de.bioforscher.jstructure.efr.model.Start2FoldResidueAnnotation)2 Start2FoldXmlParser (de.bioforscher.jstructure.efr.parser.Start2FoldXmlParser)2 Path (java.nio.file.Path)2 Paths (java.nio.file.Paths)2