You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The part 'in the worker' should be replaced by the new methods
// SAME CODE AS MF FROM MM (All elements)varelements=API.getData("elementTable");varoptions=API.getData("preferences");varmodification=options.modification;varexperimental=API.getData("experimental");if(experimental){experimental=experimental.get();}if(!elements){return;}functiongetSymbol(element){varsymbol=element.symbol;if(!symbol.match(/^[A-Z][a-z]?$/)){symbol="{"+symbol+"}";}returnsymbol;}varbaseRange="("+modification+")";for(vari=0;i<elements.length;i++){varelement=elements[i];if(element.many==true&&element.min>=0&&element.max>0&&element.max>=element.min){baseRange+=getSymbol(element);if(element.max!=element.min){baseRange+=element.min+"-"+element.max;}else{baseRange+=element.min;}baseRange+=" ";}}// we will combine all the elements with all the one where only one is presentvarresultsMM=getResult(baseRange,options.mass,options).results;varstart=Date.now();for(vari=0;i<elements.length;i++){varelement=elements[i];if(element.one==true&&element.min>=0&&element.max>0&&element.max>=element.min){varsymbol=getSymbol(element);if(element.min==0){varrange=symbol+"1-"+element.max;}else{varrange=symbol+element.min+"-"+element.max;}resultsMM=resultsMM.concat(getResult(baseRange+range,options.mass,options).results);}}functiongetCalculationOptions(userOptions,mfRange,targetMass){varoptions=JSON.parse(JSON.stringify(userOptions));options.mfRange=mfRange;options.typedResult=true;options.useUnsaturation=false;options.maxNumberRows=100;options.decimalsMass=4;options.decimalsPPM=3;options.gaussianWidth=0;options.addExperimentalExtract=true;options.bestOf=0;if(userOptions.resolution){options.massRange=Math.min(0.5,targetMass/userOptions.resolution*4);options.fwhm=targetMass/userOptions.resolution;}returnoptions;}functiongetResult(mfRange,targetMass){varcalculationOptions=getCalculationOptions(options,mfRange,targetMass);varresult=CE.mfFromMonoisotopicMass(targetMass,calculationOptions);returnresult;}// we will create UNIQUE MFvarexistingMF={};varmfs=[];varuniqueResults=[];for(vari=0;i<resultsMM.length;i++){varmf=resultsMM[i].mf.value;if(!existingMF[mf]){uniqueResults.push(resultsMM[i]);existingMF[mf]=true;mfs.push({mf:mf});}}uniqueResults.sort(function(a,b){returnMath.abs(a.error)-Math.abs(b.error);});// we could already display the results ... and make the detailed analysis// we add the abs ppmuniqueResults=uniqueResults.map(function(a){a.absppm=Math.abs(a.ppm*100)/100;returna;})API.createData("results",uniqueResults);if(options.calculateSimilarity!=true||!experimental){return;}setAsync();// we will do tehe calculations in workersvarresults=[];/* --------------------------------------------// Beginning of the worker-------------------------------------------------*/varcalculationOptions=getCalculationOptions(options);varmanager=API.cache('MFprocessor');manager.postAll('init',[experimental,calculationOptions]).then(function(){console.log('All workers responded to init');},function(e){console.log('Workers init error: ',e);});API.createData("totalMFs",mfs.length);varprocessedMFs=0;mfs.forEach(function(mf){manager.post('data',[mf.mf]).then(function(result){addResult(mf,result);},function(error){console.log(error);}).then(// in all the cases we incrementfunction(){processedMFs++;API.doAction("incrementProgress");if(processedMFs===mfs.length){// finishfinish();}});});functionaddResult(mf,result){results.push(result);result.parts=mf;if(results.length>options.maxResults*2){results=CE.bestResults(results,options.bestOf,options.maxResults,options.minSimilarity);}}functionfinish(){results=CE.bestResults(results,options.bestOf,options.maxResults,options.minSimilarity);results=results.map(function(a){varppm=((a.msem-options.mass)/(a.msem))*1e6;a.ppm=Math.round(ppm*100)/100;a.absppm=Math.abs(a.ppm*100)/100;returna;})API.createData("results",results);console.log("Calculation time: "+(Date.now()-start));done();}
The text was updated successfully, but these errors were encountered:
We would need couple of methods methods
This could be done in the init script of the visualizer
var mfProcessor = new CCE.MFProcessorWorrker ({ -- options for max process --})
mfProcessor would be a new class
Methods available on mfProcessor
process(mfs, experimental, options)
options:
init
var mfProcessor = API.cache('MFprocessor');
mfProcessor.init(experimental, calculationOptions);
// should return a promise
reset
// would kill all the running process and recreate the workers
API.cache('MFprocessor').reset()
;
Example of code in the visualizer
In the init script:
In an executor:
Current code in the code executor
The part 'in the worker' should be replaced by the new methods
The text was updated successfully, but these errors were encountered: