Search in sources :

Example 16 with Structure

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

the class ProteinLigandInteractionProfiler method parsePiStackingInteraction.

private Optional<PiStackingInteraction> parsePiStackingInteraction(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> 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 PiStackingInteraction(atom1, piAtoms, group1, 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 17 with Structure

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

the class ProteinLigandInteractionProfiler method parseHalogenBonds.

private void parseHalogenBonds(Structure structure, Element interactionElement, List<Interaction> interactions) {
    Elements halogenBonds = interactionElement.getElementsByTag("halogen_bond");
    halogenBonds.stream().map(element -> parseHalogenBond(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 18 with Structure

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

the class EnergyProfileCalculatorTest method shouldAgreeRegardingEnergyTerms.

@Test
public void shouldAgreeRegardingEnergyTerms() throws IOException {
    Structure protein = StructureParser.fromPdbId("1bs2").parse();
    featureProvider.process(protein);
    TestUtils.getResourceAsStream("energy/1bs2.ep2").filter(line -> line.startsWith("ENGY")).map(line -> line.split("\t")).forEach(split -> {
        Group group = protein.select().chainName(split[1]).residueNumber(Integer.valueOf(split[2])).asGroup();
        Assert.assertEquals("energy values differ for " + group, Double.valueOf(split[5]), group.getFeature(EnergyProfile.class).getSolvationEnergy(), 0.001);
    });
}
Also used : DecimalFormatSymbols(java.text.DecimalFormatSymbols) DecimalFormat(java.text.DecimalFormat) Structure(de.bioforscher.jstructure.model.structure.Structure) Test(org.junit.Test) IOException(java.io.IOException) TestUtils(de.bioforscher.testutil.TestUtils) StructureParser(de.bioforscher.jstructure.model.structure.StructureParser) Collectors(java.util.stream.Collectors) List(java.util.List) Stream(java.util.stream.Stream) Ignore(org.junit.Ignore) FeatureProvider(de.bioforscher.jstructure.model.feature.FeatureProvider) Group(de.bioforscher.jstructure.model.structure.Group) Locale(java.util.Locale) Assert(org.junit.Assert) Before(org.junit.Before) Group(de.bioforscher.jstructure.model.structure.Group) Structure(de.bioforscher.jstructure.model.structure.Structure) Test(org.junit.Test)

Example 19 with Structure

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

the class EnergyProfileCalculatorTest method shouldProcessStructureWithSelenomethionine.

@Test
public void shouldProcessStructureWithSelenomethionine() {
    Structure protein = StructureParser.fromPdbId("3TQO").parse();
    featureProvider.process(protein);
}
Also used : Structure(de.bioforscher.jstructure.model.structure.Structure) Test(org.junit.Test)

Example 20 with Structure

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

the class DictionaryOfProteinSecondaryStructureTest method getDSSPAnnotatedStructure.

private String getDSSPAnnotatedStructure(String id) throws IOException, StructureException {
    // load structure
    org.biojava.nbio.structure.Structure protein = new PDBFileReader().getStructureById(id);
    // assign states
    new SecStrucCalc().calculate(protein, true);
    // return complete DSSP annotation string from BioJava
    return protein.getChains().stream().flatMap(chain -> chain.getAtomGroups(GroupType.AMINOACID).stream()).map(aminoAcid -> aminoAcid.getProperty(Group.SEC_STRUC)).map(SecStrucState.class::cast).map(SecStrucState::getType).map(type -> String.valueOf(type.type)).collect(Collectors.joining());
}
Also used : PDBFileReader(org.biojava.nbio.structure.io.PDBFileReader) DSSPSecondaryStructure(de.bioforscher.jstructure.feature.sse.dssp.DSSPSecondaryStructure) Structure(de.bioforscher.jstructure.model.structure.Structure) Test(org.junit.Test) IOException(java.io.IOException) StructureParser(de.bioforscher.jstructure.model.structure.StructureParser) Collectors(java.util.stream.Collectors) StructureException(org.biojava.nbio.structure.StructureException) SecStrucState(org.biojava.nbio.structure.secstruc.SecStrucState) Stream(java.util.stream.Stream) Group(org.biojava.nbio.structure.Group) SecStrucCalc(org.biojava.nbio.structure.secstruc.SecStrucCalc) Assert(org.junit.Assert) GroupType(org.biojava.nbio.structure.GroupType) PDBFileReader(org.biojava.nbio.structure.io.PDBFileReader) DictionaryOfProteinSecondaryStructure(de.bioforscher.jstructure.feature.sse.dssp.DictionaryOfProteinSecondaryStructure) Before(org.junit.Before) SecStrucCalc(org.biojava.nbio.structure.secstruc.SecStrucCalc) SecStrucState(org.biojava.nbio.structure.secstruc.SecStrucState)

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