@Override
 public void handleEvent(FormatEvent event) {
   switch (event.getType()) {
     case PROGRESS:
       progressBar.setValue((int) (event.getProgress() * 100.0));
       if (event.getSubTask() != null) {
         statusLabel.setText(event.getSubTask());
       }
       break;
     case COMPLETED:
       setVisible(false);
       if (GenomeController.getInstance().isGenomeLoaded()) {
         if (formatter instanceof BAMToCoverage) {
           // For coverage tracks, we report success, but don't offer to open the track.
           DialogUtils.displayMessage(
               "Format Successful",
               String.format(
                   "<HTML>Format successful.<BR>Coverage will be available the next time you open <i>%s</i>.</HTML>",
                   formatter.getInputFile().getName()));
         } else {
           if (toLoadTrack
               || DialogUtils.askYesNo("Format Successful", "Format successful. Open track now?")
                   == DialogUtils.YES) {
             try {
               FrameController.getInstance()
                   .addTrackFromPath(formatter.getOutputFile().getAbsolutePath(), null, null);
             } catch (Exception ex) {
             }
           }
         }
       } else {
         DialogUtils.displayMessage(
             "Format Successful",
             "<HTML>Format successful. <BR>A genome must be loaded before you can open this track.</HTML>");
       }
       break;
     case FAILED:
       setVisible(false);
       SavantFileFormatter.reportFormattingError(event.getError(), formatter.getInputFile());
       break;
   }
 }
Example #2
0
 /**
  * Add a listener to monitor changes in the reference genome.
  *
  * @param l the listener to be added
  */
 public static void addGenomeChangedListener(Listener<GenomeChangedEvent> l) {
   genomeController.addListener(l);
 }
Example #3
0
 /**
  * Set the current genome.
  *
  * @param genome the genome to set
  */
 public static void setGenome(GenomeAdapter genome) {
   genomeController.setGenome((Genome) genome);
 }
Example #4
0
 /**
  * Get the loaded genome.
  *
  * @return the loaded genome
  */
 public static GenomeAdapter getGenome() {
   return genomeController.getGenome();
 }
Example #5
0
 /**
  * Tell whether Savant has loaded a genome yet.
  *
  * @return true if a genome is loaded
  */
 public static boolean isGenomeLoaded() {
   return genomeController.isGenomeLoaded();
 }
Example #6
0
/**
 * Utility methods for dealing with Savant genomes.
 *
 * @author tarkvara
 */
public class GenomeUtils {

  private static GenomeController genomeController = GenomeController.getInstance();

  /**
   * Tell whether Savant has loaded a genome yet.
   *
   * @return true if a genome is loaded
   */
  public static boolean isGenomeLoaded() {
    return genomeController.isGenomeLoaded();
  }

  /**
   * Get the loaded genome.
   *
   * @return the loaded genome
   */
  public static GenomeAdapter getGenome() {
    return genomeController.getGenome();
  }

  /**
   * Set the current genome.
   *
   * @param genome the genome to set
   */
  public static void setGenome(GenomeAdapter genome) {
    genomeController.setGenome((Genome) genome);
  }

  /** Create a placeholder genome with the given name and length. */
  public static GenomeAdapter createGenome(String name, int length) {
    return new Genome(name, length);
  }

  /**
   * Create a new genome from the given track full of sequence data.
   *
   * @param seqTrack a track containing sequence information
   * @return a genome object for the given sequence
   */
  public static GenomeAdapter createGenome(TrackAdapter seqTrack) {
    return Genome.createFromTrack((Track) seqTrack);
  }

  /**
   * Create a new genome from the given file full of sequence data.
   *
   * @param f a file containing sequence information
   * @return a genome object for the given sequence
   */
  public static GenomeAdapter createGenome(File f) throws Throwable {
    return createGenome(TrackUtils.createTrack(f)[0]);
  }

  /**
   * Add a listener to monitor changes in the reference genome.
   *
   * @param l the listener to be added
   */
  public static void addGenomeChangedListener(Listener<GenomeChangedEvent> l) {
    genomeController.addListener(l);
  }

  /**
   * Remove a genome change listener.
   *
   * @param l the listener to be removed
   */
  public static void removeGenomeChangedListener(Listener<GenomeChangedEvent> l) {
    genomeController.removeListener(l);
  }
}
Example #7
0
 /**
  * Remove a genome change listener.
  *
  * @param l the listener to be removed
  */
 public static void removeGenomeChangedListener(Listener<GenomeChangedEvent> l) {
   genomeController.removeListener(l);
 }