Esempio n. 1
0
 Record rdataFromString(Name name, short dclass, int ttl, MyStringTokenizer st, Name origin)
     throws TextParseException {
   SIGRecord rec = new SIGRecord(name, dclass, ttl);
   rec.covered = Type.value(st.nextToken());
   rec.alg = Byte.parseByte(st.nextToken());
   rec.labels = Byte.parseByte(st.nextToken());
   rec.origttl = TTL.parseTTL(st.nextToken());
   rec.expire = parseDate(st.nextToken());
   rec.timeSigned = parseDate(st.nextToken());
   rec.footprint = (short) Integer.parseInt(st.nextToken());
   rec.signer = Name.fromString(st.nextToken(), origin);
   if (st.hasMoreTokens()) rec.signature = base64.fromString(st.remainingTokens());
   return rec;
 }
Esempio n. 2
0
  // Gets a property and converts it into byte.
  static byte getByteProperty(String propName, byte defaultValue) {

    String temp = getConfigValue(propName);
    byte result = defaultValue;
    if (temp != null) {
      result = Byte.parseByte(temp);
      Logger.info("{DB}-" + propName + ":" + result);
    } else {

      result = Byte.parseByte(properties.getProperty(propName, Byte.toString(defaultValue)).trim());
      Logger.info("{FILE}-" + propName + ":" + result);
    }

    return result;
  }
  /**
   * Parses the arguments table from the GATK Report and creates a RAC object with the proper
   * initialization values
   *
   * @param table the GATKReportTable containing the arguments and its corresponding values
   * @return a RAC object properly initialized with all the objects in the table
   */
  private RecalibrationArgumentCollection initializeArgumentCollectionTable(GATKReportTable table) {
    final RecalibrationArgumentCollection RAC = new RecalibrationArgumentCollection();

    for (int i = 0; i < table.getNumRows(); i++) {
      final String argument = table.get(i, "Argument").toString();
      Object value = table.get(i, RecalUtils.ARGUMENT_VALUE_COLUMN_NAME);
      if (value.equals("null"))
        value =
            null; // generic translation of null values that were printed out as strings | todo --
                  // add this capability to the GATKReport

      if (argument.equals("covariate") && value != null)
        RAC.COVARIATES = value.toString().split(",");
      else if (argument.equals("standard_covs"))
        RAC.DO_NOT_USE_STANDARD_COVARIATES = Boolean.parseBoolean((String) value);
      else if (argument.equals("solid_recal_mode"))
        RAC.SOLID_RECAL_MODE = RecalUtils.SOLID_RECAL_MODE.recalModeFromString((String) value);
      else if (argument.equals("solid_nocall_strategy"))
        RAC.SOLID_NOCALL_STRATEGY =
            RecalUtils.SOLID_NOCALL_STRATEGY.nocallStrategyFromString((String) value);
      else if (argument.equals("mismatches_context_size"))
        RAC.MISMATCHES_CONTEXT_SIZE = Integer.parseInt((String) value);
      else if (argument.equals("indels_context_size"))
        RAC.INDELS_CONTEXT_SIZE = Integer.parseInt((String) value);
      else if (argument.equals("mismatches_default_quality"))
        RAC.MISMATCHES_DEFAULT_QUALITY = Byte.parseByte((String) value);
      else if (argument.equals("insertions_default_quality"))
        RAC.INSERTIONS_DEFAULT_QUALITY = Byte.parseByte((String) value);
      else if (argument.equals("deletions_default_quality"))
        RAC.DELETIONS_DEFAULT_QUALITY = Byte.parseByte((String) value);
      else if (argument.equals("maximum_cycle_value"))
        RAC.MAXIMUM_CYCLE_VALUE = Integer.parseInt((String) value);
      else if (argument.equals("low_quality_tail"))
        RAC.LOW_QUAL_TAIL = Byte.parseByte((String) value);
      else if (argument.equals("default_platform")) RAC.DEFAULT_PLATFORM = (String) value;
      else if (argument.equals("force_platform")) RAC.FORCE_PLATFORM = (String) value;
      else if (argument.equals("quantizing_levels"))
        RAC.QUANTIZING_LEVELS = Integer.parseInt((String) value);
      else if (argument.equals("recalibration_report"))
        RAC.existingRecalibrationReport = (value == null) ? null : new File((String) value);
      else if (argument.equals("binary_tag_name"))
        RAC.BINARY_TAG_NAME = (value == null) ? null : (String) value;
      else if (argument.equals("sort_by_all_columns"))
        RAC.SORT_BY_ALL_COLUMNS = Boolean.parseBoolean((String) value);
    }

    return RAC;
  }
  private RecalDatum getRecalDatum(
      final GATKReportTable reportTable, final int row, final boolean hasEstimatedQReportedColumn) {
    final long nObservations =
        asLong(reportTable.get(row, RecalUtils.NUMBER_OBSERVATIONS_COLUMN_NAME));
    final double nErrors = asDouble(reportTable.get(row, RecalUtils.NUMBER_ERRORS_COLUMN_NAME));
    // final double empiricalQuality = asDouble(reportTable.get(row,
    // RecalUtils.EMPIRICAL_QUALITY_COLUMN_NAME));

    // the estimatedQreported column only exists in the ReadGroup table
    final double estimatedQReported =
        hasEstimatedQReportedColumn
            ? (Double) reportTable.get(row, RecalUtils.ESTIMATED_Q_REPORTED_COLUMN_NAME)
            : // we get it if we are in the read group table
            Byte.parseByte(
                (String)
                    reportTable.get(
                        row,
                        RecalUtils
                            .QUALITY_SCORE_COLUMN_NAME)); // or we use the reported quality if we
                                                          // are in any other table

    final RecalDatum datum = new RecalDatum(nObservations, nErrors, (byte) 1);
    datum.setEstimatedQReported(estimatedQReported);
    // datum.setEmpiricalQuality(empiricalQuality); // don't set the value here because we will want
    // to recompute with a different conditional Q score prior value
    return datum;
  }
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    // For each test
    StringBuffer sb = new StringBuffer();
    for (byte T = Byte.parseByte(br.readLine()); T > 0; --T) {

      // INPUT
      byte N = Byte.parseByte(br.readLine());
      int[] A = new int[N];
      N = 0;
      for (String s : br.readLine().split(" ")) {
        A[N++] = Integer.parseInt(s);
      }

      sb.append(solve(A, N) ? YES : NO);
    }
    System.out.print(sb);
  }
  public static void main(String[] args) throws IOException {
    StringBuffer sb = new StringBuffer();
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    // For each test case
    for (byte T = Byte.parseByte(br.readLine()); T > 0; --T) {

      // Solve
      sb.append(getMinDeletions(br.readLine().toCharArray()) + "\n");
    }
    System.out.print(sb);
  }
 /**
  * Parses the quantization table from the GATK Report and turns it into a map of original =>
  * quantized quality scores
  *
  * @param table the GATKReportTable containing the quantization mappings
  * @return an ArrayList with the quantization mappings from 0 to MAX_SAM_QUAL_SCORE
  */
 private QuantizationInfo initializeQuantizationTable(GATKReportTable table) {
   final Byte[] quals = new Byte[QualityUtils.MAX_SAM_QUAL_SCORE + 1];
   final Long[] counts = new Long[QualityUtils.MAX_SAM_QUAL_SCORE + 1];
   for (int i = 0; i < table.getNumRows(); i++) {
     final byte originalQual = (byte) i;
     final Object quantizedObject = table.get(i, RecalUtils.QUANTIZED_VALUE_COLUMN_NAME);
     final Object countObject = table.get(i, RecalUtils.QUANTIZED_COUNT_COLUMN_NAME);
     final byte quantizedQual = Byte.parseByte(quantizedObject.toString());
     final long quantizedCount = Long.parseLong(countObject.toString());
     quals[originalQual] = quantizedQual;
     counts[originalQual] = quantizedCount;
   }
   return new QuantizationInfo(Arrays.asList(quals), Arrays.asList(counts));
 }
  public static void main(String[] args) throws IOException {
    StringBuffer sb = new StringBuffer();
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    // INPUT
    for (byte T = Byte.parseByte(br.readLine()); T > 0; --T) {
      String[] input = br.readLine().split(" ");
      int A = Integer.parseInt(input[0]);
      int B = Integer.parseInt(input[1]);

      // SOLVE
      int C = (int) (Math.floor(Math.sqrt(B)) - Math.ceil(Math.sqrt(A)) + 1);
      sb.append(C + "\n");
    }

    // OUTPUT
    System.out.print(sb);
  }
Esempio n. 9
0
 // Get property value as a byte
 public byte getByte(String key) {
   return (properties.containsKey(key)) ? Byte.parseByte(properties.get(key).toString()) : 0;
 }
Esempio n. 10
0
 private void parseMobFile(String strStore, RandomAccessFile rafFile) {
   try {
     if (strStore.equalsIgnoreCase("skill")) {
       strStore = rafFile.readLine();
       int value = Byte.parseByte(rafFile.readLine());
       addToSkill(strStore, value);
       engGame.log.printMessage(Log.DEBUG, strStore + "=" + value);
       return;
     }
     if (strStore.equalsIgnoreCase("condition")) {
       Condition cndStore = engGame.getCondition(rafFile.readLine());
       cndStore.intTicksPast = Integer.parseInt(rafFile.readLine());
       cndStore.intDuration = Integer.parseInt(rafFile.readLine());
       addCondition(cndStore);
       engGame.log.printMessage(Log.DEBUG, "condition \"" + cndStore.strName + "\"");
       return;
     }
     if (strStore.equalsIgnoreCase("giveitem")) {
       String strItem = rafFile.readLine();
       double dblChance = Double.valueOf(rafFile.readLine()).doubleValue();
       vctGiveItems.addElement(new GiveItem(strItem, dblChance));
       engGame.log.printMessage(
           Log.DEBUG,
           strName + " gives a \"" + strItem + "\" " + (100 * dblChance) + "% of the time.");
       return;
     }
     if (strStore.equalsIgnoreCase("item")) {
       Item itmStore = engGame.getItem(rafFile.readLine());
       if (itmStore != null) {
         itmStore.lngDurability = Long.parseLong(rafFile.readLine());
         itmStore.intUses = Integer.parseInt(rafFile.readLine());
         vctItems.addElement(itmStore);
       }
       return;
     }
     if (strStore.equalsIgnoreCase("clan")) {
       strClan = rafFile.readLine();
       return;
     }
     if (strStore.equalsIgnoreCase("race")) {
       strRace = rafFile.readLine();
       return;
     }
     if (strStore.equalsIgnoreCase("title")) {
       strTitle = rafFile.readLine();
       return;
     }
     if (strStore.equalsIgnoreCase("description")) {
       strDescription = rafFile.readLine();
       return;
     }
     if (strStore.equalsIgnoreCase("x")) {
       intLocX = Integer.parseInt(rafFile.readLine());
       return;
     }
     if (strStore.equalsIgnoreCase("y")) {
       intLocY = Integer.parseInt(rafFile.readLine());
       return;
     }
     if (strStore.equalsIgnoreCase("maxhp")) {
       maxhp = Integer.parseInt(rafFile.readLine());
       return;
     }
     if (strStore.equalsIgnoreCase("maxmp")) {
       maxmp = Integer.parseInt(rafFile.readLine());
       return;
     }
     if (strStore.equalsIgnoreCase("stre")) {
       stre = Integer.parseInt(rafFile.readLine());
       return;
     }
     if (strStore.equalsIgnoreCase("inte")) {
       inte = Integer.parseInt(rafFile.readLine());
       return;
     }
     if (strStore.equalsIgnoreCase("dext")) {
       dext = Integer.parseInt(rafFile.readLine());
       return;
     }
     if (strStore.equals("cons")) {
       cons = Integer.parseInt(rafFile.readLine());
       return;
     }
     if (strStore.equalsIgnoreCase("wisd")) {
       wisd = Integer.parseInt(rafFile.readLine());
       return;
     }
     if (strStore.equalsIgnoreCase("image")) {
       intImage = Integer.parseInt(rafFile.readLine());
       return;
     }
     if (strStore.equalsIgnoreCase("bravery")) {
       dblBravery = Double.valueOf(rafFile.readLine()).doubleValue();
       return;
     }
     if (strStore.equalsIgnoreCase("grouprelation")) {
       dblGroupRelation = Double.valueOf(rafFile.readLine()).doubleValue();
       return;
     }
     if (strStore.equalsIgnoreCase("wield")) {
       equWorn.wield = engGame.getItem(rafFile.readLine());
       if (equWorn.wield != null) {
         equWorn.wield.lngDurability = Long.parseLong(rafFile.readLine());
         equWorn.wield.intUses = Integer.parseInt(rafFile.readLine());
       }
       runWearScript(equWorn.wield);
       return;
     }
     if (strStore.equalsIgnoreCase("arms")) {
       equWorn.arms = engGame.getItem(rafFile.readLine());
       if (equWorn.arms != null) {
         equWorn.arms.lngDurability = Long.parseLong(rafFile.readLine());
         equWorn.arms.intUses = Integer.parseInt(rafFile.readLine());
       }
       runWearScript(equWorn.arms);
       return;
     }
     if (strStore.equalsIgnoreCase("legs")) {
       equWorn.legs = engGame.getItem(rafFile.readLine());
       if (equWorn.legs != null) {
         equWorn.legs.lngDurability = Long.parseLong(rafFile.readLine());
         equWorn.legs.intUses = Integer.parseInt(rafFile.readLine());
       }
       runWearScript(equWorn.legs);
       return;
     }
     if (strStore.equalsIgnoreCase("torso")) {
       equWorn.torso = engGame.getItem(rafFile.readLine());
       if (equWorn.torso != null) {
         equWorn.torso.lngDurability = Long.parseLong(rafFile.readLine());
         equWorn.torso.intUses = Integer.parseInt(rafFile.readLine());
       }
       runWearScript(equWorn.torso);
       return;
     }
     if (strStore.equalsIgnoreCase("waist")) {
       equWorn.waist = engGame.getItem(rafFile.readLine());
       if (equWorn.waist != null) {
         equWorn.waist.lngDurability = Long.parseLong(rafFile.readLine());
         equWorn.waist.intUses = Integer.parseInt(rafFile.readLine());
       }
       runWearScript(equWorn.waist);
       return;
     }
     if (strStore.equalsIgnoreCase("neck")) {
       equWorn.neck = engGame.getItem(rafFile.readLine());
       if (equWorn.neck != null) {
         equWorn.neck.lngDurability = Long.parseLong(rafFile.readLine());
         equWorn.neck.intUses = Integer.parseInt(rafFile.readLine());
       }
       runWearScript(equWorn.neck);
       return;
     }
     if (strStore.equalsIgnoreCase("skull")) {
       equWorn.skull = engGame.getItem(rafFile.readLine());
       if (equWorn.skull != null) {
         equWorn.skull.lngDurability = Long.parseLong(rafFile.readLine());
         equWorn.skull.intUses = Integer.parseInt(rafFile.readLine());
       }
       runWearScript(equWorn.skull);
       return;
     }
     if (strStore.equalsIgnoreCase("eyes")) {
       equWorn.eyes = engGame.getItem(rafFile.readLine());
       if (equWorn.eyes != null) {
         equWorn.eyes.lngDurability = Long.parseLong(rafFile.readLine());
         equWorn.eyes.intUses = Integer.parseInt(rafFile.readLine());
       }
       runWearScript(equWorn.eyes);
       return;
     }
     if (strStore.equalsIgnoreCase("hands")) {
       equWorn.hands = engGame.getItem(rafFile.readLine());
       if (equWorn.hands != null) {
         equWorn.hands.lngDurability = Long.parseLong(rafFile.readLine());
         equWorn.hands.intUses = Integer.parseInt(rafFile.readLine());
       }
       runWearScript(equWorn.hands);
       return;
     }
     if (strStore.equalsIgnoreCase("faction")) {
       String strFaction = rafFile.readLine();
       fctFaction = engGame.getFaction(strFaction);
       if (fctFaction != null) {
         engGame.log.printMessage(Log.DEBUG, "faction=\"" + fctFaction.strName + "\"");
       } else {
         engGame.log.printMessage(Log.DEBUG, "no faction found for \"" + strFaction + "\"");
       }
       return;
     }
     if (strStore.equalsIgnoreCase("onBattle")) {
       strOnBattle = rafFile.readLine();
       return;
     }
     if (strStore.equalsIgnoreCase("nofollow")) {
       noFollow = true;
       return;
     }
   } catch (Exception e) {
     engGame.log.printError(
         "parseMobFile():Parsing \"" + strStore + "\" from " + strName + "'s file", e);
   }
 }
Esempio n. 11
0
 // ========================================================================//
 // ============================ PRIVATE METHODS ===========================//
 // ========================================================================//
 // Gets a property and converts it into byte.
 static byte getByteProperty(String propName, byte defaultValue) {
   return Byte.parseByte(properties.getProperty(propName, Byte.toString(defaultValue)).trim());
 }