Search in sources :

Example 11 with Structure

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

the class ProteinLigandInteractionProfiler method writePolymerInteractions.

public void writePolymerInteractions(Chain chain, Path outputPath) {
    try {
        Path outputDirectoryPath = createTemporaryOutputDirectory();
        Structure structure = chain.getParentStructure();
        String[] commandLineCall = composePolymerCommandLineCall(structure, outputDirectoryPath, chain.getChainIdentifier().getChainId());
        // execute command
        executeCommandLineCall(commandLineCall);
        Path output = outputDirectoryPath.resolve("report.xml");
        Files.copy(output, outputPath);
    } 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) ComputationException(de.bioforscher.jstructure.model.feature.ComputationException) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException)

Example 12 with Structure

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

the class ProteinLigandInteractionProfiler method parseMetalComplexes.

private void parseMetalComplexes(Structure structure, Element interactionElement, List<Interaction> interactions) {
    Elements metalComplexes = interactionElement.getElementsByTag("metal_complex");
    metalComplexes.stream().map(element -> parseMetalComplex(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 13 with Structure

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

the class ProteinLigandInteractionProfiler method parsePiCationInteraction.

private Optional<PiCationInteraction> parsePiCationInteraction(Structure structure, Element element) {
    // TODO check if direction can be reversed: protein is pi system, ligand is cation
    // TODO: potentially half interaction
    Optional<Element> optionalCationCoordinateElement = element.getElementsByTag("protcoo").stream().findFirst();
    if (!optionalCationCoordinateElement.isPresent()) {
        return Optional.empty();
    }
    Element cationCoordinateElement = optionalCationCoordinateElement.get();
    double[] cationCoordinates = new double[] { Double.valueOf(cationCoordinateElement.getElementsByTag("x").first().text()), Double.valueOf(cationCoordinateElement.getElementsByTag("y").first().text()), Double.valueOf(cationCoordinateElement.getElementsByTag("z").first().text()) };
    String chainId = element.getElementsByTag("reschain").first().text();
    int residueNumber = Integer.valueOf(element.getElementsByTag("resnr").first().text());
    Optional<Group> optionalCationGroup = structure.select().chainId(chainId).residueNumber(residueNumber).asOptionalGroup();
    if (!optionalCationGroup.isPresent()) {
        return Optional.empty();
    }
    Group cationGroup = optionalCationGroup.get();
    Optional<Atom> optionalCation = cationGroup.atoms().min(Comparator.comparingDouble(atom -> atom.calculate().distanceFast(cationCoordinates)));
    if (!optionalCation.isPresent()) {
        return Optional.empty();
    }
    Atom cation = optionalCation.get();
    List<Atom> piAtoms = element.getElementsByTag("idx").stream().map(Element::text).map(pdbSerial -> selectAtom(structure, pdbSerial)).filter(Optional::isPresent).map(Optional::get).collect(Collectors.toList());
    if (piAtoms.isEmpty()) {
        return Optional.empty();
    }
    Group piGroup = piAtoms.get(0).getParentGroup();
    return Optional.of(new PiCationInteraction(cation, piAtoms, cationGroup, piGroup));
}
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)

Example 14 with Structure

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

the class ProteinLigandInteractionProfiler method parseHydrogenBonds.

private void parseHydrogenBonds(Structure structure, Element interactionElement, List<Interaction> interactions) {
    Elements hydrogenBonds = interactionElement.getElementsByTag("hydrogen_bond");
    hydrogenBonds.stream().map(element -> parseHydrogenBond(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 15 with Structure

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

the class ProteinLigandInteractionProfiler method parseSaltBridges.

private void parseSaltBridges(Structure structure, Element interactionElement, List<Interaction> interactions) {
    Elements saltBridges = interactionElement.getElementsByTag("salt_bridge");
    saltBridges.stream().map(element -> parseSaltBridge(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)

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