/**
  * Create a string to serialize to a file
  *
  * @return
  */
 @SuppressWarnings("unchecked")
 @Override
 public String serializeSave(MarkerSerializer markerSerializer) {
   return super.serializeSave(markerSerializer) //
       + "\t"
       + markerSerializer.save((Collection<Marker>) subIntervals.values()) //
   ;
 }
  /** Parse a line from a serialized file */
  @SuppressWarnings("unchecked")
  @Override
  public void serializeParse(MarkerSerializer markerSerializer) {
    super.serializeParse(markerSerializer);

    Markers markers = markerSerializer.getNextFieldMarkers();
    for (Marker m : markers) add((T) m);
  }
示例#3
0
  /** Load predictor from a binary file */
  public static SnpEffectPredictor load(Config config) {
    String snpEffPredFile = config.getFileSnpEffectPredictor();

    // Sanity check
    if (!Gpr.canRead(snpEffPredFile))
      throw new RuntimeException(
          "\tERROR: Cannot read file '"
              + snpEffPredFile
              + "'.\n\tYou can try to download the database by running the following command:\n\t\tjava -jar snpEff.jar download "
              + config.getGenome().getVersion()
              + "\n");

    // Load markers from file
    MarkerSerializer ms = new MarkerSerializer();
    Markers markers = ms.load(snpEffPredFile);

    // Find genome
    Genome genome = null;
    for (Marker m : markers) if (m instanceof Genome) genome = (Genome) m;
    if (genome == null) throw new RuntimeException("Genome not found. This should never happen!");

    // Create predictor
    SnpEffectPredictor snpEffectPredictor = new SnpEffectPredictor(genome);

    // Add genes
    for (Marker m : markers)
      if (m instanceof Gene) {
        Gene gene = (Gene) m;
        snpEffectPredictor.add(gene);
      }

    // Add 'other' markers
    for (Marker m : markers)
      if (!(m instanceof Genome) //
          && !(m instanceof Chromosome) //
          && !(m instanceof Gene) //
          && !(m instanceof Transcript) //
          && !(m instanceof Exon) //
          && !(m instanceof Cds) //
          && !(m instanceof Utr) //
          && !(m instanceof SpliceSite) //
      ) snpEffectPredictor.add(m);

    return snpEffectPredictor;
  }
  /** Save nextprot markers */
  void save() {
    String nextProtBinFile = config.getDirDataVersion() + "/nextProt.bin";
    if (verbose) Timer.showStdErr("Saving database to file '" + nextProtBinFile + "'");

    // Add chromosomes
    HashSet<Chromosome> chromos = new HashSet<Chromosome>();
    for (Marker m : markers) chromos.add(m.getChromosome());

    // Create a set of all markers to be saved
    Markers markersToSave = new Markers();
    markersToSave.add(genome);
    for (Chromosome chr : chromos) markersToSave.add(chr);
    for (Marker m : markers) markersToSave.add(m);

    // Save
    MarkerSerializer markerSerializer = new MarkerSerializer();
    markerSerializer.save(nextProtBinFile, markersToSave);
  }
示例#5
0
 /** Save predictor to a binary file (specified by the configuration) */
 public void save(Config config) {
   String databaseFile = config.getFileSnpEffectPredictor();
   MarkerSerializer markerSerializer = new MarkerSerializer();
   markerSerializer.save(databaseFile, this);
 }