Java Code Examples for htsjdk.tribble.annotation.Strand#FORWARD

The following examples show how to use htsjdk.tribble.annotation.Strand#FORWARD . 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: DataProviderForExampleGencodeGtfGene.java    From gatk with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static GencodeGtfUTRFeature create3pUtr(final AtomicInteger featureOrderNum, final String contig,
                                                final int length3Utr, final String geneName,
                                                final GencodeGtfExonFeature exon, final Strand codingDirection) {
    final int start = codingDirection == Strand.FORWARD ? exon.getGenomicEndLocation() - length3Utr + 1 : exon.getGenomicStartLocation();
    final int end = codingDirection == Strand.FORWARD ? exon.getGenomicEndLocation() : exon.getGenomicStartLocation() + length3Utr - 1;
    final GencodeGtfFeatureBaseData tmp3pUtr = new GencodeGtfFeatureBaseData(GencodeGtfCodec.GTF_FILE_TYPE_STRING, featureOrderNum.getAndIncrement(), contig, GencodeGtfFeature.ANNOTATION_SOURCE_ENSEMBL, GencodeGtfFeature.FeatureType.UTR,
            start, end, codingDirection, GencodeGtfFeature.GenomicPhase.DOT, "TEST_GENE1", "TEST_TRANSCRIPT1", GencodeGtfFeature.GeneTranscriptType.PROTEIN_CODING,
            null, geneName, GencodeGtfFeature.GeneTranscriptType.PROTEIN_CODING, null, "TEST_TRANSCRIPT1", exon.getExonNumber(), exon.getExonId(), GencodeGtfFeature.LocusLevel.AUTOMATICALLY_ANNOTATED,
            Collections.emptyList(),
            null
    );
    return (GencodeGtfUTRFeature) GencodeGtfFeature.create(tmp3pUtr);
}
 
Example 2
Source File: DataProviderForExampleGencodeGtfGene.java    From gatk with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static GencodeGtfUTRFeature create5pUtr(final AtomicInteger featureOrderNum, final String contig,
                                                final int length5Utr, final String geneName,
                                                final GencodeGtfExonFeature exon, final Strand codingDirection) {
    final int start = codingDirection == Strand.FORWARD ? exon.getGenomicStartLocation() : exon.getGenomicEndLocation() - length5Utr + 1;
    final int end = codingDirection == Strand.FORWARD ? exon.getGenomicStartLocation() + length5Utr - 1 : exon.getGenomicEndLocation();

    final GencodeGtfFeatureBaseData tmp5pUtr = new GencodeGtfFeatureBaseData(GencodeGtfCodec.GTF_FILE_TYPE_STRING, featureOrderNum.getAndIncrement(), contig, GencodeGtfFeature.ANNOTATION_SOURCE_ENSEMBL, GencodeGtfFeature.FeatureType.UTR,
            start, end, codingDirection, GencodeGtfFeature.GenomicPhase.DOT, "TEST_GENE1", "TEST_TRANSCRIPT1", GencodeGtfFeature.GeneTranscriptType.PROTEIN_CODING,
            null, geneName, GencodeGtfFeature.GeneTranscriptType.PROTEIN_CODING, null, "TEST_TRANSCRIPT1", exon.getExonNumber(), exon.getExonId(), GencodeGtfFeature.LocusLevel.AUTOMATICALLY_ANNOTATED,
            Collections.emptyList(),
            null
    );
    return (GencodeGtfUTRFeature) GencodeGtfFeature.create(tmp5pUtr);
}
 
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);
  }
}