| ListWalker |
package Samples;
import java.io.*;
import Sight.util.ListProcessor;
/**
* This class provides example how to create the simple
* genome walker that walks through the list of accession
* numbers.
*/
public class ListWalker {
public ListWalker() {
}
static public void main(String[] args) {
// process fragment of the chromosome 8, located in H8.txt
// (program start folder)
new ListWalker().processList("H8.txt");
}
/**
* Analyses the given list.
*/
public void processList(String fileToLoad)
{
try {
ourListProcessor lp = new ourListProcessor();
lp.walker = this;
lp.setList(new File(fileToLoad));
lp.run();
} catch (Exception exc)
{ if (exc!=null) System.out.println(exc.getMessage());
exc.printStackTrace();
};
};
}
/* We need a new child of ListProcessor. */
class ourListProcessor extends Sight.util.ListProcessor
{
ListWalker walker;
/** Operations, required only when starting the task list.
* For example, write header of the log files. */
public void do_on_start()
{
System.out.println("Starting");
};
/** Operations, required only when finishig the task list.
* For example, write footers of the log files. */
public void do_on_finish()
{
System.out.println("Finishing.");
};
/** Analyse the item. */
public void process(String accession) throws Exception
{
// Do something great with your accession number here:
System.out.println(accession);
// make a pause or you will see nothing.
try { Thread.sleep(1000); } catch (InterruptedException ex) {}
};
};| ListWalker |