def score_chromatograms(self, merged):
     chroma_scoring_model = self.peak_shape_scoring_model
     scored_merged = []
     n = len(merged)
     i = 0
     for c in merged:
         i += 1
         if i % 500 == 0:
             self.log("%0.2f%% chromatograms evaluated (%d/%d) %r" % (i * 100. / n, i, n, c))
         try:
             scored_merged.append(ChromatogramSolution(c, scorer=chroma_scoring_model))
         except (IndexError, ValueError) as e:
             self.log("Could not score chromatogram %r due to %s" % (c, e))
             scored_merged.append(ChromatogramSolution(c, score=0.0))
     return scored_merged
 def evaluate_chromatogram(self, chromatogram):
     score_set = self.scoring_model.compute_scores(chromatogram)
     score = score_set.product()
     return ChromatogramSolution(chromatogram,
                                 score,
                                 scorer=self.scoring_model,
                                 score_set=score_set)
 def evaluate_chromatogram(self, chromatogram):
     score_set = self.scoring_model.compute_scores(chromatogram)
     logitsum_score = score_set.logitsum()
     return ChromatogramSolution(chromatogram,
                                 logitsum_score,
                                 scorer=self.scoring_model,
                                 score_set=score_set)
Example #4
0
    def create(self, structure, chromatogram, shift):
        chrom = GlycopeptideChromatogram(structure, ChromatogramTreeList())
        chrom = chrom.merge(chromatogram, shift)

        # If there is another identification that this wasn't merged with because of varying
        # errors in apex time matching, things break down. Check just in case we really want
        # to merge here.
        try:
            existing = self.get_identified_structure_for(structure)
            if existing.chromatogram.common_nodes(chrom):
                return None
            else:
                return self.merge(structure, chromatogram, shift)
        except KeyError:
            pass
        ms1_model = self.ms1_scoring_model
        chrom = ChromatogramSolution(chrom,
                                     ms1_model.logitscore(chrom),
                                     scorer=ms1_model)
        chrom = TandemAnnotatedChromatogram(chrom)
        sset = MultiScoreSpectrumSolutionSet(None,
                                             [FakeSpectrumMatch(structure)])
        sset.q_value = sset.best_solution().q_value
        idgp = IdentifiedGlycopeptide(structure, [sset], chrom)
        return idgp
    def convert(self, *args, **kwargs):
        chromatogram_scoring_model = kwargs.pop(
            "chromatogram_scoring_model", GeneralScorer)
        chromatogram = self.chromatogram.convert(*args, **kwargs)
        composition = self.composition_group.convert() if self.composition_group else None
        chromatogram.composition = composition
        sol = MemoryChromatogramSolution(
            chromatogram, self.score, chromatogram_scoring_model, self.internal_score)
        used_as_mass_shift = []
        for pair in self.used_as_mass_shift:
            used_as_mass_shift.append((pair[0], pair[1].convert()))
        sol.used_as_mass_shift = used_as_mass_shift

        ambiguous_with = []
        for pair in self.ambiguous_with:
            ambiguous_with.append((pair[0], pair[1].convert()))
        sol.ambiguous_with = ambiguous_with
        return sol
Example #6
0
    def convert(self, *args, **kwargs):
        chromatogram_scoring_model = kwargs.pop("chromatogram_scoring_model",
                                                GeneralScorer)
        chromatogram = self.chromatogram.convert(*args, **kwargs)
        composition = self.composition_group.convert(
        ) if self.composition_group else None
        chromatogram.composition = composition
        sol = MemoryChromatogramSolution(chromatogram, self.score,
                                         chromatogram_scoring_model,
                                         self.internal_score)
        used_as_adduct = []
        for pair in self.used_as_adduct:
            used_as_adduct.append((pair[0], pair[1].convert()))
        sol.used_as_adduct = used_as_adduct

        ambiguous_with = []
        for pair in self.ambiguous_with:
            ambiguous_with.append((pair[0], pair[1].convert()))
        sol.ambiguous_with = ambiguous_with
        return sol