sequaljs
Version:
JavaScript/TypeScript library for parsing and manipulating ProForma peptide sequence notation
72 lines (71 loc) • 2.4 kB
JavaScript
;
/**
* This module provides functionality for fragmenting sequences into ion fragments for mass spectrometry analysis.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.FragmentFactory = exports.cz = exports.by = exports.ax = void 0;
exports.fragmentNonLabile = fragmentNonLabile;
exports.fragmentLabile = fragmentLabile;
const ion_1 = require("./ion");
exports.ax = "ax";
exports.by = "by";
exports.cz = "cz";
/**
* Calculate non-labile modifications and yield associated transitions.
*
* For example, "by" would yield a tuple of "b" and "y" transitions.
*
* @param sequence - The sequence to be fragmented
* @param fragmentType - The type of fragment transition (e.g., "by", "ax")
*/
function* fragmentNonLabile(sequence, fragmentType) {
for (let i = 1; i < sequence.seqLength; i++) {
const left = new ion_1.Ion(sequence.getItem([0, i]), 1, fragmentType[0], i);
const right = new ion_1.Ion(sequence.getItem(i), 1, fragmentType[1], sequence.seqLength - i);
yield [left, right];
}
}
/**
* Calculate all labile modification variants for the sequence and its associated labile modifications.
*
* @param sequence - The sequence to be fragmented
* @returns An Ion object representing the fragmented sequence with labile modifications
*/
function fragmentLabile(sequence) {
let fragmentNumber = 0;
for (const p in sequence.mods.keys()) {
const modList = sequence.mods.get(Number(p));
if (modList) {
for (const i of modList) {
if (i.labile) {
fragmentNumber += i.labileNumber;
}
}
}
}
return new ion_1.Ion(sequence, 1, "Y", fragmentNumber);
}
/**
* A factory class for generating ion fragments from sequences.
*/
class FragmentFactory {
/**
* Initialize a FragmentFactory object.
*
* @param fragmentType - The type of fragment transition (e.g., "by", "ax")
* @param ignore - A list of modifications to ignore
*/
constructor(fragmentType, ignore = []) {
this.fragment_type = fragmentType;
this.ignore = ignore || [];
}
/**
* Set the list of modifications to ignore.
*
* @param ignore - A list of modifications to ignore
*/
setIgnore(ignore) {
this.ignore = ignore;
}
}
exports.FragmentFactory = FragmentFactory;