Java Code Examples for htsjdk.tribble.annotation.Strand#decode()

The following examples show how to use htsjdk.tribble.annotation.Strand#decode() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IlluminaManifestRecord.java    From picard with MIT License 5 votes vote down vote up
private Strand getRefStrandFromManifest(final Map<String, Integer> columnNameToIndex) {
    final String strandValue = getColumnValueIfPresentInManifest(columnNameToIndex, IlluminaManifest.REF_STRAND_HEADER_NAME);
    if (strandValue == null) {
        return Strand.NONE;
    }
    return Strand.decode(strandValue.charAt(0));
}
 
Example 2
Source File: FuncotatorUtilsUnitTest.java    From gatk with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static Object[] helpCreateDataForTestGetBasesInWindowAroundReferenceAllele(final String refAlleleBases,
                                                                                   final String strand,
                                                                                   final int windowSizeInBases,
                                                                                   final int startPos,
                                                                                   final int endPos,
                                                                                   final String expected) {
    return new Object[] {
        Allele.create(refAlleleBases, true),
        new ReferenceContext( refDataSourceHg19Ch3, new SimpleInterval("chr3", startPos, endPos) ),
        Strand.decode(strand),
        windowSizeInBases,
        expected
    };
}
 
Example 3
Source File: LiftOver.java    From varsim with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * Main method
 */
public void run(String[] args){
  if (!parseArguments(args)) {
    return;
  }
  log.info("command: " + String.join(" ", args));
  if (!input.endsWith(".bed")) {
    throw new IllegalArgumentException("Right now only takes .bed files.");
  }
  String outfile = prefix + ".bed";
  try (BufferedWriter outputWriter = new BufferedWriter(new FileWriter(outfile));
       BufferedReader fileToLift = new BufferedReader(new FileReader(input))) {

      MapBlocks mapBlocks = new MapBlocks(new File(mapForLiftover));
      log.info("Assume forward strand if not set.");

      String line;
      while ((line = fileToLift.readLine()) != null) {
        String[] fields = line.split("\t");
        GenomeInterval interval = new GenomeInterval(new ChrString(fields[0]), Integer.parseInt(fields[1]), Integer.parseInt(fields[2]),
                fields.length >= 6 ? Strand.decode(fields[5]) : Strand.FORWARD, MapBlock.BlockType.UNKNOWN);
        Collection<ReadMapBlock> liftedReadMapBlocks = mapBlocks.liftOverGenomeInterval(interval, 1);
        for (ReadMapBlock i : liftedReadMapBlocks) {
          GenomeInterval liftedInterval = i.getMapInterval();
          StringBuilder stringBuilder = new StringBuilder();
          stringBuilder.append(liftedInterval.getChromosome().toString());
          stringBuilder.append("\t");
          stringBuilder.append(liftedInterval.getStart());
          stringBuilder.append("\t");
          stringBuilder.append(liftedInterval.getEnd());
          // try to write whatever original input file has
          if (fields.length >= 4) {
            stringBuilder.append("\t");
            stringBuilder.append(fields[3]);
          }
          if (fields.length >= 5) {
            stringBuilder.append("\t");
            stringBuilder.append(fields[4]);
          }
          if (fields.length >= 6) {
            stringBuilder.append("\t");
            stringBuilder.append(liftedInterval.getStrand().toString());
          }
          if (fields.length >= 7) {
            for (int j = 6; j < fields.length; j++) {
              stringBuilder.append("\t");
              stringBuilder.append(fields[j]);
            }
          }
          stringBuilder.append("\n");
          outputWriter.write(stringBuilder.toString());
        }
      }
  } catch(IOException e) {
    e.printStackTrace();
    throw new IllegalArgumentException("Unable to write to " + outfile + " or read " + mapForLiftover + " or " + input);
  }
}