gtscript documentation

This document describes the gtscript API. gtscript is basically Lua (an embeddable scripting language) plus parts of the GenomeTools C libraries exported to Lua. Because the GenomeTools binary gt contains an embedded Lua interpreter, gtscript files can be executed with the gt binary. The parts of the GenomeTools C libraries exported to Lua (the gtscript API) are described here, for a documentation of Lua itself and its APIs, please refer to the Lua reference manual.

Notes

Classes

Sole functions

gff3_in_stream_new_sorted(filename)

Returns a new GFF3 input stream object for filename. The file filename has to be a sorted GFF3 file.


gff3_out_stream_new(genome_stream)

Returns a new GFF3 output stream which pulls its features from genome_stream.


gff3_visitor_new()

Returns a new GFF3 visitor.


ranges_sort(range_array)

Returns an array containing the ranges from array range_array in sorted order.


ranges_are_sorted(range_array)

Returns true if the ranges in array range_array are sorted, false otherwise.


reload()

Reload gt module.


features_contain_marked(features)

Returns true if the given array of features contains a marked feature, false otherwise.


features_show(features)

Print the given array of features to stdout.


features_show_marked(features)

Print all marked features (an array) to stdout.


export()

Export the content of gt table to the global environment.


display(filename)

Call external 'display' program for file filename.


show_table(tbl)

Show all keys and values of table tbl.


show(all)

Show content of the gt table.


re()

Reload the gt module and export its content to the global environment.


Class Alpha

alpha_new_protein()

Returns a new protein alphabet.


alpha:decode(code)

Returns a string containing the decoded character of the code number.


alpha:size()

Returns the size of alpha a number.


Class Bittab

bittab_new(num_of_bits)

Returns a bittab with num_of_bits many bits.


bittab:set_bit(bit)

Set bit in bittab.


bittab:unset_bit(bit)

Unset bit in bittab.


bittab:complement(src)

Store the complement of bittab src in bittab. bittab and src must have the same size.


bittab:equal(src)

Set bittab equal to bittab src. bittab and src must have the same size.


bittab:and_equal(src)

Set bittab equal to the bitwise AND of bittab and src. bittab and src must have the same size.


bittab:bit_is_set(bit)

Returns true if bit is set in bittab, false otherwise.


Class Diagram

diagram_new(feature_index, range, seqid)

Return a diagram object which contains the genome nodes given in feature_index in the given range of the sequence region with sequence ID seqid.


Class FeatureIndex

feature_index_new()

Returns a new feature_index object.


feature_index:add_sequence_region(sequence_region)

Add sequence_region to feature_index.


feature_index:add_genome_feature(genome_feature)

Add genome_feature to feature_index.


feature_index:get_features_for_seqid(seqid)

Returns the genome features for sequence ID seqid in an array.


feature_index:get_features_for_range(seqid, range)

Returns the genome features for sequence ID seqid within range in an array.


feature_index:get_first_seqid()

Returns the first sequence ID stored in feature_index.


feature_index:get_seqids()

Returns an array containins all sequence IDs stored in feature_index.


feature_index:get_range_for_seqid(seqid)

Returns the range covered by features of sequence ID seqid in feature_index.


feature_index:get_coverage(seqid, maxdist)

Computes the coverage for the sequence ID seqid. The optional maxdist parameter denotes the maximal distance two features can be apart without creating a new Range. Returns an array of Ranges denoting parts the of seqid covered by features.


feature_index:get_marked_regions(seqid, maxdist)

Returns an array of Ranges denoting parts of seqid which are covered by at least one marked feature. Internally, get_coverage() is called and the maxdist is passed along.


feature_index:render_to_png(seqid, range, png_file, width)

Render to PNG file png_file for seqid in range with optional width. If no png_file is given os.tmpname() is called to create one. Returns name of written PNG file.


feature_index:show_seqids()

Show all sequence IDs.


Class FeatureStream

feature_stream_new(feature_index)

Returns a new feature stream object over feature_index. That is, all genome nodes which are pulled through the feature stream are added to the feature_index.


Class FeatureVisitor

feature_visitor_new(feature_index)

Returns a new feature visitor object over feature_index. That is, all genome nodes which are visited by the feature visitor are added to the feature_index.


Class GenomeNode

genome_node:show(gff3_visitor)

Show genome node on stdout (using the optional gff3_visitor).


genome_node:show_marked()

Show marked parts of genome node on stdout.


Class GenomeNodeIterator

genome_node_iterator_new(genome_node)

Returns a new genome node iterator object for genome_node.


genome_node_iterator:next()

Returns the next genome node for genome_node_iterator or nil.


Class GenomeStream

genome_stream:next_tree()

Returns the next genome node for genome_stream or nil.


Class GenomeVisitor

Class Range

range_new(startpos, endpos)

Returns a new range object with start startpos and end endpos. startpos must be smaller or equal than endpos.


range:get_start()

Returns start of range.


range:get_end()

Returns end of range.


range:show()

Show range on stdout.


Class Render

render_new()

Returns a new render object.


render:to_png(diagram, filename, width)

Uses render to render the given diagram as PNG to filename. The optional width parameter sets the width of the PNG (default: 800).


Class ScoreMatrix

score_matrix_new_read_protein(path)

Returns a new protein score matrix object which has been read from file path.


score_matrix:get_dimension()

Returns the dimension of the score_matrix as number.


score_matrix:get_score(idx1, idx2)

Returns the score for idx1,idx2 as number.


Class StreamEvaluator

stream_evaluator_new(reality_stream, prediction_stream)

Returns a new stream evaluator object for the two genome streams reality_stream and prediction_stream.


stream_evaluator:evaluate(genome_visitor)

Run evaluation of stream_evaluator. All evaluated features are visited by the optional genome_visitor.


stream_evaluator:show()

Show result of stream_evaluator on stdout.