Ordinal() in JavaScript CLIC plugin and comma operator

Discuss with developer team, share useful tips, report bugs, request new features and anything else
Post Reply
Posts: 2
Joined: September 23rd, 2013, 6:09 am

Ordinal() in JavaScript CLIC plugin and comma operator

Post by mwilde1 » December 5th, 2014, 6:28 am

I have just started investigating the potential of CLIC expressions and User Defined CLIC expressions with JavaScript. I don't have experience in scripting so have spent awhile experimenting in Notepad and have been heavily reliant on working from examples of script in plugins you gave previously in a different discussion (http://www.gcimage.com/forum/viewtopic.php?f=5&t=23).

Is it possible to use the Ordinal() function when writing a plugin? I noticed in your previous Dons_script.js, when assigning the base peak as part of the function's criteria, you use the MassRank() function e.g. (massSpec.getMassRank(1) == 149). The Ordinal() function in GC Image allows you to set a range of orders e.g. Ordinal(81)<=5, so it will return spectra containing m/z 81 in the top 5 intensity peaks. However as far as I understand with MassRank(), you can only set 1 rank e.g. MassRank(1)=67 and not MassRank(1-5)=67.

I've been trying to write a function, where the criteria are; that at least 3 of 5 different ions (e.g. m/z 69, 83, 97, 111 and 125) are in the top 5 most intense peaks of a mass spectrum. However my attempts to use the Ordinal() function within the plugin have been unsuccessful e.g. (massSpec.getOrdinal(67) <= 5) and I could not find any examples within your example plugins.

Secondly, could you give an example of using the comma operator ',' or when it would be necessary to use the comma operator in the CLIC calculator? In the users guide it says the ',' groups operators and operands but the use of parentheses is highly recommended to insure the intended order of evaluation.

Many thanks.

Posts: 143
Joined: October 7th, 2011, 10:16 am

Re: Ordinal() in JavaScript CLIC plugin and comma operator

Post by qtao » December 6th, 2014, 12:12 pm

There are a couple of getOrdinal() functions available from MassSpectrum objects for scripting. The one used by CLIC Expression's built-in Ordinal() is as calling:

Code: Select all

, which takes the m/z as a range string in double quotes. If you use getOrdinal(67) that takes the m/z as an integer, you need to be sure that the spectrum is a nominal spectrum with integer masses. Otherwise, it won't find the exact same m/z you specified.

You may want to test the above directly in the CLIC Tool first before adding it to your script because debugging the script is not easy if you are not familiar with JavaScript. Also, you can combine built-in functions with custom functions together in a CLIC expression, for example,

Code: Select all

(Ordinal(67)<5) & MyScriptFunction() 
, so that you do not need to put every constraint in a script.

WRT "the comma operator", comma is not an operator in CLIC expressions. It is only used as a separator in a CLIC expression. In the user's guide, "," is just the plain text comma in the sentence.

Post Reply