-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Find fragmentation contribution for each bond hose #50
Comments
First version for fragmentation contribution of each bond const {quantile} = require("simple-statistics");
/** Experimental data & In silico data*/
let FragmentationResult = [
{ mf: 'C8H10(+)', em: 133.4, bondHose: 'LPQR'},
{ mf: 'C6H5(+)', em: 217.1,bondHose: 'ABCD'},
{ mf: 'C2H5(+)', em: 252.5,bondHose: 'CDAG'},
{ mf: 'C7H7(+)', em: 301.5,bondHose: 'LRKF'},
{ mf: 'CH3(+)', em: 350.5,bondHose: 'PSZU' },
];
const Exp =[82,1.113586,90.1,23.830735,110.5,1.113586,117.9,3.11804,133.4,10.022272,134,6.681514,134.9,1.55902,163.1,22.271715,165.9,0.445434,171.2,13.140312,180.1,2.004454,202.5,2.227171,217.1,3.563474,218.1,3.11804,223,0.890869,224.7,1.113586,234.4,3.340757,235.3,5.345212,243.6,9.576837,244.4,1.55902,252.5,12.026726,260.3,5.790646,261.5,4.231626,269.3,1.113586,274.7,0.890869,277.4,0.668151,278.2,3.340757,289.9,2.895323,292.4,2.004454,300.7,2.227171,301.5,16.035635,308.1,13.585746,333.5,4.899777,350.5,100];
const MRef = [4.899777]; // Intensity reference of M+ ion
function contribution(FragmentationResult,Exp,MRef){
/** organisation of experimental data*/
let Spec = {
column1: [],
column2: []
}
for (let i=0; i<Exp.length/2; i++){
Spec.column1.push(Exp[i*2]);
Spec.column2.push(Exp[i*2+1]);
}
/** Normalisation of intensity in function of M+ ion intensity*/
let Int = {
column1:[],
column2:[],
column3:[]
};
for (let i=0; i<Spec.column2.length; i++){
Int.column1.push(Spec.column2[i]/MRef);
}
/** Non-normalized contrubtion calculation*/
let Sumint = 0;
for (let i=0;i<Int.column1.length;i++){
Sumint+=Int.column1[i]
}
for(let i=0; i<Int.column1.length;i++){
let Intsumi= Sumint-Int.column1[i];
let Cipre = Int.column1[i]/Intsumi;
Int.column2.push(Cipre)
}
/** Normalisation of contribution*/
let Maxci = Math.max(...Int.column2)
let Minci = Math.min(...Int.column2)
for(let i=0; i<Int.column1.length;i++){
let Delta =Maxci-Minci;
let Contribution = (Int.column2[i]-Minci)/Delta;
Int.column3.push(Contribution);
}
/** Merge m/z whit contribution*/
let Fragmentcont = {
column1: [],
column2: []
}
for(let i=0; i<Int.column1.length;i++){
Fragmentcont.column1.push(Spec.column1[i]);
Fragmentcont.column2.push(Int.column3[i]);
}
/** Statistics*/
let Qsindex = ["25th percentile","50th percentile","75th percentile"]
let Qs = quantile(Fragmentcont.column2,[ 0.25, 0.5,0.75])
let ContStats = {Qsindex,Qs};
/**contribution of each bond */
let Bondcont = {
bondHose: [],
Cont: []
}
for(let i=0; i<FragmentationResult.length;i++){
let emi = FragmentationResult[i].em;
for (let s=0; s<Fragmentcont.column1.length; s++){
if (emi===Fragmentcont.column1[s]){
Bondcont.bondHose.push(FragmentationResult[i].bondHose);
Bondcont.Cont.push(Fragmentcont.column2[s])
}
}
}
return {Bondcont, ContStats}
}
let Results=contribution(FragmentationResult,Exp,MRef)
console.log(Results) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We have an experimental mass spectrum:
[{x:100, y:100}, {x:110, y:10}, ...]
We have a molfile (or smiles):
CCc1ccccc1
(ethylbenzene)We calculate all possible fragments + monoisotopic mass
The text was updated successfully, but these errors were encountered: