Skip to content
Martin Asser Hansen edited this page Oct 2, 2015 · 6 revisions

Biopiece: compute

Description

compute can be used to perform computations on records in stream, whether you want to add some constant to specific keys - or if you want to substract the values of sets of keys.

Usage

... | compute [options]

Options

[-?          | --help]               #  Print full usage description.
[-e <string> | --eval=<string>]      #  Evaluate extression.
[-f <string> | --format=<string>]    #  Printf like format string for output.
[-I <file!>  | --stream_in=<file!>]  #  Read input from stream file  -  Default=STDIN
[-O <file>   | --stream_out=<file>]  #  Write output to file         -  Default=STDOUT
[-v          | --verbose]            #  Verbose output.

Examples

To set a specific key to a constant, do:

... | compute -e 'CHR_BEG = 50'

To set a specific key to a string, do:

... | compute -e 'CHR = chr1'

To add a new key with the value of another key:

... | compute -e 'CHROMOSOME = CHR'

To add a constant to a specific key, such as adding 50 to the key CHR_BEG, do:

... | compute -e 'CHR_BEG = CHR_BEG - 50'

Note that CHR_BEG += 50 does not work.

Or if you want to perform an operation on two specified keys and save the value to a third key:

... | compute -e 'CHR_END = CHR_END + BED_LEN'

To specify the output format you can use the -f switch that enables printf like formatting.

E.g. to output a decimal number with two decimals (rounded):

... | compute -e 'SCORE = COUNT / LINES' -f '%.2f'

To add bogus quality SCORES to sequence type entries ala FASTQ format do:

... | compute -e 'SCORES="h" x SEQ_LEN'

See also

bioscript

Author

Martin Asser Hansen - Copyright (C) - All rights reserved.

mail@maasha.dk

August 2007

License

GNU General Public License version 2

http://www.gnu.org/copyleft/gpl.html

Help

compute is part of the Biopieces framework.

http://www.biopieces.org

Clone this wiki locally