bpmanip - Include or exclude fields from bpipe file
bpmanip [-i input_file] [-v fields_to_exclude] [fields_to_include] > output_file
bpmanip reads in an existing bp file and includes or exclude data fields in the output, depending on the user input. File can either be read from STDIN or from existing files with the -i flag. bpmanip's operations are deliberately similar to that of the rdb tool column, although it doesn't support regexes yet.
Data fields are included in the output by specifying them on the command line. For example, if input.bp is a bp file that has three data fields, "weight", "position", and "direction", the following would produce an output.bp file with only one data field, "position". The values in that data field would be unchanged:
bpmanip -i input.bp position >! output.bp
If -i is not specified, STDIN is read from, but the command syntax is otherwise identical, and produces the same effect:
cat input.bp | bpmanip weight >! output.bp
To remove only a certain set of fields, specify them after using the -v flag:
bpmanip -i input.bp -v stuff weight >! output.bp
This will produce an output.bp with all fields except "stuff" and "weight".
Finally, an echo to STDERR of the user input and a running count of how many packets have been processed is available by turning verbosity on with the -w switch:
bpmanip -w -i input.bp -v stuff >! output.bp
will produce output to the screen like this:
args: -w -i input.bp -v stuff
----------------------
input mmap [exclude] = stuff
program name = bpmanip
infile = input.bp
Writing packets 1 to 10 ... Done
The following examples will assume a bp event list "input.bp",
containing 10 data packets, each with the following fields:
direction[1]
graze_angle[1]
polarization[4]
position[1]
stuff[3][3][3]
weight[1]
with a typical packet looking something like:
data packet 1:
direction[1]: : 2 2 2
graze_angle[1]: : 1
polarization[4]: : 0 | 1 | 2 | 3
position[1]: : 0 0 0
stuff[3][3][3]: [0][0]: 42 | 42 | 42
stuff[3][3][3]: [0][1]: 42 | 42 | 42
stuff[3][3][3]: [0][2]: 42 | 42 | 42
--------------------
stuff[3][3][3]: [1][0]: 42 | 42 | 42
stuff[3][3][3]: [1][1]: 42 | 42 | 42
stuff[3][3][3]: [1][2]: 42 | 42 | 42
--------------------
stuff[3][3][3]: [2][0]: 42 | 42 | 42
stuff[3][3][3]: [2][1]: 42 | 42 | 42
stuff[3][3][3]: [2][2]: 42 | 42 | 42
--------------------
weight[1]: : 235.3
bpmanip -i input.bp weight >! output.bp
will produce an output.bp
containing only the weight field.
cat input.bp | bpmanip weight >! output.bp
will produce identical output.
bpmanip -i input.bp -v stuff weight >! output.bp
produces an output.bp file with
everything but the stuff and weight
fields in the data packets.
bpmanip -i input.bp weight stuff -v stuff | bpipe_dump
produces a bp stream (in the instance,
we aren't writing to file) with just a
"weight" field ("weight" and "stuff"
were included, and then "stuff" was excluded,
leaving only "weight").
Excluding and including the exact same
list of fields will produce a helpful
error (and cause the program to exit
gracefully without producing any input).
bpmanip -w -i input.bp -v stuff >! output.bp
This software is released under the GNU General Public License. You may find a copy at
http://www.fsf.org/copyleft/gpl.html
$Revision$
Kester (Christopher) Allen ( callen@cfa.harvard.edu )