Search in sources :

Example 1 with Protein

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

the class EnergyProfileCalculatorTest method shouldAgreeRegardingEnergyTerms.

@Test
public void shouldAgreeRegardingEnergyTerms() throws IOException {
    Protein protein = ProteinParser.source("1bs2").parse();
    featureProvider.process(protein);
    Files.lines(Paths.get(TestUtils.getResourceAsFilepath("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.getFeatureContainer().getFeature(EnergyProfile.class).getSolvationEnergy(), 0.001);
    });
}
Also used : AbstractFeatureProvider(de.bioforscher.jstructure.model.feature.AbstractFeatureProvider) ProteinParser(de.bioforscher.jstructure.parser.ProteinParser) Files(java.nio.file.Files) DecimalFormatSymbols(java.text.DecimalFormatSymbols) TestUtils(util.TestUtils) DecimalFormat(java.text.DecimalFormat) Test(org.junit.Test) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) List(java.util.List) Stream(java.util.stream.Stream) Ignore(org.junit.Ignore) Paths(java.nio.file.Paths) Group(de.bioforscher.jstructure.model.structure.Group) Locale(java.util.Locale) Protein(de.bioforscher.jstructure.model.structure.Protein) Assert(org.junit.Assert) FeatureProviderRegistry(de.bioforscher.jstructure.model.feature.FeatureProviderRegistry) Before(org.junit.Before) Group(de.bioforscher.jstructure.model.structure.Group) Protein(de.bioforscher.jstructure.model.structure.Protein) Test(org.junit.Test)

Example 2 with Protein

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

the class OrientationsOfProteinsInMembranesAnnotator method processInternally.

@Override
protected void processInternally(Protein protein) {
    try {
        Document document = getDocument(SEARCH_URL + protein.getPdbId().getPdbId());
        if (document.text().contains("No matches")) {
            throw new ComputationException("did not find OPM entry for " + protein.getIdentifier() + " - possibly it is no membrane protein");
        }
        // create global membrane object - 3rd link points to download
        String downloadLink = document.getElementById("caption").getElementsByTag("a").get(2).attr("href");
        try (InputStreamReader inputStreamReader = new InputStreamReader(new URL(BASE_URL + downloadLink).openStream())) {
            try (BufferedReader bufferedReader = new BufferedReader(inputStreamReader)) {
                byte[] bytes = bufferedReader.lines().collect(Collectors.joining(System.lineSeparator())).getBytes();
                // parse protein
                Protein opmProtein = ProteinParser.source(new ByteArrayInputStream(bytes)).forceProteinName(ProteinIdentifier.createFromPdbId(downloadLink.split("=")[0].split("/")[1].substring(0, 4))).parse();
                Membrane membrane = new Membrane(this);
                // superimpose opm protein onto instance of the original protein
                //TODO this alignment is by no means perfect, but works for a first glance
                SVDSuperimposer.ALPHA_CARBON_SVD_INSTANCE.align(protein.select().aminoAcids().asGroupContainer(), opmProtein.select().aminoAcids().asGroupContainer()).transform(opmProtein);
                // extract dummy atoms and move them to membrane object
                List<double[]> membraneAtoms = opmProtein.atoms().map(Atom::getParentGroup).filter(group -> group.getThreeLetterCode().equals("DUM")).flatMap(Group::atoms).map(Atom::getCoordinates).collect(Collectors.toList());
                membrane.setMembraneAtoms(membraneAtoms);
                // extract general information - that is the first table
                Element generalDataTable = document.getElementsByClass("data").get(0);
                Element thicknessTr = generalDataTable.getElementsByTag("tr").get(1);
                membrane.setHydrophobicThickness(thicknessTr.getElementsByTag("td").get(1).text());
                Element tiltTr = generalDataTable.getElementsByTag("tr").get(2);
                membrane.setTiltAngle(tiltTr.getElementsByTag("td").get(1).text());
                Element transferTr = generalDataTable.getElementsByTag("tr").get(3);
                membrane.setDeltaGTransfer(transferTr.getElementsByTag("td").get(1).text());
                Element topologyTr = generalDataTable.getElementsByTag("tr").get(5);
                membrane.setTopology(topologyTr.getElementsByTag("td").get(1).text());
                // extract trans-membrane helices - second table
                Element transMembraneSubunitsTable = document.getElementsByClass("data").get(1);
                List<TransMembraneHelix> helices = transMembraneSubunitsTable.getElementsByTag("tr").stream().skip(1).map(element -> element.getElementsByTag("td").get(0)).map(Element::text).map(TransMembraneHelix::new).collect(Collectors.toList());
                membrane.setTransMembraneHelices(helices);
                protein.getFeatureContainer().addFeature(membrane);
            //                    //TODO remove, used to evaluate alignment manually
            //                    Files.write(Paths.get(System.getProperty("user.home") + "/ori.pdb"), protein.getPdbRepresentation().getBytes());
            //                    Files.write(Paths.get(System.getProperty("user.home") + "/opm.pdb"), opmProtein.getPdbRepresentation().getBytes());
            //                    //TODO remove, used to evaluate segment positions manually
            //                    Files.write(Paths.get(System.getProperty("user.home") + "/tm.pdb"), protein.select()
            //                            .residueNumber(helices.stream()
            //                                    .map(TransMembraneHelix::getSegments)
            //                                    .flatMap(Collection::stream)
            //                                    .collect(Collectors.toList())
            //                                    .toArray(new IntegerRange[0]))
            //                            .asGroupContainer()
            //                            .getPdbRepresentation()
            //                            .getBytes());
            }
        }
    } catch (IOException e) {
        throw new ComputationException("failed to fetch OPM file", e);
    }
}
Also used : AbstractFeatureProvider(de.bioforscher.jstructure.model.feature.AbstractFeatureProvider) ProteinIdentifier(de.bioforscher.jstructure.model.structure.identifier.ProteinIdentifier) ProteinParser(de.bioforscher.jstructure.parser.ProteinParser) Logger(org.slf4j.Logger) ComputationException(de.bioforscher.jstructure.feature.ComputationException) URL(java.net.URL) LoggerFactory(org.slf4j.LoggerFactory) IOException(java.io.IOException) InputStreamReader(java.io.InputStreamReader) Collectors(java.util.stream.Collectors) SVDSuperimposer(de.bioforscher.jstructure.alignment.SVDSuperimposer) List(java.util.List) ByteArrayInputStream(java.io.ByteArrayInputStream) FeatureProvider(de.bioforscher.jstructure.model.feature.FeatureProvider) Group(de.bioforscher.jstructure.model.structure.Group) Atom(de.bioforscher.jstructure.model.structure.Atom) Document(org.jsoup.nodes.Document) Element(org.jsoup.nodes.Element) Jsoup(org.jsoup.Jsoup) BufferedReader(java.io.BufferedReader) Protein(de.bioforscher.jstructure.model.structure.Protein) Group(de.bioforscher.jstructure.model.structure.Group) InputStreamReader(java.io.InputStreamReader) Element(org.jsoup.nodes.Element) IOException(java.io.IOException) Document(org.jsoup.nodes.Document) URL(java.net.URL) Protein(de.bioforscher.jstructure.model.structure.Protein) Atom(de.bioforscher.jstructure.model.structure.Atom) ByteArrayInputStream(java.io.ByteArrayInputStream) ComputationException(de.bioforscher.jstructure.feature.ComputationException) BufferedReader(java.io.BufferedReader)

Example 3 with Protein

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

the class Demo method demo.

@Test
public void demo() {
    // fetch protein from the PDB
    Protein protein = ProteinParser.source("1brr").parse();
    // compute the fraction of alanine in the protein
    double alanineRatio = protein.select().groupName(Alanine.THREE_LETTER_CODE).asFilteredGroups().count() / (double) protein.getSize() * 100.0;
    System.out.printf("alanine ratio: %3.2f%%", alanineRatio);
    // compute some features - e.g. compute the loop fraction
    FeatureProviderRegistry.resolve(LoopFraction.class).process(protein);
}
Also used : LoopFraction(de.bioforscher.jstructure.feature.loopfraction.LoopFraction) Protein(de.bioforscher.jstructure.model.structure.Protein) Test(org.junit.Test)

Example 4 with Protein

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

the class EnergyProfileCalculatorTest method shouldProcessStructureWithSelenomethionine.

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

Example 5 with Protein

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

the class PLIPAnnotatorTest method shouldAnnotateProteinWithWaterBridges.

@Test
public void shouldAnnotateProteinWithWaterBridges() {
    Protein protein = ProteinParser.source("5A1S").parse();
    plipAnnotator.process(protein);
}
Also used : Protein(de.bioforscher.jstructure.model.structure.Protein) Test(org.junit.Test)

Aggregations

Protein (de.bioforscher.jstructure.model.structure.Protein)32 Test (org.junit.Test)25 IOException (java.io.IOException)10 ProteinParser (de.bioforscher.jstructure.parser.ProteinParser)8 Collectors (java.util.stream.Collectors)8 Group (de.bioforscher.jstructure.model.structure.Group)7 List (java.util.List)6 AbstractFeatureProvider (de.bioforscher.jstructure.model.feature.AbstractFeatureProvider)5 FeatureProviderRegistry (de.bioforscher.jstructure.model.feature.FeatureProviderRegistry)5 Assert (org.junit.Assert)5 Before (org.junit.Before)4 AminoAcid (de.bioforscher.jstructure.model.structure.aminoacid.AminoAcid)3 UncheckedIOException (java.io.UncheckedIOException)3 Paths (java.nio.file.Paths)3 Stream (java.util.stream.Stream)3 LoopFraction (de.bioforscher.jstructure.feature.loopfraction.LoopFraction)2 Atom (de.bioforscher.jstructure.model.structure.Atom)2 Chain (de.bioforscher.jstructure.model.structure.Chain)2 Files (java.nio.file.Files)2 Path (java.nio.file.Path)2