(chromatogram_map, targeted, precursor_tolerance, product_tolerance, allow_unmapped=True, allow_double_mappings=False)
| 9 | """ |
| 10 | |
| 11 | def algorithm(chromatogram_map, targeted, precursor_tolerance, product_tolerance, allow_unmapped=True, allow_double_mappings=False): |
| 12 | |
| 13 | output = copy.copy(chromatogram_map) |
| 14 | output.clear(False); |
| 15 | empty_chromats = [] |
| 16 | output.setChromatograms(empty_chromats); |
| 17 | |
| 18 | notmapped = 0 |
| 19 | for chrom in chromatogram_map.getChromatograms(): |
| 20 | mapped_already = False |
| 21 | for transition in targeted.getTransitions(): |
| 22 | if (abs(chrom.getPrecursor().getMZ() - transition.getPrecursorMZ()) < precursor_tolerance and |
| 23 | abs(chrom.getProduct().getMZ() - transition.getProductMZ()) < product_tolerance): |
| 24 | if mapped_already: |
| 25 | this_peptide = targeted.getPeptideByRef(transition.getPeptideRef() ).sequence |
| 26 | other_peptide = chrom.getPrecursor().getMetaValue("peptide_sequence") |
| 27 | print "Found mapping of", chrom.getPrecursor().getMZ(), "/", chrom.getProduct().getMZ(), "to", transition.getPrecursorMZ(), "/",transition.getProductMZ() |
| 28 | print "Of peptide", this_peptide |
| 29 | print "But the chromatogram is already mapped to", other_peptide |
| 30 | if not allow_double_mappings: raise Exception("Cannot map twice") |
| 31 | mapped_already = True |
| 32 | precursor = chrom.getPrecursor(); |
| 33 | peptide = targeted.getPeptideByRef(transition.getPeptideRef() ) |
| 34 | precursor.setMetaValue("peptide_sequence", peptide.sequence) |
| 35 | chrom.setPrecursor(precursor) |
| 36 | chrom.setNativeID(transition.getNativeID()) |
| 37 | if not mapped_already: |
| 38 | notmapped += 1 |
| 39 | print "Did not find a mapping for chromatogram", chrom.getNativeID() |
| 40 | if not allow_unmapped: raise Exception("No mapping") |
| 41 | else: |
| 42 | output.addChromatogram(chrom) |
| 43 | |
| 44 | if notmapped > 0: |
| 45 | print "Could not find mapping for", notmapped, "chromatogram(s)" |
| 46 | |
| 47 | |
| 48 | dp = pyopenms.DataProcessing() |
| 49 | # dp.setProcessingActions(ProcessingAction:::FORMAT_CONVERSION) |
| 50 | pa = pyopenms.DataProcessing().ProcessingAction().FORMAT_CONVERSION |
| 51 | dp.setProcessingActions(set([pa])) |
| 52 | |
| 53 | chromatograms = output.getChromatograms(); |
| 54 | for chrom in chromatograms: |
| 55 | this_dp = chrom.getDataProcessing() |
| 56 | this_dp.append(dp) |
| 57 | chrom.setDataProcessing(this_dp) |
| 58 | |
| 59 | output.setChromatograms(chromatograms); |
| 60 | return output |
| 61 | |
| 62 | def main(options): |
| 63 | precursor_tolerance = options.precursor_tolerance |
no test coverage detected