Script

Math Operation Two Sequences

Publication ID: ICY-E7R1W2

Short Description

This script shows how to use the Math Operation on two sequences, with a more advanced formula.

Versions

  • Version 1 • Released on: 2013-09-20 15:43:13
    Download
    Description:

    initial version

    importClass(Packages.plugins.ylemontag.mathoperations.functors.Functor2)
    
    // get the sequence
    if (gui.getSequences().size() < 2)
    	throw "Please open two sequences first"
    
    seq = gui.getSequences().get(0)
    seq2 = gui.getSequences().get(1)
    
    // create the expression
    formula = "a + 2 * min(b, 10)"
    
    
    // The Functor parses the formula, 
    // and apply() assigns its arguments to the variables of the formula.
    // Ex : Here, seq is assigned to "a" and seq2 is assigned to "b"
    seqRes = Functor2.parse(formula).apply(seq, seq2)
    
    gui.addSequence(seqRes)

Leave a Review