.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Zerg 3pm" .TH Zerg 3pm 2024-03-07 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Zerg \- a lexical scanner for BLAST reports. .SH SYNOPSIS .IX Header "SYNOPSIS" use Zerg; .SH DESCRIPTION .IX Header "DESCRIPTION" This manpage describes the Zerg library and its interface for use with Perl. .PP The Zerg library contains a C/flex lexical scanner for BLAST reports and a set of supporting functions. It is centered on a "get_token" function that scans the input for specified lexical elements and, when one is found, returns its code and value to the user. .PP It is intended to be fast: for that we used flex, which provides simple regular expression matching and input buffering in the generated C scanner. And it is intended to be simple in the sense of providing just a lexical scanner, with no features whose support could slow down its main function. .SS FUNCTIONS .IX Subsection "FUNCTIONS" \&\fBzerg_get_token()\fR is the core function of this module. Each time it is called, it scans the input BLAST report for the next "interesting" lexical element and returns its code and value. Codes are listed in the section "EXPORTED CONSTANTS (TOKEN CODES)". Code zero (not listed) means end of file. .PP .Vb 1 \& ($code, $value) = Zerg::zerg_get_token(); .Ve .PP zerg_open_file($filename) opens \f(CW$filename\fR in read-only mode and set it as the input to the scanner. If this function is not called, the standard input is used. .PP .Vb 1 \& Zerg::zerg_open_file($filename); .Ve .PP \&\fBzerg_close_file()\fR closes the file opened with \fBzerg_open_file()\fR. .PP \&\fBzerg_get_token_offset()\fR returns the byte offset (relative to the beginning of file) of the last token read. (See section BUGS). .PP zerg_ignore($code) instructs zerg_get_token not to return when it finds a token with code \f(CW$code\fR. .PP \&\fBzerg_ignore_all()\fR does zerg_ignore on all token codes. .PP zerg_unignore($code) instructs zerg_get_token to return when it finds a token with code \f(CW$code\fR. .PP \&\fBzerg_unignore_all()\fR does zerg_unignore on all token codes. .PP .Vb 4 \& Example: \& Zerg::zerg_ignore_all(); \& Zerg::zerg_unignore(QUERY_NAME); \& Zerg::zerg_unignore(SUBJECT_NAME); .Ve .SS "EXPORTED CONSTANTS (TOKEN CODES)" .IX Subsection "EXPORTED CONSTANTS (TOKEN CODES)" .Vb 10 \& ALIGNMENT_LENGTH \& BLAST_VERSION \& CONVERGED \& DATABASE \& DESCRIPTION_ANNOTATION \& DESCRIPTION_EVALUE \& DESCRIPTION_HITNAME \& DESCRIPTION_SCORE \& END_OF_REPORT \& EVALUE \& GAPS \& HSP_METHOD \& IDENTITIES \& NOHITS \& PERCENT_IDENTITIES \& PERCENT_POSITIVES \& POSITIVES \& QUERY_ALI \& QUERY_ANNOTATION \& QUERY_END \& QUERY_FRAME \& QUERY_LENGTH \& QUERY_NAME \& QUERY_ORIENTATION \& QUERY_START \& REFERENCE \& ROUND_NUMBER \& ROUND_SEQ_FOUND \& ROUND_SEQ_NEW \& SCORE \& SCORE_BITS \& SEARCHING \& SUBJECT_ALI \& SUBJECT_ANNOTATION \& SUBJECT_END \& SUBJECT_FRAME \& SUBJECT_LENGTH \& SUBJECT_NAME \& SUBJECT_ORIENTATION \& SUBJECT_START \& TAIL_OF_REPORT \& UNMATCHED .Ve .SS "NOTES ON THE SCANNER" .IX Subsection "NOTES ON THE SCANNER" Some BLAST parsers rely on some simple regular expression matches to conclude about token types and values. For example: an input line matching /^Query=\es(\eS+)/ should make such a "loose" parser to infer that a token was found, it is a query name and its value is \&\f(CW$1\fR. Although improbable, it is perfectly possible for an anotation field to match /^Query=\es(\eS+)/. Worse than this is the fact that those parsers are often unable to detect corrupt or truncated BLAST reports, possibly producing inaccurate information. .PP The scanner provided by this library is much more stringent: for a token to match it must be in its place in the context of a BLAST report. For example: in a single BLAST report, a QUERY_NAME cannot follow another QUERY_NAME. The scanner can be thought as, and in fact it is, a big regular expression that matches an entire BLAST report. .PP A special token code (UNMATCHED) is provided for cases in which the input text does not match any other lexical rule of the scanner. When an umnacthed character is found, either the report is corrupt or the scanner has a bug. .PP If you are interested in only a few token codes, try to \fBzerg_ignore()\fR as much codes you can. This will avoid unnecessary function calls that eat a lot of CPU. .SH EXAMPLES .IX Header "EXAMPLES" This program prints the code and the value of each token it finds. .PP .Vb 3 \& #!/usr/bin/perl \-w \& use strict; \& use Zerg; \& \& my ($code, $value); \& while((($code, $value)= Zerg::zerg_get_token()) && $code) \& { \& print "$code\et$value\en"; \& } .Ve .PP The program below is a "syntax checker". The presence of UNMATCHEDs is a strong indicator of problems in the BLAST report. (See section NOTES ON THE SCANNER) .PP .Vb 3 \& #!/usr/bin/perl \-w \& use strict; \& use Zerg; \& \& my ($code, $value); \& \& Zerg::zerg_ignore_all(); \& Zerg::zerg_unignore(UNMATCHED); \& \& while((($code, $value)= Zerg::zerg_get_token()) && $code) \& { \& print "UNMATCHED CHAR:\et$value\en"; \& } .Ve .SH BUGS .IX Header "BUGS" The tokens DESCRIPTION_ANNOTATION, DESCRIPTION_SCORE and DESCRIPTION_EVALUE are scanned all at once and released one by one on user request. So, if the user wants to get any of these fields, they must be unignored BEFORE scanning DESCRIPTION_ANNOTATION. .PP \&\fBzerg_get_token_offset()\fR may return incorrect values for these tokens and those that are modified by the parser, namely: QUERY_LENGTH, SUBJECT_LENGTH, EVALUE, GAPS. .SH TODO .IX Header "TODO" Add more tokens to the scanner as the need for that appears. .SH AUTHOR .IX Header "AUTHOR" ApuĆ£ Paquola, IQ-USP Bioinformatics Lab, apua@iq.usp.br .PP Laszlo Kajan , Technical University of Munich, Germany .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fBperl\fR\|(1), \fBflex\fR\|(1), http://www.bioperl.org, http://www.ncbi.nlm.nih.gov/BLAST