Need help or advice ? Come to the Icy club ! - Every Wenesday morning from 9h30 to 12h30 - Francois Jacob Building - Main hall - Pasteur
Register

Math Operations

by tprovoost / Thomas Provoost

Example on how to use the Math Operations Plugin in scripts.

version 2 (last version):

download to use and modify in Icy. How do I use scripts ? A Problem ? ask the community.
Changelog for this version: * simpler code
importClass(Packages.plugins.ylemontag.mathoperations.functors.Functor1)
importClass(Packages.plugins.ylemontag.mathoperations.Expression)
importClass(Packages.icy.gui.main.MainInterface)
importClass(Packages.plugins.ylemontag.mathoperations.Functor)

// get the sequence
seq = getSequence()
if (seq == null) throw "Please open a sequence first"

// create the expression
formula = "a ^ 2"

// The Functor parses the formula, 
// and apply() assigns its arguments to the variables of the formula.
// Ex : Here, seq is assigned to "a".
seqRes = Functor1.parse(formula).apply(seq)

gui.addSequence(seqRes)

This script has no documentation. A Problem ? ask the community.


Previous versions:


version 1:

download to use and modify in Icy.
Changelog for this version: initial version
importClass(Packages.icy.gui.main.MainInterface)
importClass(Packages.plugins.ylemontag.mathoperations.Functor)
importClass(Packages.plugins.ylemontag.mathoperationspp.Expression)

// get the sequence
seq = getSequence()
if (seq == null) throw "Please open a sequence first"

// create the expression
formula = "seq ^ 2"

// get the formula as a Function
fn = Expression.parse(formula).getFunctor()

// create an array of arguments
args = [ seq ]

// apply the Function to the arguments
seq = fn["apply(icy.sequence.Sequence[])"](args)

gui.addSequence(seq)


Icy script publication Id : X4O4N3