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.
Ordinal() in JavaScript CLIC plugin and comma operator
-
- Posts: 2
- Joined: September 23rd, 2013, 6:09 am
-
- Posts: 230
- Joined: October 7th, 2011, 10:16 am
Re: Ordinal() in JavaScript CLIC plugin and comma operator
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:
, 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,
, 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.
Code: Select all
massSpec.getOrdinal("67")
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()
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.