Mnova Logo

The user will be able to change or create his own multiplet report templates; by following the menu ‘Script/Edit Script’.

From Mnova 5.3.2, it will be possible to easily add new multiplet scripts to the Mnova interface (multiplet menus for example). This enhancement in the script feature will make the handle of the scripts easier for the user. It will be easier to share your scripts with another users and with this new feature it will be possible to add new possibilities in the future.

You can see below how to add a new multiplet reporter to the Mnova GUI.

1. Follow the menu ‘Script/Edit Script’ to launch the ‘Script editor’.

Thumbnail

2. Write your own script or edit the example ‘customMultipletReporter.qs’ under the script folder of Mnova (Mnovaexamplesscripts). Do not forget to include the below sentence in the script; in order to add the reporter to the program:
Env.MultipletReportersArray.push(new MyMultipletReporter());

We have created a variable in the scripts which saves a list of the known reporters. To see the list, just type in the editor:
print(Env.MultipletReportersArray)

Thumbnail

See below how to edit this script.

Thumbnail

3. Save the resulting script (for example ‘My Multiplet Reporter’) in a directory where Mnova will be able to find it and restart Mnova. To add new script directories follow the menu ‘Scripts’Scripts Directories’:

Thumbnail

4. The script will be automatically added to the Mnova GUI (for example, to the ‘Multiplet Table/Report Special/Setup’ menu). This will allow you to select the ‘Multiplet Report’ format for your analysis. Of course, you can add as many different scripts as you need.

Thumbnail

Please bear in mind that the multiplet format that you select on this dialog box, will be applied always when you select the ‘Multiplet Report’ option; however you can select any other formats for individual reports (without changing the default one) just by following the menu ‘Scripts/Report/Multiplets’ and selecting the desired format for that report.

Let’s see how to create a new multiplet reporter script from the example ‘customMultipletReporter.qs’ (stored at the ‘example/scripts’ folder of Mnova) :

/******************************************************************************************************
Copyright (C) 2009 Mestrelab Research S.L. All rights reserved.This file is part of the MNova scripting toolkit.Authorized users of MNova Software may use this file freely, but this file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*****************************************************************************************************/

var MyMultipletReporterSettingsKey = new String(“MyMultipletReporter/Custom Message”);

/* This creates a Custom Multiplet Reporter */
function MyMultipletReporter()

{
MultipletReporter.call(this);

var setts=new Settings(Application.mainWindow.scriptHandler.settings);
this.customMessage = setts.value( MyMultipletReporterSettingsKey, “My Multiplet Reporter” );

this.name = “My Multiplet Reporter”;

this.onlyElementName=false;
// Define font size and font family

this.font = “<font style=”font-size: 10pt; font-family: Times New Roman”>”;

this.nucleusTemplate=”%1″;
// Report header. %1 will be raplaced with nucleusString, %2 with frequency, %3 with solvent
this.header = this.customMessage+” %1 NMR (%2 MHz, %3) δ “;
//this.header = “Custom %1 NMR (%2 MHz, %3) δ “;

// Multiplet templates. %1 – delta, %2 – category, %3 – nH
this.reportRange = true; // set to true to get multiplet range instead of delta.
this.withoutJsTemplate = ” %1 (%2, %3H)”; // multiplet template without J’s
this.withJsTemplate = ” %1 (%2, %4, %3H)”; // multiplet template with J’s
this.rangeTemplate = “%1 – %2”;

// J’s list template. %1 – list of J’s
this.jListTemplate = “<i>J</i> = %1”;

this.jPrecision = 1; // J’s precision
this.deltaPrecision = 2; // delta precision
this.mSeparator = “, “; // multiplet separator
this.jSeparator = “, “; // J’s separator

this.start = “<html><head><title>Multiplet Report</title></head><body>” + this.font;

this.end = “.</font></body></html>”;
}

MyMultipletReporter.prototype = new MultipletReporter();
MyMultipletReporter.prototype.toString = function() { return “MyMultipletReporter()”; }

//This line adds my custom reporter to the list of reporters, this means that this reporter can be used by the general functions like reportMultipletsUser or automaticMultipletReport and it can be used to generate reports from the Multiplets Table
Env.MultipletReportersArray.push(new MyMultipletReporter());

//Uncomment this line to make this reporter the default reporter, the saved settings will be ignored, the user will not be able to modify the reporter from MNova

//Env.DefaultMultipletReporter = “My Multiplet Reporter”;

//This function can be used to generate multiplet reports
function customReportMultipletsUser(createItem)
{
var multipletTable = new MultipletTable(nmr.multipletTable()); // Get table of multiplets
var spectrum;
if(multipletTable.isValid())
spectrum = new NMRSpectrum(multipletTable.spectrum()); // Get spectrum currently shown in the table of multiplets

else
spectrum = new NMRSpectrum(nmr.activeSpectrum());

if( spectrum.isValid() )
{
var reporter = MultipletReporter.getReporterByName(“My Multiplet Reporter”);
return reporter.report(spectrum, createItem);
}
else

return undefined;
}

//Uncomment this line to use the previous function to report multiplets instead of the default one
//Env.ReportMultipletsUser = customReportMultipletsUser;

//Function to setup my reporter
function customReportMultipletsUserSetup()
{
var rep = MultipletReporter.getReporterByName(“My Multiplet Reporter”);

var diag = new Dialog();
diag.title = “Custom Setup”;

var lEdit = new LineEdit();
lEdit.text = rep.customMessage;
diag.add(lEdit);

if(diag.exec())
{
rep.customMessage = lEdit.text;

settings.setValue( MyMultipletReporterSettingsKey, rep.customMessage );
}
}

//Uncomment this line to use the previous function to setup the report multiplets
//Env.ReportMultipletsUserSetup = customReportMultipletsUserSetup;

Firstly, we are going to change the name of the ‘Multiplet Reporter’ and the message which appears at the beginning of the Multiplet Report (customMessage) to ‘My Report’ and ‘My Journal’ respectively’ (see the text below highlighted in yellow)

/* This creates a Custom Multiplet Reporter */
function MyMultipletReporter(){
MultipletReporter.call(this);var setts=new Settings(Application.mainWindow.scriptHandler.settings);
this.customMessage = setts.value( MyMultipletReporterSettingsKey, “My Journal“);this.name = “My Report”;

this.onlyElementName=false;

this.onlyElementName=false; changing false with true, we will obtain only the element name without the atomic mass (For example: H, C instead of 1H, 13C).

The function: this.font = “<font style=”font-size: 10pt; font-family: Times New Roman”>”; will define the font size and the font family of the multiplet report.

We are going to change the font of the multiplet report to 14pt and Arial:

// Define font size and font family
this.font = “<font style=”font-size:14pt; font family: Arial“>”;

will define the font size and the font family of the multiplet report.
The line: this.header = this.customMessage+ “%1 NMR (%2 MHz, %3) δ “; is used to print the header of the report, where %1 will be the nucleus (H or C), %2 the frequency of the spectrometer (in MHz), and %3 the solvent, followed by a delta symbol (d). For example: “1H NMR (500 MHz, CDCl3) ?”.
Let´s modify the header of the report by putting the ‘delta’ symbol in italic:

// Report header. %1 will be replaced with nucleusString, %2 with frequency, %3 with solvent
this.header = this.customMessage+” %1 NMR (%2 MHz, %3) <i>δ</i> “;

We can also modify the way to report the multiplet infomration

// Multiplet templates. %1 – delta, %2 – category, %3 – nH
this.reportRange = true; // set to true to get multiplet range instead of delta.
this.withoutJsTemplate = ” %1 (%2, %3H)”; // multiplet template without J’s
this.withJsTemplate = ” %1 (%2, %4, %3H)”; // multiplet template with J’s
this.rangeTemplate = “%1 – %2”;

The sentence: this.reportRange = true is used to obtain the multiplet range instead of the chemical shift.

The functions: this.withoutJsTemplate = ” %1 (%2, %3H)” and this.withJsTemplate = ” %1 (%2, %4, %3H)” are used to customize the appearance of the multiplet report by changing the positions of %1, %2, %3H, or %4 (where, %1 means: chemical shift; %2 means: type of multiplet (s, d, t, etc); %3H means: number of hydrogens and %4 means the coupling constant value). As you can see, the first line shows a multiplet without coupling constants, (while the last line shows a multiplet with coupling constants).

So, if you need to obtain something like this (japanese format):

1H NMR (300 MHz, Solvent) d ppm 6.43-6.22 (1 H, m), 3.17 (1 H, q, J = 7.15 Hz) etc…

You should modify both lines, as you can see below:

this.withoutJsTemplate = %1 (%3H, %2)”;
this.withJsTemplate = ” %1 (%3H, %2, %4 Hz)”;

If you prefer to obtain something like this:
1H NMR (300 MHz, Solvent) d ppm 1.23 (d, J = 1.2 Hz, 3 H), etc…
Just replace the original lines with:

this.withoutJsTemplate = %1 (%2, %3H)”;
this.withJsTemplate = ” %1 (%2, %4 Hz, %3H)”;

You can also customize the coupling constant format:

 // J’s list template. %1 – list of J’s
this.jListTemplate = “<i>J</i> = %1”;this.jPrecision = 1; // J’s precisionthis.deltaPrecision = 2; // delta precision
this.mSeparator = “, “; // multiplet separator
this.jSeparator = “, “; // J’s separatorthis.start = “<html><head><title>Multiplet Report</title></head><body>” + this.font;

this.end = “.</font></body></html>”;

To obtain the coupling constant symbol in normal instead of ‘italic’, just modify the script by removing the italic format (<i>J</i>). If you prefer to obtain it in “bold” just type:
this.jListTemplate = “<b>J</b> = %1”;

The following paragraph will be used to customize the appearance of the coupling constants list:

The second line is used for the precision of the coupling constants values, the next will be used for the precision of the chemical shift and the remaining two lines will print the separation (coma, colon, dots, etc.) between the multiplets and the coupling constants values.

If you need to obtain the coupling constants in descending order, replace ‘true’ with ‘false’ in the following line:

var jList = new JList(multiplet.jList());
jList.sort(true);

If you want to obtain the multiplet chemical shifts in ascending order, just replace the ‘false’ with ‘true’ in the script:

var multiplets = new Multiplets(spectrum.multiplets()); // get multiplets from spectrum
jList.sort(true);

To obtain the multiplet range in ascending order, just replace the rangeMin with rangeMax in the below line of the script:

shiftStr = this.rangeTemplate.argDec(multipletrangeMax, 0, ‘f’, this.deltaPrecision).argDec(multiplet.rangeMin, 0, ‘f’, this.deltaPrecision);

It will be possible to select a multiplet report format as the default one, without allowing the user to modify it, just by removing the two slash symbols (before this sentence:Env.DefaultMultipletReporter = “My Multiplet Reporter”;). Please bear in mind that if you do that, you will not obtain any dialog box when you follow the Menu ‘Multiplets Table/Report Special/Setup’.

//Uncomment this line to make this reporter the default reporter, the saved settings will be ignored, the user will not be able to modify the reporter from MNova
Env.DefaultMultipletReporter = “My Multiplet Reporter”;

Indeed, the variable ‘Env’ contains several environment variables which can be used to customize the Mnova behaviour. Typing print(Env) in the Script editor, you will get the list of the available variables. In the example below, we have only defined the ‘Setup’ of the ‘Multiplet Reports’. All the remaining variables are ‘undefined’.

Thumbnail

You can define the ‘DefaultMultipletReport’ variable by uncomment this line in the script:
Env.DefaultMultipletReporter = “My Multiplet Reporter”;

Doing that, the user will not be able to modify the multiplet report.

You can define the ‘ReportMultipletUser’ variable by uncomment this line of the script:
Env.ReportMultipletsUser = customReportMultipletsUser;

Defining this variable, you will have a format for the ‘multiplet report’ and the ‘copy special’ and another different (the default one) for the report which appears on top of the ‘multiplets table’.

The ‘ReportMultipletUserSetup’ is the variable defined in the menu ‘Multiplet Table/Report Special/Setup’ for the ‘Multiplet Report’.

The ‘MultipletLabelFunctions’ are different options (showed in the ‘Multiplet Properties’ dialog box) which allow the user to customize the information which appears in the multiplet boxes.

 

/* This creates a Custom Multiplet Reporter */
function MyMultipletReporter()
{

MultipletReporter.call(this);
var setts=new Settings(Application.mainWindow.scriptHandler.settings);
this.customMessage = setts.value( MyMultipletReporterSettingsKey, “My Journal” );
this.name = “My Report”;
this.onlyElementName=false;


Last modified: July 2, 2014 by