Search in sources :

Example 1 with Start2FoldResidueAnnotation

use of de.bioforscher.start2fold.model.Start2FoldResidueAnnotation in project jstructure by JonStargaryen.

the class Start2FoldXmlParser method parse.

public static void parse(Chain chain, InputStream inputStream) {
    try {
        // assign baseline resp. entry container for each residue
        chain.aminoAcids().forEach(aminoAcid -> aminoAcid.getFeatureContainer().addFeature(new Start2FoldResidueAnnotation()));
        Document document = Jsoup.parse(inputStream, "UTF-8", "/");
        Elements experimentElements = document.getElementsByTag("experiment");
        // logger.info("found {} experiments",
        // experimentElements.size());
        List<Experiment> experiments = experimentElements.stream().map(Experiment::parse).collect(Collectors.toList());
        for (Experiment experiment : experiments) {
            assignValues(experiment, chain);
        }
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
Also used : Experiment(de.bioforscher.start2fold.model.Experiment) Start2FoldResidueAnnotation(de.bioforscher.start2fold.model.Start2FoldResidueAnnotation) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException) Document(org.jsoup.nodes.Document) Elements(org.jsoup.select.Elements)

Example 2 with Start2FoldResidueAnnotation

use of de.bioforscher.start2fold.model.Start2FoldResidueAnnotation in project jstructure by JonStargaryen.

the class Start2FoldXmlParser method parseSpecificExperiment.

public static void parseSpecificExperiment(Chain chain, InputStream inputStream, List<Integer> experimentIds) {
    // experimentIds);
    try {
        // assign baseline resp. entry container for each residue
        chain.aminoAcids().forEach(aminoAcid -> aminoAcid.getFeatureContainer().addFeature(new Start2FoldResidueAnnotation()));
        Document document = Jsoup.parse(inputStream, "UTF-8", "/");
        Elements experimentElements = document.getElementsByTag("experiment");
        List<Experiment> experiments = experimentElements.stream().map(Experiment::parse).filter(experiment -> experimentIds.contains(experiment.getExperimentId())).collect(Collectors.toList());
        if (experimentIds.size() != experiments.size()) {
            throw new IllegalArgumentException("did not find all referenced experiments");
        }
        for (Experiment experiment : experiments) {
            assignValuesForEarly(experiment, chain);
        }
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
Also used : LoggerFactory(org.slf4j.LoggerFactory) ProteinSequence(org.biojava.nbio.core.sequence.ProteinSequence) SimpleGapPenalty(org.biojava.nbio.alignment.SimpleGapPenalty) AminoAcid(de.bioforscher.jstructure.model.structure.aminoacid.AminoAcid) Chain(de.bioforscher.jstructure.model.structure.Chain) SubstitutionMatrixHelper(org.biojava.nbio.core.alignment.matrices.SubstitutionMatrixHelper) CompoundNotFoundException(org.biojava.nbio.core.exceptions.CompoundNotFoundException) Path(java.nio.file.Path) Logger(org.slf4j.Logger) Experiment(de.bioforscher.start2fold.model.Experiment) Files(java.nio.file.Files) SequencePair(org.biojava.nbio.core.alignment.template.SequencePair) AminoAcidCompound(org.biojava.nbio.core.sequence.compound.AminoAcidCompound) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) UncheckedIOException(java.io.UncheckedIOException) Start2FoldResidueAnnotation(de.bioforscher.start2fold.model.Start2FoldResidueAnnotation) List(java.util.List) Stream(java.util.stream.Stream) ProtectionLevel(de.bioforscher.start2fold.model.ProtectionLevel) Alignments(org.biojava.nbio.alignment.Alignments) Document(org.jsoup.nodes.Document) Jsoup(org.jsoup.Jsoup) Elements(org.jsoup.select.Elements) InputStream(java.io.InputStream) Experiment(de.bioforscher.start2fold.model.Experiment) Start2FoldResidueAnnotation(de.bioforscher.start2fold.model.Start2FoldResidueAnnotation) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException) Document(org.jsoup.nodes.Document) Elements(org.jsoup.select.Elements)

Example 3 with Start2FoldResidueAnnotation

use of de.bioforscher.start2fold.model.Start2FoldResidueAnnotation in project jstructure by JonStargaryen.

the class A01_ReportGeneralStatistics method handleStrongFile.

private static void handleStrongFile(Path path) {
    try {
        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, path);
        boolean hasStabilityData = chain.aminoAcids().map(aminoAcid -> aminoAcid.getFeature(Start2FoldResidueAnnotation.class)).anyMatch(Start2FoldResidueAnnotation::isStrong);
        if (!hasStabilityData) {
            return;
        }
        long count = chain.aminoAcids().filter(aminoAcid -> aminoAcid.getFeature(Start2FoldResidueAnnotation.class).isStrong()).count();
        strong.add((int) count);
        weak.add((int) (chain.aminoAcids().count() - count));
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
Also used : java.util(java.util) Files(java.nio.file.Files) FishersExactTest(edu.northwestern.at.utils.math.statistics.FishersExactTest) Structure(de.bioforscher.jstructure.model.structure.Structure) IOException(java.io.IOException) StructureParser(de.bioforscher.jstructure.model.structure.StructureParser) Collectors(java.util.stream.Collectors) FunctionalResidueParser(de.bioforscher.start2fold.parser.FunctionalResidueParser) UncheckedIOException(java.io.UncheckedIOException) FunctionalResidueAnnotation(de.bioforscher.start2fold.model.FunctionalResidueAnnotation) Start2FoldResidueAnnotation(de.bioforscher.start2fold.model.Start2FoldResidueAnnotation) AccessibleSurfaceArea(de.bioforscher.jstructure.feature.asa.AccessibleSurfaceArea) SetOperations(de.bioforscher.jstructure.mathematics.SetOperations) AminoAcid(de.bioforscher.jstructure.model.structure.aminoacid.AminoAcid) Start2FoldXmlParser(de.bioforscher.start2fold.parser.Start2FoldXmlParser) Chain(de.bioforscher.jstructure.model.structure.Chain) StandardFormat(de.bioforscher.jstructure.StandardFormat) Jsoup(org.jsoup.Jsoup) Pattern(java.util.regex.Pattern) Path(java.nio.file.Path) Chain(de.bioforscher.jstructure.model.structure.Chain) Start2FoldResidueAnnotation(de.bioforscher.start2fold.model.Start2FoldResidueAnnotation) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException) Structure(de.bioforscher.jstructure.model.structure.Structure)

Aggregations

Start2FoldResidueAnnotation (de.bioforscher.start2fold.model.Start2FoldResidueAnnotation)3 IOException (java.io.IOException)3 UncheckedIOException (java.io.UncheckedIOException)3 Chain (de.bioforscher.jstructure.model.structure.Chain)2 AminoAcid (de.bioforscher.jstructure.model.structure.aminoacid.AminoAcid)2 Experiment (de.bioforscher.start2fold.model.Experiment)2 Files (java.nio.file.Files)2 Path (java.nio.file.Path)2 Collectors (java.util.stream.Collectors)2 Jsoup (org.jsoup.Jsoup)2 Document (org.jsoup.nodes.Document)2 Elements (org.jsoup.select.Elements)2 StandardFormat (de.bioforscher.jstructure.StandardFormat)1 AccessibleSurfaceArea (de.bioforscher.jstructure.feature.asa.AccessibleSurfaceArea)1 SetOperations (de.bioforscher.jstructure.mathematics.SetOperations)1 Structure (de.bioforscher.jstructure.model.structure.Structure)1 StructureParser (de.bioforscher.jstructure.model.structure.StructureParser)1 FunctionalResidueAnnotation (de.bioforscher.start2fold.model.FunctionalResidueAnnotation)1 ProtectionLevel (de.bioforscher.start2fold.model.ProtectionLevel)1 FunctionalResidueParser (de.bioforscher.start2fold.parser.FunctionalResidueParser)1