示例#1
0
文件: LiftOver.java 项目: gkno/picard
 /**
  * Throw an exception if all the "to" sequence names in the chains are not found in the given
  * sequence dictionary.
  */
 public void validateToSequences(final SAMSequenceDictionary sequenceDictionary) {
   for (final Chain chain : chains.getAll()) {
     if (sequenceDictionary.getSequence(chain.toSequenceName) == null) {
       throw new PicardException(
           "Sequence "
               + chain.toSequenceName
               + " from chain file is not found in sequence dictionary.");
     }
   }
 }
示例#2
0
 public static Interval parseOne(SAMSequenceDictionary dict, String s) {
   int colon = s.indexOf(':');
   if (colon < 1 || colon + 1 == s.length()) return null;
   int hyphen = s.indexOf('-', colon + 1);
   if (hyphen == -1) return null;
   int start, end;
   try {
     SAMSequenceRecord ssr = null;
     String chrom = s.substring(0, colon);
     if (dict != null) {
       ssr = dict.getSequence(chrom);
       if (ssr == null) return null;
     }
     start = Integer.parseInt(s.substring(colon + 1, hyphen));
     end = Integer.parseInt(s.substring(hyphen + 1));
     if (end < start) return null;
     return new Interval(s.substring(0, colon), start, end);
   } catch (Exception e) {
     return null;
   }
 }
示例#3
0
  public Datum map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {
    GenomeLoc cur = context.getLocation();

    if (verbose && showSkipped) {
      for (long i = context.getSkippedBases(); i >= 0; i--) {
        SAMSequenceDictionary dictionary =
            getToolkit().getReferenceDataSource().getReference().getSequenceDictionary();
        SAMSequenceRecord contig = dictionary.getSequence(cur.getContig());
        if (cur.getStop() < contig.getSequenceLength())
          cur = getToolkit().getGenomeLocParser().incPos(cur, 1);
        else
          cur =
              getToolkit()
                  .getGenomeLocParser()
                  .createGenomeLoc(
                      dictionary.getSequence(contig.getSequenceIndex() + 1).getSequenceName(),
                      1,
                      1);
        out.printf("%s: skipped%n", cur);
      }
    }

    long nRodsHere = 0;
    long nTotalBases = 0;

    if (ref == null) {
      // we're getting the last skipped update
      if (verbose)
        out.printf(
            "Last position was %s: skipping %d bases%n",
            context.getLocation(), context.getSkippedBases());
      nRodsHere = -1; // don't update this
      nTotalBases = context.getSkippedBases();
    } else {
      Collection<RODRecordList> rods = new LinkedList<RODRecordList>();
      for (RODRecordList rod : tracker.getBoundRodTracks()) {
        // System.out.printf("Considering rod %s%n", rod);
        if (rod.getLocation().getStart() == context.getLocation().getStart()
            && !rod.getName().equals("interval")) {
          // only consider the first element
          // System.out.printf("adding it%n");
          rods.add(rod);
        }
      }

      nRodsHere = rods.size();

      if (nRodsHere > 0) {
        if (verbose) {
          List<String> names = new ArrayList<String>();
          for (RODRecordList rod : rods) {
            names.add(rod.getName());
          }

          // System.out.printf("context is %s", context.getSkippedBases());
          out.printf(
              "At %s: found %d rod(s) [%s] after skipping %d bases%n",
              context.getLocation(), nRodsHere, Utils.join(",", names), context.getSkippedBases());
        }
      }

      nTotalBases = context.getSkippedBases() + 1;
    }

    return new Datum(nRodsHere, context.getSkippedBases(), nTotalBases);
  }