gt:       if(chrs[i].getFirstPos() == chrs[i].getLastPos()){
context: /*****************************************************************************
    Main.java
  
    (c) 2008-2013 - Alan Boyle
    Department of Genetics
    Stanford University
    aboyle@gmail.com
  
    Licensed under the GNU General Public License 3.0 license.
  
    This file is part of F-seq.
  
    F-seq is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
  
    F-seq is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
  
    You should have received a copy of the GNU General Public License
    along with F-seq.  If not, see <http://www.gnu.org/licenses/>.
  
  ******************************************************************************/
  
  package edu.duke.igsp.gkde;
  
  import java.awt.Dimension;
  import java.io.File;
  import java.io.FileFilter;
  import java.util.ArrayList;
  import java.util.Arrays;
  import java.util.Random;
  
  import javax.swing.JFrame;
  
  import org.apache.commons.cli.CommandLine;
  import org.apache.commons.cli.CommandLineParser;
  import org.apache.commons.cli.GnuParser;
  import org.apache.commons.cli.HelpFormatter;
  import org.apache.commons.cli.OptionBuilder;
  import org.apache.commons.cli.Options;
  
  import edu.duke.igsp.gkde.KDEChromosome.Settings;
  import edu.duke.igsp.gkde.KDEChromosome;
  import edu.duke.igsp.gkde.format.BedDensityWriter;
  import edu.duke.igsp.gkde.format.NpfDensityWriter;
  import edu.duke.igsp.gkde.format.BedReader;
  import edu.duke.igsp.gkde.format.DensityWriter;
  import edu.duke.igsp.gkde.format.WiggleDensityWriter;
  import edu.duke.igsp.gkde.background.*;
  
  public class Main {
    
    public static void main(String[] argv) throws Exception {
     
      
      Options opts = new Options();
      opts.addOption("s",true,"wiggle track step (default=1)");
      opts.addOption("l",true, "feature length (default=600)");
      opts.addOption("f",true, "fragment size (default=estimated from data)");
  //    opts.addOption("b", true, "bandwidth (default=200)");
  //    opts.addOption("w", true, "window (default=3800");
      opts.addOption("wg", true, "wg threshold set (default = calculated)");
      opts.addOption("c", true, "genomic count of sequence reads (default = calculated)");
      opts.addOption("h", false, "print usage");
      opts.addOption(OptionBuilder.withArgName( "input dir" )
          .hasArg()
          .withDescription( "input directory (default=current directory)" )
          .isRequired(false)
          .create( "d" ));
      opts.addOption(OptionBuilder.withArgName( "output dir" )
          .hasArg()
          .withDescription( "output directory (default=current directory)" )
          .isRequired(false)
          .create( "o" ));
      opts.addOption(OptionBuilder.withArgName( "background dir" )
              .hasArg()
              .withDescription( "background directory (default=none)" )
              .isRequired(false)
              .create( "b" ));
      opts.addOption(OptionBuilder.withArgName( "ploidy dir" )
              .hasArg()
              .withDescription( "ploidy/input directory (default=none)" )
              .isRequired(false)
              .create( "p" ));
      opts.addOption(OptionBuilder.withArgName( "wig | bed | npf" )
        .hasArg()
        .withDescription(  "output format (default wig)" )
        .isRequired(false)
        .create( "of" ));
      opts.addOption("t", true, "threshold (standard deviations) (default=4.0)");
  //    opts.addOption("r", true, "background ratio (default=2.0)");
      opts.addOption("v", false, "verbose output");
      
      CommandLineParser parser = new GnuParser();
      int fragment_size = -1;
      int fragment_offset = 0;
      long featureLength = 600l;
  //    float thresh = 2;
      float threshold = KDEChromosome.Settings.DEFAULT_THRESHOLD;
      int step = 1;
      boolean showHelp = false;
      boolean verbose = false;
      String inputDirectory = null;
      String backgroundDirectory = null;
      String ploidyDirectory = null;
      String[] files = null;
      String[] bgfiles = {};
      String[] ipfiles = {};
      String outputFormat = "wig";
      File outputDirectory = new File(System.getProperty("user.dir"));
      
      long bandwidth = 0l;
      long window = 0l;
    	long ncuts = 0l;
  	float temp_threshold = 0f;
  
      System.out.println("F-Seq Version 1.85");
      
      try{
        CommandLine cmd = parser.parse(opts, argv);
        showHelp = (cmd.hasOption("h"));
        verbose = (cmd.hasOption("v"));
        if(cmd.hasOption("s"))
          step = Integer.parseInt(cmd.getOptionValue("s"));
        if(cmd.hasOption("f"))
      	fragment_size = Integer.parseInt(cmd.getOptionValue("f"));
        if(cmd.hasOption("d")) //input directory
          inputDirectory = cmd.getOptionValue("d");
        if(cmd.hasOption("b")) //background directory
          backgroundDirectory = cmd.getOptionValue("b");
        if(cmd.hasOption("p")) //ploidy|input directory
          ploidyDirectory = cmd.getOptionValue("p");
        if(cmd.hasOption("l")) // bandwidth
          featureLength = Long.parseLong(cmd.getOptionValue("l"));
        if(cmd.hasOption("of")){ // output format
          outputFormat = cmd.getOptionValue("of");
          if(!outputFormat.equals("wig") && !outputFormat.equals("bed") && !outputFormat.equals("npf")){
            System.out.println("Parameter error: output format must be 'wig' or 'bed'.");
            showHelp = true;
          }
        }
        if(cmd.hasOption("t")){ // threshold (standard deviations)
          threshold = Float.parseFloat(cmd.getOptionValue("t"));
        }
        if(cmd.hasOption("o")){ // output directory
          String out = cmd.getOptionValue("o");
          outputDirectory = new File(out);
          if(!outputDirectory.exists() && !outputDirectory.isDirectory()){
            System.out.println("Output directory '" + out + "' is not a valid directory.");
            showHelp = true;
          }
        }
        
  		if(cmd.hasOption("wg"))
  			temp_threshold = Float.parseFloat(cmd.getOptionValue("wg"));
  		if(cmd.hasOption("c"))
  			ncuts = Long.parseLong(cmd.getOptionValue("c"));
  
        // TESTING ONLY
     //   if(cmd.hasOption("w")) // window
     //     window = Long.parseLong(cmd.getOptionValue("w"));
        //if(cmd.hasOption("b")) // window
        //  bandwidth = Long.parseLong(cmd.getOptionValue("b"));
        
        files = cmd.getArgs(); // input files
        //bgfiles = cmd.getArgs(); // background files
      }catch(Exception e){
        System.out.println("Error parsing arguments: " + e.getMessage());
        e.printStackTrace();
        showHelp = true;
      }
      
      if(showHelp || (inputDirectory == null && files.length==0)){
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp( "fseq [options]... [file(s)]...", opts );
        System.exit(1);
      }
      
      
      File[] pfiles = getFiles(inputDirectory, files);
      File[] background_files = getFiles(backgroundDirectory, bgfiles);
      File[] ploidy_files = getFiles(ploidyDirectory, ipfiles);
      
      KDEChromosome[] chrs = BedReader.read(pfiles);
      //KDEChromosome[] input = BedReader.read(ifiles);
      
      //compute fragment offset
      if(fragment_size == -1) {
      	fragment_size = wgShiftCalc(chrs);
      }
      fragment_offset = (int)(fragment_size/2);
      
  	if(ncuts == 0l) {
  	  	for(int i = 0; i < chrs.length; ++i){
   	 		ncuts += (long)chrs[i].getLength();
  	  	}
      }
  
      KDEChromosome.Settings settings = null;
      if(bandwidth > 0 || window > 0){
        settings = new KDEChromosome.Settings(bandwidth,window,threshold,fragment_offset, ncuts);
      }else{
        settings = new KDEChromosome.Settings(featureLength, threshold, fragment_offset, ncuts);
      }
  
  	float wg_threshold = wgThreshold(settings, chrs);    
  	if(temp_threshold != 0f) {
  		wg_threshold = temp_threshold;
  	}
      //KDEChromosome.Settings bg_settings = null;
      //bg_settings = new KDEChromosome.Settings(featureLength*2, threshold, fragment_offset);
      
  
      //int background_size = 0;
      //int input_size = 0;
      //float bg_ratio = 0;
      //float sd = 0;
  
      if(verbose){
          System.out.println("Settings: ");
          System.out.println("\twindow=" + (settings.window * 2));
          System.out.println("\tbandwidth=" + (settings.bandwidth));
          //System.out.println("\tfragment offset=" + (settings.offset));
      	System.out.println("\tthreshold = " + wg_threshold);
      	System.out.println("\test. fragment size = " + fragment_size);
      	System.out.println("\tsequence length = " + chrs[0].getSequenceLength());
      }
      
  //    if(backgroundDirectory != null) {
  //	    for(int i = 0; i < input.length; ++i) {
  //	    	background_size += input[i].getLength();
  //	    }
  //	    for(int i = 0; i < chrs.length; ++i) {
  //	    	input_size += chrs[i].getLength();
  //	    }
  //	    bg_ratio = (float)input_size/(float)background_size;
  //	    sd = computeSD(bg_settings, input);
  //	    //System.out.println("Sample Ratio: " + bg_ratio);
  //	    //System.out.println("Input Size: " + input_size);
  //	    //System.out.println("Background Size: " + background_size);
  //	    //System.out.println("Input standard deviation: " + (settings.threshold * (float)Math.sqrt((double)bg_ratio * (double)sd * (double)sd)));
  //	    //System.out.println("Data standard deviation: " + settings.threshold * computeSD(settings, chrs));
  //    }
      
      for(int i = 0; i < chrs.length; ++i){
  