/*===========================================================================
*
*                            PUBLIC DOMAIN NOTICE
*               National Center for Biotechnology Information
*
*  This software/database is a "United States Government Work" under the
*  terms of the United States Copyright Act.  It was written as part of
*  the author's official duties as a United States Government employee and
*  thus cannot be copyrighted.  This software/database is freely available
*  to the public for use. The National Library of Medicine and the U.S.
*  Government have not placed any restriction on its use or reproduction.
*
*  Although all reasonable efforts have been taken to ensure the accuracy
*  and reliability of the software and data, the NLM and the U.S.
*  Government do not and cannot warrant the performance or results that
*  may be obtained by using this software or data. The NLM and the U.S.
*  Government disclaim all warranties, express or implied, including
*  warranties of performance, merchantability or fitness for any particular
*  purpose.
*
*  Please cite the author in any work or product based on this material.
*
* ===========================================================================
*
*/

This file contains instructions on building and running NGS Java example programs.

Once installed, the source code is contained in examples/*.java files. Each source file corresponds to a separate example that demonstrates use of a particular feature of the NGS Java API.

To be built, the examples require Java JDK installed. To be run, they require an external shared library and a .jar file. See 6) for default locations and overrides.

1. Build all
    - run "make". This will compile all examples and place their .class files in ./examples/.

2. Run all
    - run "make run_all". This will run all examples with their predefined arguments. The output of all the examples goes to stdout.

3. Run and diff
    - run "make run_and_diff". This will execute all the examples with their predefined arguments, run them, capture the output in a temporary file, and then use "diff" to compare the actual output against a file containing the expected output (./expected.txt). Any discrepancies will be displayed. If the actual output matches the expected, there will be a message "NGS Java examples work as expected" at the end of the execution.

6. Run separately
    - run "make <example>" where <example> is one of "run_frag", "run_align", "run_dump", "run_align_slice", "run_pileup", "run_ref", "run_read_group". This will run the selected example with some predefined arguments.
    - In order to run an individual example with custom arguments, do so using java from the command line, e.g.
        java -Djava.library.path=<path-to-libncbi-ngs.so> -cp NGS-JavaTest.jar:<path-to-ngs-java.jar> examples.AlignTest ERR225922 10000 2
    - When run without arguments, the examples will output a very short description of the required parameters.

6. Alternative Jar/Library Locations
    - By default, the makefile accesses the required .jar and object lirary via paths relative to the current directory, assuming that the examples are a part of a standard installation of sra-tools.
    - To change the location of the jar/library to use, specify the following varibles on the make command (e.g. "make NGS_LIBDIR=/some-path/"):
        -- NCBI_JAR - the path to ngs-java.jar, built by the ngs-java subproject of sra-tools (default ../../jar/ngs-java.jar).
        -- NGS_LIBDIR - the location of libncbi-ngs.so, built by the ngs-sdk subproject of sra-tools  (default ../../lib64)

8. Clean
    - run "make clean" to remove the executables.
