Package htsjdk.samtools.reference

Examples of htsjdk.samtools.reference.ReferenceSequenceFile


* @version 0.1
*/
public class CreateBWTFromReference {
    private byte[] loadReference( File inputFile ) {
        // Read in the first sequence in the input file
        ReferenceSequenceFile reference = ReferenceSequenceFileFactory.getReferenceSequenceFile(inputFile);
        ReferenceSequence sequence = reference.nextSequence();
        return sequence.getBases();
    }
View Full Code Here


        ReferenceSequence sequence = reference.nextSequence();
        return sequence.getBases();
    }

    private byte[] loadReverseReference( File inputFile ) {
        ReferenceSequenceFile reference = ReferenceSequenceFileFactory.getReferenceSequenceFile(inputFile);
        ReferenceSequence sequence = reference.nextSequence();
        PackUtils.reverse(sequence.getBases());
        return sequence.getBases();
    }
View Full Code Here

    private final static double ACTIVE_PROB_THRESHOLD= 0.002;

    @BeforeClass
    public void init() throws FileNotFoundException {
        // sequence
        ReferenceSequenceFile seq = new CachingIndexedFastaSequenceFile(new File(b37KGReference));
        genomeLocParser = new GenomeLocParser(seq);
    }
View Full Code Here

    private final static double ACTIVE_PROB_THRESHOLD= 0.002;

    @BeforeClass
    public void init() throws FileNotFoundException {
        // sequence
        ReferenceSequenceFile seq = new CachingIndexedFastaSequenceFile(new File(hg18Reference));
        genomeLocParser = new GenomeLocParser(seq);
        startLoc = genomeLocParser.createGenomeLoc("chr1", 1, 1, 100);
    }
View Full Code Here

        }
        catch(IllegalArgumentException ex) {
            usage("Invalid output type: " + args[2]);
        }

        ReferenceSequenceFile sequenceFile = ReferenceSequenceFileFactory.getReferenceSequenceFile(fastaFile);
        SAMSequenceDictionary dictionary = sequenceFile.getSequenceDictionary();

        switch(outputType) {
            case ANN:
                ANNWriter annWriter = new ANNWriter(outputFile);
                annWriter.write(dictionary);
View Full Code Here

        }

        // Read in the first sequence in the input file
        String inputFileName = argv[0];
        File inputFile = new File(inputFileName);
        ReferenceSequenceFile reference = ReferenceSequenceFileFactory.getReferenceSequenceFile(inputFile);
        ReferenceSequence sequence = reference.nextSequence();

        // Target file for output
        PackUtils.writeReferenceSequence( new File(argv[1]), sequence.getBases() );

        // Reverse the bases in the reference
View Full Code Here

        File hg18Ref = new File(BaseTest.hg18Reference);
        try {
            ReferenceDataSource referenceDataSource = new ReferenceDataSource(hg18Ref);
            hg18Header = new SAMFileHeader();
            hg18Header.setSequenceDictionary(referenceDataSource.getReference().getSequenceDictionary());
            ReferenceSequenceFile seq = new CachingIndexedFastaSequenceFile(hg18Ref);
            hg18GenomeLocParser = new GenomeLocParser(seq);
            hg18ReferenceLocs = Collections.unmodifiableList(GenomeLocSortedSet.createSetFromSequenceDictionary(referenceDataSource.getReference().getSequenceDictionary()).toList()) ;
        }
        catch(FileNotFoundException ex) {
            throw new UserException.CouldNotReadInputFile(hg18Ref,ex);
        }

        File hg19Ref = new File(BaseTest.hg19Reference);
        try {
            ReferenceDataSource referenceDataSource = new ReferenceDataSource(hg19Ref);
            hg19Header = new SAMFileHeader();
            hg19Header.setSequenceDictionary(referenceDataSource.getReference().getSequenceDictionary());
            ReferenceSequenceFile seq = new CachingIndexedFastaSequenceFile(hg19Ref);
            hg19GenomeLocParser = new GenomeLocParser(seq);
            hg19ReferenceLocs = Collections.unmodifiableList(GenomeLocSortedSet.createSetFromSequenceDictionary(referenceDataSource.getReference().getSequenceDictionary()).toList()) ;

            hg19exomeIntervals = Collections.unmodifiableList(IntervalUtils.parseIntervalArguments(hg19GenomeLocParser, Arrays.asList(hg19Intervals)));
        }
View Full Code Here

    @Override
    protected int execute() throws Exception {
        BasicConfigurator.configure();
        logger.setLevel(Level.INFO);

        final ReferenceSequenceFile ref;
        try {
            ref = ReferenceSequenceFileFactory.getReferenceSequenceFile(refFile);
        } catch ( Exception e ) {
            throw new UserException("Couldn't load provided reference sequence file " + refFile, e);
        }

        variant = parseVariantList(variant);

        Comparator<Pair<Integer,File>> positionComparator = new PositionComparator();

        Queue<Pair<Integer,File>> priorityQueue;
        if (assumeSorted)
            priorityQueue = new LinkedList<>();
        else
            priorityQueue = new PriorityQueue<>(10000, positionComparator);

        FileType fileType = FileType.INVALID;
        for (File file : variant) {
            // if it returns a valid type, it will be the same for all files
            fileType = fileExtensionCheck(file, outputFile);
            if (fileType == FileType.INVALID)
                return 1;

            if (assumeSorted){
                priorityQueue.add(new Pair<>(0,file));
            }
            else{
                if (!file.exists()) {
                    throw new UserException(String.format("File %s doesn't exist",file.getAbsolutePath()));
                }
                FeatureReader<VariantContext> reader = getFeatureReader(fileType, file);
                Iterator<VariantContext> it = reader.iterator();
                if(!it.hasNext()){
                    System.err.println(String.format("File %s is empty. This file will be ignored",file.getAbsolutePath()));
                    continue;
                }
                VariantContext vc = it.next();
                int firstPosition = vc.getStart();
                reader.close();
                priorityQueue.add(new Pair<>(firstPosition,file));
            }

        }

        FileOutputStream outputStream = new FileOutputStream(outputFile);
        EnumSet<Options> options = EnumSet.of(Options.INDEX_ON_THE_FLY);
        final IndexCreator idxCreator = GATKVCFUtils.getIndexCreator(variant_index_type, variant_index_parameter, outputFile, ref.getSequenceDictionary());
        final VariantContextWriter outputWriter = VariantContextWriterFactory.create(outputFile, outputStream, ref.getSequenceDictionary(), idxCreator, options);

        boolean firstFile = true;
        int count = 0;
        while(!priorityQueue.isEmpty() ){
            count++;
View Full Code Here

                addSeqToClip(rs.getName(), rs.getBases());
            }
        }

        if (clipSequenceFile != null) {
            ReferenceSequenceFile rsf = ReferenceSequenceFileFactory.getReferenceSequenceFile(new File(clipSequenceFile));

            while (true) {
                ReferenceSequence rs = rsf.nextSequence();
                if (rs == null)
                    break;
                else {
                    addSeqToClip(rs.getName(), rs.getBases());
                }
View Full Code Here

     * Fake a reference sequence file.  Essentially, seek a header with a bunch of dummy data.
     *
     * @return A 'fake' reference sequence file
     */
    private static ReferenceSequenceFile fakeReferenceSequenceFile() {
        return new ReferenceSequenceFile() {
            public SAMSequenceDictionary getSequenceDictionary() {
                SAMSequenceRecord sequenceRecord = new SAMSequenceRecord("chr1", 1000000);
                SAMSequenceDictionary dictionary = new SAMSequenceDictionary(Collections.singletonList(sequenceRecord));
                return dictionary;
            }
View Full Code Here

TOP

Related Classes of htsjdk.samtools.reference.ReferenceSequenceFile

Copyright © 2018 www.massapicom. 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.