Search in sources :

Example 1 with Start2FoldResidueAnnotation

use of de.bioforscher.jstructure.efr.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.debug("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.jstructure.efr.model.Experiment) Start2FoldResidueAnnotation(de.bioforscher.jstructure.efr.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.jstructure.efr.model.Start2FoldResidueAnnotation in project jstructure by JonStargaryen.

the class Start2FoldXmlParser method parseSpecificExperiment.

public static void parseSpecificExperiment(Chain chain, InputStream inputStream, List<Integer> experimentIds) {
    logger.debug("ids: {}", experimentIds);
    try {
        // assign baseline resp. entry container for each residue if not already happened
        chain.aminoAcids().filter(aminoAcid -> !aminoAcid.getFeatureContainer().getFeatureOptional(Start2FoldResidueAnnotation.class).isPresent()).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());
        logger.debug("processing {} experiments", experiments.size());
        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) ProtectionLevel(de.bioforscher.jstructure.efr.model.ProtectionLevel) Experiment(de.bioforscher.jstructure.efr.model.Experiment) SimpleGapPenalty(org.biojava.nbio.alignment.SimpleGapPenalty) Method(de.bioforscher.jstructure.efr.model.Method) 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) Start2FoldResidueAnnotation(de.bioforscher.jstructure.efr.model.Start2FoldResidueAnnotation) 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) List(java.util.List) Stream(java.util.stream.Stream) 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.jstructure.efr.model.Experiment) Start2FoldResidueAnnotation(de.bioforscher.jstructure.efr.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.jstructure.efr.model.Start2FoldResidueAnnotation in project jstructure by JonStargaryen.

the class Start2FoldXmlParser method parseStability.

public static void parseStability(Chain chain, InputStream inputStream) {
    try {
        // assign baseline resp. entry container for each residue if not already happened
        chain.aminoAcids().filter(aminoAcid -> !aminoAcid.getFeatureContainer().getFeatureOptional(Start2FoldResidueAnnotation.class).isPresent()).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 -> experiment.getMethod() == Method.STABILITY).collect(Collectors.toList());
        for (Experiment experiment : experiments) {
            assignValuesForStrong(experiment, chain);
        }
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
Also used : LoggerFactory(org.slf4j.LoggerFactory) ProteinSequence(org.biojava.nbio.core.sequence.ProteinSequence) ProtectionLevel(de.bioforscher.jstructure.efr.model.ProtectionLevel) Experiment(de.bioforscher.jstructure.efr.model.Experiment) SimpleGapPenalty(org.biojava.nbio.alignment.SimpleGapPenalty) Method(de.bioforscher.jstructure.efr.model.Method) 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) Start2FoldResidueAnnotation(de.bioforscher.jstructure.efr.model.Start2FoldResidueAnnotation) 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) List(java.util.List) Stream(java.util.stream.Stream) 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.jstructure.efr.model.Experiment) Start2FoldResidueAnnotation(de.bioforscher.jstructure.efr.model.Start2FoldResidueAnnotation) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException) Document(org.jsoup.nodes.Document) Elements(org.jsoup.select.Elements)

Aggregations

Experiment (de.bioforscher.jstructure.efr.model.Experiment)3 Start2FoldResidueAnnotation (de.bioforscher.jstructure.efr.model.Start2FoldResidueAnnotation)3 IOException (java.io.IOException)3 UncheckedIOException (java.io.UncheckedIOException)3 Document (org.jsoup.nodes.Document)3 Elements (org.jsoup.select.Elements)3 Method (de.bioforscher.jstructure.efr.model.Method)2 ProtectionLevel (de.bioforscher.jstructure.efr.model.ProtectionLevel)2 Chain (de.bioforscher.jstructure.model.structure.Chain)2 AminoAcid (de.bioforscher.jstructure.model.structure.aminoacid.AminoAcid)2 InputStream (java.io.InputStream)2 Files (java.nio.file.Files)2 Path (java.nio.file.Path)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 Stream (java.util.stream.Stream)2 Alignments (org.biojava.nbio.alignment.Alignments)2 SimpleGapPenalty (org.biojava.nbio.alignment.SimpleGapPenalty)2 SubstitutionMatrixHelper (org.biojava.nbio.core.alignment.matrices.SubstitutionMatrixHelper)2 SequencePair (org.biojava.nbio.core.alignment.template.SequencePair)2