Ejemplo n.º 1
0
  /**
   * Returns all supported sample rates.
   *
   * @return an array of sample rates, in Hertz, never <code>null</code>.
   */
  public Integer[] getSampleRates() {
    final String rawValue = this.properties.get(DEVICE_SAMPLERATES);
    final String[] values = rawValue.split(",\\s*");
    final SortedSet<Integer> result =
        new TreeSet<Integer>(
            NumberUtils.<Integer>createNumberComparator(false /* aSortAscending */));
    for (String value : values) {
      result.add(Integer.valueOf(value.trim()));
    }

    return result.toArray(new Integer[result.size()]);
  }
  public RecalibrationReport(final File recalFile, final SortedSet<String> allReadGroups) {
    final GATKReport report = new GATKReport(recalFile);

    argumentTable = report.getTable(RecalUtils.ARGUMENT_REPORT_TABLE_TITLE);
    RAC = initializeArgumentCollectionTable(argumentTable);

    GATKReportTable quantizedTable = report.getTable(RecalUtils.QUANTIZED_REPORT_TABLE_TITLE);
    quantizationInfo = initializeQuantizationTable(quantizedTable);

    Pair<ArrayList<Covariate>, ArrayList<Covariate>> covariates =
        RecalUtils.initializeCovariates(RAC); // initialize the required and optional covariates
    ArrayList<Covariate> requiredCovariates = covariates.getFirst();
    ArrayList<Covariate> optionalCovariates = covariates.getSecond();
    requestedCovariates = new Covariate[requiredCovariates.size() + optionalCovariates.size()];
    optionalCovariateIndexes = new HashMap<String, Integer>(optionalCovariates.size());
    int covariateIndex = 0;
    for (final Covariate covariate : requiredCovariates)
      requestedCovariates[covariateIndex++] = covariate;
    for (final Covariate covariate : optionalCovariates) {
      requestedCovariates[covariateIndex] = covariate;
      final String covariateName =
          covariate
              .getClass()
              .getSimpleName()
              .split("Covariate")[
              0]; // get the name of the covariate (without the "covariate" part of it) so we can
                  // match with the GATKReport
      optionalCovariateIndexes.put(covariateName, covariateIndex - 2);
      covariateIndex++;
    }

    for (Covariate cov : requestedCovariates)
      cov.initialize(
          RAC); // initialize any covariate member variables using the shared argument collection

    recalibrationTables = new RecalibrationTables(requestedCovariates, allReadGroups.size());

    initializeReadGroupCovariates(allReadGroups);

    parseReadGroupTable(
        report.getTable(RecalUtils.READGROUP_REPORT_TABLE_TITLE),
        recalibrationTables.getReadGroupTable());

    parseQualityScoreTable(
        report.getTable(RecalUtils.QUALITY_SCORE_REPORT_TABLE_TITLE),
        recalibrationTables.getQualityScoreTable());

    parseAllCovariatesTable(
        report.getTable(RecalUtils.ALL_COVARIATES_REPORT_TABLE_TITLE), recalibrationTables);
  }
Ejemplo n.º 3
0
  /**
   * Prints one Unicode property value per line, along with its aliases, if any, for the given
   * unicodeVersion.
   *
   * @param unicodeVersion The Unicode version to print property values and aliases for
   * @throws UnicodeProperties.UnsupportedUnicodeVersionException if unicodeVersion is not supported
   */
  private static void printUnicodePropertyValuesAndAliases(String unicodeVersion)
      throws UnicodeProperties.UnsupportedUnicodeVersionException {
    Pattern versionPattern = Pattern.compile("(\\d+)(?:\\.(\\d+))?(?:\\.\\d+)?");
    Matcher matcher = versionPattern.matcher(unicodeVersion);
    if (!matcher.matches()) {
      throw new UnicodeProperties.UnsupportedUnicodeVersionException();
    }
    String underscoreVersion =
        matcher.group(1) + (null == matcher.group(2) ? "_0" : "_" + matcher.group(2));

    String[] propertyValues;
    String[] propertyValueAliases;
    try {
      Class<?> clazz = Class.forName("jflex.unicode.data.Unicode_" + underscoreVersion);
      Field field = clazz.getField("propertyValues");
      propertyValues = (String[]) field.get(null);
      field = clazz.getField("propertyValueAliases");
      propertyValueAliases = (String[]) field.get(null);
    } catch (Exception e) {
      throw new UnicodeProperties.UnsupportedUnicodeVersionException();
    }
    SortedMap<String, SortedSet<String>> propertyValuesToAliases =
        new TreeMap<String, SortedSet<String>>();
    for (String value : propertyValues) {
      propertyValuesToAliases.put(value, new TreeSet<String>());
    }
    for (int i = 0; i < propertyValueAliases.length; i += 2) {
      String alias = propertyValueAliases[i];
      String value = propertyValueAliases[i + 1];
      SortedSet<String> aliases = propertyValuesToAliases.get(value);
      if (null == aliases) {
        aliases = new TreeSet<String>();
        propertyValuesToAliases.put(value, aliases);
      }
      aliases.add(alias);
    }
    for (Map.Entry<String, SortedSet<String>> entry : propertyValuesToAliases.entrySet()) {
      String value = entry.getKey();
      SortedSet<String> aliases = entry.getValue();
      Out.print(value);
      if (aliases.size() > 0) {
        for (String alias : aliases) {
          Out.print(", " + alias);
        }
      }
      Out.println("");
    }
  }
Ejemplo n.º 4
0
  public static String getNext(SortedSet<String> slines, String num) {
    String nxt = "";
    SortedSet<String> candidates = new TreeSet<String>();
    for (String s : slines) {
      if (s.contains(num) && s.indexOf(num) < s.length() - 1) {
        candidates.add(s.split("")[s.indexOf(num) + 1]);
      }
    }
    // System.out.println(candidates);
    if (candidates.size() == 0) return null;
    nxt = candidates.first();
    for (String s : slines) {
      for (String c : candidates) {
        if (s.contains(c) && s.contains(nxt) && s.indexOf(c) < s.indexOf(nxt)) nxt = c;
      }
    }

    return nxt;
  }
Ejemplo n.º 5
0
  /** Create a new set of shared job state counters for all jobs in the given group. */
  public void initCounters(TaskTimer timer, QueueJobGroup group) {
    long groupID = group.getGroupID();

    if (LogMgr.getInstance().isLoggable(LogMgr.Kind.Ops, LogMgr.Level.Finest))
      LogMgr.getInstance()
          .log(LogMgr.Kind.Ops, LogMgr.Level.Finest, "Init Job Counts for Group (" + groupID + ")");

    SortedSet<Long> jobIDs = group.getJobIDs();
    Counters counters = new Counters(jobIDs.size());

    timer.acquire();
    synchronized (pCountersByGroup) {
      timer.resume();

      if (pCountersByGroup.put(groupID, counters) != null)
        LogMgr.getInstance()
            .logAndFlush(
                LogMgr.Kind.Ops,
                LogMgr.Level.Warning,
                "Somehow the job group ("
                    + groupID
                    + ") was already in the state "
                    + "counts table!");
    }

    timer.acquire();
    synchronized (pCountersByJob) {
      timer.resume();

      for (Long jobID : jobIDs) {
        if (pCountersByJob.put(jobID, counters) != null)
          LogMgr.getInstance()
              .logAndFlush(
                  LogMgr.Kind.Ops,
                  LogMgr.Level.Warning,
                  "Somehow the job (" + jobID + ") was already in the state counts table!");
      }
    }
  }
 int getActiveThreadCount() {
   return active_threads.size();
 }