              *** STELLAR - the SwifT Exact LocaL AligneR ***
                 http://www.seqan.de/projects/stellar.html
                               December, 2010
				 
---------------------------------------------------------------------------
Table of Contents
---------------------------------------------------------------------------
  1.   Overview
  2.   Installation
  3.   Usage
  4.   Output Format
  5.   Examples
  6.   Contact

---------------------------------------------------------------------------
1. Overview
---------------------------------------------------------------------------

STELLAR is a tool for finding pairwise local alignments between long 
genomic or very many short sequences. It identifies all local alignments
with a maximal error rate and a minimal length, whereby errors can be
mismatches, insertions or deletions (edit operations).
STELLAR applies the SWIFT filter algorithm to identify parallelograms of
the alignment matrix that overlap with a potential local alignment. These
parallelograms are verified subsequently and the resulting local alignments
written to the output file.

---------------------------------------------------------------------------
2. Installation
---------------------------------------------------------------------------

STELLAR is distributed with SeqAn - The C++ Sequence Analysis Library (see 
http://www.seqan.de). To build STELLAR do the following:

  1)  Download the latest snapshot of SeqAn
  2)  Unzip it to a directory of your choice (e.g. seqan)
  3)  cd seqan/projects/library/cmake
  4)  cmake . -DCMAKE_BUILD_TYPE=Release
  5)  make stellar
  6)  ./apps/stellar

Alternatively you can check out the latest SVN version of STELLAR and SeqAn
with:

  1)  svn co http://svn.mi.fu-berlin.de/seqan/trunk/seqan
  2)  cd seqan/projects/library/cmake
  3)  cmake . -DCMAKE_BUILD_TYPE=Release
  5)  make stellar
  7)  ./apps/stellar

On success, an executable file stellar was build and a brief usage 
description was dumped.

---------------------------------------------------------------------------
3. Usage
---------------------------------------------------------------------------

Usage: stellar -d <FASTA sequence file> -q <FASTA sequence file> [Options]

To get a short usage description of STELLAR, you can execute stellar -h or 
stellar --help.

---------------------------------------------------------------------------
3.1. Non-optional arguments
---------------------------------------------------------------------------

STELLAR always expects the two parameters --database and --query (or -d and
-q) to be set.

 [ -d FILE ],  [ --database FILE ]
 
  Set the name of the file containing the database sequence(s) in
  (multi-)Fasta format.  
 
 [ -q FILE ],  [ --query FILE ]
 
  Set the name of the file containing the query sequence(s) in (multi-)
  Fasta format. All query sequences will be compared to all database
  sequences.

Without any additional parameters STELLAR would compare the query
sequence(s) to both strands of the database sequence(s) with an error rate
of 0.05 (i.e. 5% errors, an identity of 95%) and a minimal length of 100,
and dump all local alignments in an output file named "stellar.gff".

The default behaviour can be modified by adding the following options to
the command line.

---------------------------------------------------------------------------
3.2. Main Options
---------------------------------------------------------------------------

  [ -e REAL ],  [ --epsilon REAL ]
  
  Set the maximal error rate for local alignments. REAL must be a floating
  point number between 0 and 0.25. The default value is 0.05. REAL is the
  number of edit operations needed to transform the aligned query substring
  to the aligned database substring divided by the length of the local
  alignment. For example specify '-e 0.1' for a maximal error rate of 10%
  (90% identity).

  [ -l NUM ],  [ --minLength NUM ]
  
  Set the minimal length of a local alignment. The default value is 100.
  NUM is the minimal length of an alignment, not the length of the
  aligned substrings.

  [ -f ],  [ --forward ]

  Only compare query sequence(s) to the positive/forward strand of the
  database sequence(s). By default, both strands are scanned.

  [ -r ],  [ --reverse ]

  Only compare query sequence(s) to the negative/reverse-complemented 
  database sequence(s). By default, both strands are scanned.
 
  [ -v ],  [ --verbose ]
  
  Verbose. Print extra information and running times.

  [ -V ],  [ --version ]
  
  Print version information.

  [ -h ],  [ --help ]

  Print a usage summary. All other options are ignored.

---------------------------------------------------------------------------
3.3. Filtering Options
---------------------------------------------------------------------------

  [ -k NUM ],  [ --kmer NUM ]

  Set the k-mer size for the SWIFT filter. NUM must be a value between 1
  and 32. The default value is min(s^min, 32) (see the STELLAR paper for a
  definition of s^min). NUM is the number of consecutive matches between
  the query sequencen and database sequence that is necessary for a q-gram
  hit.

  [ -rp NUM ],  [ --repeatPeriod NUM ]
  
  Set the maximal period of low complexity repeats in the database 
  sequence(s) to be filtered out by the repeat masker of STELLAR before 
  comparing the sequences, i.e. the number of repeated characters. NUM must
  be a number greater than 0. The default value is 1. If NUM is set to 1,
  all homopolymers, e.g. AAAA... will be masked, if NUM is set to 2, e.g.
  CGCGCG... will be masked. Independently of this parameter, N characters 
  in the database sequence(s) are filetered out automatically.
  
  [ -rl NUM ],  [ --repeatLength NUM ]
  
  Set the minimal length of a low-complexity repeat region in the database
  sequence(s) to be filtered out by the repeat masker of STELLAR before
  comparing the sequences. NUM must be a number greater than 1. The default
  value is 1000. E.g. '-rp 3 -rl 15' will result in filtering out all
  3-mers that are repeated at least 5 times, all 2-mers that are repeated
  at least 8 times and all homopolymers with a minimal length of 15.
  Independently of this parameter, N characters in the genome are filtered
  out automatically.
  
  [ -a REAL ],  [ --abundanceCut REAL ]
  
  Remove overabundant query k-mers from the k-mer index. REAL must be a 
  value between 0 (remove all) and 1 (remove nothing, default). k-mers with
  a relative abundance above REAL are removed. The relative abundance is
  the absolute number of a k-mers occurences divided by the total number of
  k-mers in the query sequence(s). The total number of k-mers is about
  the total length of the query sequence(s).
  
---------------------------------------------------------------------------
3.4. Verification Options
---------------------------------------------------------------------------

  [ -x NUM ],  [ --xDrop NUM ]
  
  Set the X-Drop parameter for the verification of SWIFT hits. The default
  value is 5. NUM corresponds to the number of errors allowed in close 
  proximity in an alignment. STELLAR does not compute local alignments that
  contain a region where the score drops by X*(1/errorRate-1) or more 
  scoring matches by 1 and errors by -1/errorRate+1. During verification
  the X-drop parameter serves as a stop criterion for gapped extension.
  
  [ -vs STRING ],  [ --verification STRING ]
  
  Set the verification strategy. The default is exact verification. Options
  are exact, bestLocal, and bandedGlobal.
   exact        = The exact verification strategy as described in the
                  STELLAR paper.
   bestLocal    = Only the best local alignment in a SWIFT hit is computed
                  and processed like an epsilon-core as described in the
				  STELLAR paper.
   bandedGlobal = A banded global alignment on the SWIFT hits is processed
                  like extended epsilon-cores in the exact strategy.
  
  [ -dt NUM ],  [ --disableThresh NUM ]
  
  Set the minimal number of local alignments for one query sequence per
  database sequence that result in disabling a query sequence for this 
  database sequence. The default value is infinity. All disabled queries 
  will be written to the file "stellar.disabled.fasta" if no other filename
  is specified.
  
  [ -n NUM ],  [ --numMatches NUM ]
  
  The maximal number of local alignments for one query sequence per 
  database sequence. The default value is 50. If there are more local 
  alignments, the rest is discarded and STELLAR only outputs the NUM
  longest local alignments.
  
  [ -s NUM ],  [ --sortThresh NUM ]
  
  Set the number of local alignments that trigger removal of overlapping
  and duplicate local alignments. NUM must be at least numMatches. The 
  default value is 500. The algorithm implemented in STELLAR often computes
  identical and largely overlapping local alignments. STELLAR removes these
  local alignments before outputting, and also every NUM local alignments. 
  Choose a small value for saving space.

---------------------------------------------------------------------------
3.5. Output Options
---------------------------------------------------------------------------

  [ -o FILE ],  [ --output FILE ]

  Change the output filename to FILE. The default name of the output file
  is "stellar.gff".

  [ -of STRING ],  [ --outFormat STRING ]

  Set the output format for the local alignments. Currently, only the
  optinos gff and text are available. See section 4.
  
  [ -od FILE ],  [ --outDisabled FILE ]

  Change the name of the output file disabled query sequences are written 
  to to FILE. The default filename is "stellar.disabled.fa".

---------------------------------------------------------------------------
4. Output Formats
---------------------------------------------------------------------------

STELLAR supports currently two output format selectable via the
"--outFormat STRING" option. The following values for STRING are possible:

  gff = General Feature Format (GFF)
  text = Human Readable Alignment Format

The following subsections describe the structure of these formats.
 
---------------------------------------------------------------------------
4.1. General Feature Format (GFF)
---------------------------------------------------------------------------

The General Feature Format is specified by the Sanger Institute as a tab-
delimited text format with the following columns:

<seqname> <src> <feat> <start> <end> <score> <strand> <frame> [attr] [cmts]

See also: http://www.sanger.ac.uk/resources/software/gff/spec.html
Consistent with this specification stellar GFF output looks as follows:

GNAME razers read DBEGIN DEND PERCID DSTRAND . ATTRIBUTES

Match value description:

  DNAME        Name of the database sequence
  stellar      Constant
  eps-matches  Constant
  DBEGIN       Beginning position in the database sequence 
               (positions are counted from 1)
  DEND         End position in the database sequence (included)
  PERCID       Percent identity (100 - 100 * error rate)
  DSTRAND      '+'=forward strand of database or '-'=reverse strand
  .            Constant
  ATTRIBUTES   A list of attributes in the format <tag_name>=<tag>
               separated by ';'

Attributes are: 

  ID=          Name of the query sequence
  seq2Range=   Begin and end position of the alignment in the query
               sequence (counting from 1)
  cigar=       Alignment description in cigar format
  mutations=   Positions and bases that differ from the database sequence
               with respect to the query sequence (counting from 1)

For matches on the reverse strand, GBEGIN and GEND are positions on the 
related forward strand. It holds GBEGIN < GEND, regardless of GSTRAND.

---------------------------------------------------------------------------
4.2. Human Readable Alignment Format
---------------------------------------------------------------------------

This format is meant to be readable by humans. The first line contains
the name of the database sequence followed by a line containing the start
and end position of the match in this sequence.
The next two lines contain the name of the query sequence and the start and
end positions in the query sequence.
Positions are counted from 0, end positions are exclusive, i.e. the first 
position behind the last position of the match.

The alignment is displayed in rows, one row for the database sequence and
one for the query sequence, both containing gap characters. Inbetween there
is a row containing '|' and spaces, where '|' indicates a match. Lines are
wrapped after 50 alignment columns. To assist for counting positions, there
is a '.' above each line every 5 positions and a ':' every ten positions.

---------------------------------------------------------------------------
5. Example
---------------------------------------------------------------------------

---------------------------------------------------------------------------
5.1. Two long sequences
---------------------------------------------------------------------------

In the folder snapshot/apps/stellar/examples/ you can find the files 
NC_001477.fasta and NC_001474.fasta containing the sequences of two virus
serotypes. To compare the two sequences do the following:

  1)  cd snapshot/cmake/
  2)  ./apps/stellar -d ../apps/stellar/example/NC_001477.fasta \
                     -q ../apps/stellar/example/NC_001474.fasta
  3)  less stellar.gff

On success, STELLAR dumped one local alignment into the file stellar.gff:

gi|9626685|ref|NC_001477.1|     Stellar eps-matches     10621   10735   95.6897 +       .       gi|158976983|ref|NC_001474.2|;seq2Range=10609,10723;cigar=51M1I1M1D62M;mutations=6T,29A,52C,81A

You may want to run STELLAR again with less stringent parameters to
identify other similar regions, and write the output into a different file:

  1) cd snapshot/cmake/
  2)  ./apps/stellar -d ../apps/stellar/examples/NC_001477.fasta \
                     -q ../apps/stellar/examples/NC_001474.fasta \
					 -o virus_serotypes.gff --epsilon 0.1 --minLength 50
  3) less virus_serotypes.gff

Now, you should obtain 14 local alignments in the file virus_serotypes.gff.

---------------------------------------------------------------------------
5.2. Many-to-reference
---------------------------------------------------------------------------

To demonstrate how to compare many (short) sequences to a database sequence
we provide a file containing 10 example reads with errors, some of them
spanning simulated breakage points. For comparison we set the minimal
length of a match to only 30 what allows splitting a read into up to 3
fragments:

  1)  cd snapshot/cmake/
  2)  ./apps/stellar -d ../apps/stellar/examples/NC_001477.fasta \
                     -q ../apps/stellar/examples/reads.fasta \
					 -o mapped_reads.gff --minLength 30
  3)  less mapped_reads.gff

The output file will contain 15 matches, 6 entirely mapped reads, 3 reads
split into 2 fragments each, and one read split into 3 matches at different
genome locations.
  
---------------------------------------------------------------------------
6. Contact
---------------------------------------------------------------------------

For questions or comments contact:
  Birte Kehr <birte.kehr@fu-berlin.de>
