Examples of ReferenceSequence


Examples of htsjdk.samtools.reference.ReferenceSequence

        // Design the baits!
        int discardedBaits = 0;
        final IntervalList baits = new IntervalList(targets.getHeader());
        for (final Interval target : targets) {
            final int sequenceIndex = targets.getHeader().getSequenceIndex(target.getSequence());
            final ReferenceSequence reference = referenceWalker.get(sequenceIndex);

            for (final Bait bait : DESIGN_STRATEGY.design(this, target, reference)) {
                if (bait.length() != BAIT_SIZE) {
                    throw new PicardException("Bait designed at wrong length: " + bait);
                }
View Full Code Here

Examples of htsjdk.samtools.reference.ReferenceSequence

     * @return SAMSequenceRecords containing info from the fasta, plus from cmd-line arguments.
     */
    SAMSequenceDictionary makeSequenceDictionary(final File referenceFile) {
        final ReferenceSequenceFile refSeqFile =
                ReferenceSequenceFileFactory.getReferenceSequenceFile(referenceFile, TRUNCATE_NAMES_AT_WHITESPACE);
        ReferenceSequence refSeq;
        final List<SAMSequenceRecord> ret = new ArrayList<SAMSequenceRecord>();
        final Set<String> sequenceNames = new HashSet<String>();
        for (int numSequences = 0; numSequences < NUM_SEQUENCES && (refSeq = refSeqFile.nextSequence()) != null; ++numSequences) {
            if (sequenceNames.contains(refSeq.getName())) {
                throw new PicardException("Sequence name appears more than once in reference: " + refSeq.getName());
            }
            sequenceNames.add(refSeq.getName());
            ret.add(makeSequenceRecord(refSeq));
        }
        return new SAMSequenceDictionary(ret);
    }
View Full Code Here

Examples of htsjdk.samtools.reference.ReferenceSequence

        }

        final ReferenceSequenceFile ref = ReferenceSequenceFileFactory.getReferenceSequenceFile(INPUT, TRUNCATE_SEQUENCE_NAMES_AT_WHITESPACE);
        final BufferedWriter out = IOUtil.openFileForBufferedWriting(OUTPUT);

        ReferenceSequence seq = null;
        while ((seq = ref.nextSequence()) != null) {
            final String name  = seq.getName();
            final byte[] bases = seq.getBases();

            try {
                out.write(">");
                out.write(name);
                out.newLine();
View Full Code Here

Examples of htsjdk.samtools.reference.ReferenceSequence


        if (refFile != null) {
            intervalToGc = new HashMap<Interval,Double>();
            for (final Interval target : uniqueTargets) {
                final ReferenceSequence rs = refFile.getSubsequenceAt(target.getSequence(), target.getStart(), target.getEnd());
                intervalToGc.put(target,SequenceUtil.calculateGc(rs.getBases()));
            }
        }

        setup(accumulationLevels, samRgRecords);
    }
View Full Code Here

Examples of htsjdk.samtools.reference.ReferenceSequence

    public void acceptRecord(final SAMRecordAndReference args) {
      mappedRecordCount++;

      final SAMRecord samRecord = args.getSamRecord();
      final ReferenceSequence referenceSequence = args.getReferenceSequence();

      final byte[] readBases = samRecord.getReadBases();
      final byte[] readQualities = samRecord.getBaseQualities();
      final byte[] refBases = referenceSequence.getBases();

      if (samRecord.getReadLength() < minReadLength) {
        smallReadCount++;
        return;
      } else if (SequenceUtil.countMismatches(samRecord, refBases, true) > Math.round(samRecord.getReadLength() * maxMismatchRate)) {
View Full Code Here

Examples of htsjdk.samtools.reference.ReferenceSequence

            }

            @Override
            public ReferenceSequence getSequence(final String contig) {
                if (contig.equals(record.getSequenceName())) {
                    return new ReferenceSequence(record.getSequenceName(), 0, referenceString.getBytes());
                } else {
                    return null;
                }
            }
View Full Code Here

Examples of net.sf.picard.reference.ReferenceSequence

    int coverage;
    int previous_position = 0;

    final Map<SNPCallPair, TreeMap<Integer, Long>> calltable_validation = new HashMap<SNPCallPair, TreeMap<Integer, Long>>();

    ReferenceSequence reference = null;

    while ((reference = reference_file.nextSequence()) != null) {
      for (SamPositionIterator position_iterator : positionIterators) {
        position_iterator.nextSequence();
        String ref_name = reference.getName();

        if (!position_iterator.getCurrentSequence().equals(ref_name))
          continue;

        System.out.println("Processing reads on sequence " + ref_name);

        byte[] ref_array = reference.getBases();

        // Iterate through loci with enough coverage
        while (position_iterator.hasMoreElements()) {

          PositionInfo p = position_iterator.nextElement();
View Full Code Here

Examples of net.sf.picard.reference.ReferenceSequence

      if (tagNucleotideDiffs == null) {
        addError(new SAMValidationError(Type.MISSING_TAG_NM,
            "NM tag (nucleotide differences) is missing",
            record.getReadName(), recordNumber));
      } else if (refFileWalker != null) {
        final ReferenceSequence refSequence = refFileWalker.get(record
            .getReferenceIndex());
        final int actualNucleotideDiffs = SequenceUtil
            .calculateSamNmTag(record, refSequence.getBases(), 0,
                isBisulfiteSequenced());

        if (!tagNucleotideDiffs.equals(actualNucleotideDiffs)) {
          addError(new SAMValidationError(Type.INVALID_TAG_NM,
              "NM tag (nucleotide differences) in file ["
View Full Code Here

Examples of net.sf.picard.reference.ReferenceSequence

  public static byte[] getBasesFromReferenceFile(String referenceFilePath,
      String seqName, int from, int length) {
    ReferenceSequenceFile referenceSequenceFile = ReferenceSequenceFileFactory
        .getReferenceSequenceFile(new File(referenceFilePath));
    ReferenceSequence sequence = referenceSequenceFile.getSequence(seqName);
    byte[] bases = referenceSequenceFile.getSubsequenceAt(
        sequence.getName(), from, from + length).getBases();
    return bases;
  }
View Full Code Here

Examples of net.sf.picard.reference.ReferenceSequence

              + file.getAbsolutePath() + "'");
  }

  public static ReferenceSequence getReferenceSequenceOrNull(
      ReferenceSequenceFile rsFile, String name) {
    ReferenceSequence rs = null;
    try {
      return rsFile.getSequence(name);
    } catch (PicardException e) {
      return null;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.