Search in sources :

Example 26 with Structure

use of de.bioforscher.jstructure.model.structure.Structure in project jstructure by JonStargaryen.

the class ProteinLigandInteractionProfiler method parsePiStackingInteractions.

private void parsePiStackingInteractions(Structure structure, Element interactionElement, List<Interaction> interactions) {
    Elements piStackingInteractions = interactionElement.getElementsByTag("pi_stack");
    piStackingInteractions.stream().map(element -> parsePiStackingInteraction(structure, element)).filter(Optional::isPresent).map(Optional::get).forEach(interactions::add);
}
Also used : java.util(java.util) Logger(org.slf4j.Logger) ComputationException(de.bioforscher.jstructure.model.feature.ComputationException) ExternalLocalService(de.bioforscher.jstructure.service.ExternalLocalService) Files(java.nio.file.Files) URL(java.net.URL) LoggerFactory(org.slf4j.LoggerFactory) Structure(de.bioforscher.jstructure.model.structure.Structure) IOException(java.io.IOException) InputStreamReader(java.io.InputStreamReader) Collectors(java.util.stream.Collectors) UncheckedIOException(java.io.UncheckedIOException) Stream(java.util.stream.Stream) de.bioforscher.jstructure.feature.plip.model(de.bioforscher.jstructure.feature.plip.model) Group(de.bioforscher.jstructure.model.structure.Group) URLConnection(java.net.URLConnection) Atom(de.bioforscher.jstructure.model.structure.Atom) Document(org.jsoup.nodes.Document) Element(org.jsoup.nodes.Element) Chain(de.bioforscher.jstructure.model.structure.Chain) Jsoup(org.jsoup.Jsoup) Elements(org.jsoup.select.Elements) BufferedReader(java.io.BufferedReader) Path(java.nio.file.Path) Elements(org.jsoup.select.Elements)

Example 27 with Structure

use of de.bioforscher.jstructure.model.structure.Structure in project jstructure by JonStargaryen.

the class ProteinLigandInteractionProfiler method parseWaterBridges.

private void parseWaterBridges(Structure structure, Element interactionElement, List<Interaction> interactions) {
    Elements waterBridges = interactionElement.getElementsByTag("water_bridge");
    waterBridges.stream().map(element -> parseWaterBridge(structure, element)).filter(Optional::isPresent).map(Optional::get).forEach(interactions::add);
}
Also used : java.util(java.util) Logger(org.slf4j.Logger) ComputationException(de.bioforscher.jstructure.model.feature.ComputationException) ExternalLocalService(de.bioforscher.jstructure.service.ExternalLocalService) Files(java.nio.file.Files) URL(java.net.URL) LoggerFactory(org.slf4j.LoggerFactory) Structure(de.bioforscher.jstructure.model.structure.Structure) IOException(java.io.IOException) InputStreamReader(java.io.InputStreamReader) Collectors(java.util.stream.Collectors) UncheckedIOException(java.io.UncheckedIOException) Stream(java.util.stream.Stream) de.bioforscher.jstructure.feature.plip.model(de.bioforscher.jstructure.feature.plip.model) Group(de.bioforscher.jstructure.model.structure.Group) URLConnection(java.net.URLConnection) Atom(de.bioforscher.jstructure.model.structure.Atom) Document(org.jsoup.nodes.Document) Element(org.jsoup.nodes.Element) Chain(de.bioforscher.jstructure.model.structure.Chain) Jsoup(org.jsoup.Jsoup) Elements(org.jsoup.select.Elements) BufferedReader(java.io.BufferedReader) Path(java.nio.file.Path) Elements(org.jsoup.select.Elements)

Example 28 with Structure

use of de.bioforscher.jstructure.model.structure.Structure in project jstructure by JonStargaryen.

the class ProteinLigandInteractionProfiler method annotatePolymerInteractions.

private InteractionContainer annotatePolymerInteractions(Chain chain) {
    try {
        Path outputDirectoryPath = createTemporaryOutputDirectory();
        Structure structure = chain.getParentStructure();
        String[] commandLineCall = composePolymerCommandLineCall(structure, outputDirectoryPath, chain.getChainIdentifier().getChainId());
        // execute command
        executeCommandLineCall(commandLineCall);
        Path outputPath = outputDirectoryPath.resolve("report.xml");
        Document document = Jsoup.parse(outputPath.toFile(), "UTF-8");
        return parseDocument(structure, document);
    } catch (Exception e) {
        throw new ComputationException(e);
    }
}
Also used : Path(java.nio.file.Path) ComputationException(de.bioforscher.jstructure.model.feature.ComputationException) Structure(de.bioforscher.jstructure.model.structure.Structure) Document(org.jsoup.nodes.Document) ComputationException(de.bioforscher.jstructure.model.feature.ComputationException) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException)

Example 29 with Structure

use of de.bioforscher.jstructure.model.structure.Structure in project jstructure by JonStargaryen.

the class ProteinLigandInteractionProfiler method parsePiCationInteractions.

private void parsePiCationInteractions(Structure structure, Element interactionElement, List<Interaction> interactions) {
    Elements piCationInteractions = interactionElement.getElementsByTag("pi_cation_interaction");
    piCationInteractions.stream().map(element -> parsePiCationInteraction(structure, element)).filter(Optional::isPresent).map(Optional::get).forEach(interactions::add);
}
Also used : java.util(java.util) Logger(org.slf4j.Logger) ComputationException(de.bioforscher.jstructure.model.feature.ComputationException) ExternalLocalService(de.bioforscher.jstructure.service.ExternalLocalService) Files(java.nio.file.Files) URL(java.net.URL) LoggerFactory(org.slf4j.LoggerFactory) Structure(de.bioforscher.jstructure.model.structure.Structure) IOException(java.io.IOException) InputStreamReader(java.io.InputStreamReader) Collectors(java.util.stream.Collectors) UncheckedIOException(java.io.UncheckedIOException) Stream(java.util.stream.Stream) de.bioforscher.jstructure.feature.plip.model(de.bioforscher.jstructure.feature.plip.model) Group(de.bioforscher.jstructure.model.structure.Group) URLConnection(java.net.URLConnection) Atom(de.bioforscher.jstructure.model.structure.Atom) Document(org.jsoup.nodes.Document) Element(org.jsoup.nodes.Element) Chain(de.bioforscher.jstructure.model.structure.Chain) Jsoup(org.jsoup.Jsoup) Elements(org.jsoup.select.Elements) BufferedReader(java.io.BufferedReader) Path(java.nio.file.Path) Elements(org.jsoup.select.Elements)

Example 30 with Structure

use of de.bioforscher.jstructure.model.structure.Structure in project jstructure by JonStargaryen.

the class ProteinLigandInteractionProfiler method parseSaltBridge.

private Optional<SaltBridge> parseSaltBridge(Structure structure, Element element) {
    // TODO: potentially half interaction
    Optional<Element> optionalCoordinateElement = element.getElementsByTag("protcoo").stream().findFirst();
    if (!optionalCoordinateElement.isPresent()) {
        return Optional.empty();
    }
    Element coordinateElement = optionalCoordinateElement.get();
    double[] coordinates = new double[] { Double.valueOf(coordinateElement.getElementsByTag("x").first().text()), Double.valueOf(coordinateElement.getElementsByTag("y").first().text()), Double.valueOf(coordinateElement.getElementsByTag("z").first().text()) };
    String chainId = element.getElementsByTag("reschain").first().text();
    int residueNumber = Integer.valueOf(element.getElementsByTag("resnr").first().text());
    Optional<Group> optionalGroup1 = structure.select().chainId(chainId).residueNumber(residueNumber).asOptionalGroup();
    if (!optionalGroup1.isPresent()) {
        return Optional.empty();
    }
    Group group1 = optionalGroup1.get();
    Optional<Atom> optionalAtom1 = group1.atoms().min(Comparator.comparingDouble(atom -> atom.calculate().distanceFast(coordinates)));
    if (!optionalAtom1.isPresent()) {
        return Optional.empty();
    }
    Atom atom1 = optionalAtom1.get();
    List<Atom> saltAtoms = element.getElementsByTag("idx").stream().map(Element::text).map(pdbSerial -> selectAtom(structure, pdbSerial)).filter(Optional::isPresent).map(Optional::get).collect(Collectors.toList());
    if (saltAtoms.isEmpty()) {
        return Optional.empty();
    }
    Group saltGroup = saltAtoms.get(0).getParentGroup();
    return Optional.of(new SaltBridge(atom1, saltAtoms, group1, saltGroup));
}
Also used : java.util(java.util) Logger(org.slf4j.Logger) ComputationException(de.bioforscher.jstructure.model.feature.ComputationException) ExternalLocalService(de.bioforscher.jstructure.service.ExternalLocalService) Files(java.nio.file.Files) URL(java.net.URL) LoggerFactory(org.slf4j.LoggerFactory) Structure(de.bioforscher.jstructure.model.structure.Structure) IOException(java.io.IOException) InputStreamReader(java.io.InputStreamReader) Collectors(java.util.stream.Collectors) UncheckedIOException(java.io.UncheckedIOException) Stream(java.util.stream.Stream) de.bioforscher.jstructure.feature.plip.model(de.bioforscher.jstructure.feature.plip.model) Group(de.bioforscher.jstructure.model.structure.Group) URLConnection(java.net.URLConnection) Atom(de.bioforscher.jstructure.model.structure.Atom) Document(org.jsoup.nodes.Document) Element(org.jsoup.nodes.Element) Chain(de.bioforscher.jstructure.model.structure.Chain) Jsoup(org.jsoup.Jsoup) Elements(org.jsoup.select.Elements) BufferedReader(java.io.BufferedReader) Path(java.nio.file.Path) Group(de.bioforscher.jstructure.model.structure.Group) Element(org.jsoup.nodes.Element) Atom(de.bioforscher.jstructure.model.structure.Atom)

Aggregations

Structure (de.bioforscher.jstructure.model.structure.Structure)61 IOException (java.io.IOException)45 Collectors (java.util.stream.Collectors)40 Chain (de.bioforscher.jstructure.model.structure.Chain)39 Files (java.nio.file.Files)35 StructureParser (de.bioforscher.jstructure.model.structure.StructureParser)30 Path (java.nio.file.Path)26 AminoAcid (de.bioforscher.jstructure.model.structure.aminoacid.AminoAcid)23 List (java.util.List)22 StandardFormat (de.bioforscher.jstructure.StandardFormat)21 Logger (org.slf4j.Logger)20 LoggerFactory (org.slf4j.LoggerFactory)20 Test (org.junit.Test)19 Group (de.bioforscher.jstructure.model.structure.Group)18 UncheckedIOException (java.io.UncheckedIOException)18 Pattern (java.util.regex.Pattern)17 Stream (java.util.stream.Stream)17 Jsoup (org.jsoup.Jsoup)17 ComputationException (de.bioforscher.jstructure.model.feature.ComputationException)16 java.util (java.util)15