Package htsjdk.samtools.util

Examples of htsjdk.samtools.util.AsciiWriter


     */
    int writeSamText(PrintStream printStream) {
        try {
            IOUtil.assertFileIsReadable(INPUT);
            final SAMFileReader in = new SAMFileReader(INPUT);
            final AsciiWriter writer = new AsciiWriter(printStream);
            final SAMFileHeader header = in.getFileHeader();
            if (header.getTextHeader() != null) {
                writer.write(header.getTextHeader());
            } else {
                // Headers that are too large are not retained as text, so need to regenerate text
                new SAMTextHeaderCodec().encode(writer, header, true);
            }

            for (final SAMRecord rec : in) {
                if (printStream.checkError()) {
                    return 1;
                }

                if (this.ALIGNMENT_STATUS == AlignmentStatus.Aligned   && rec.getReadUnmappedFlag()) continue;
                if (this.ALIGNMENT_STATUS == AlignmentStatus.Unaligned && !rec.getReadUnmappedFlag()) continue;

                if (this.PF_STATUS == PfStatus.PF    && rec.getReadFailsVendorQualityCheckFlag()) continue;
                if (this.PF_STATUS == PfStatus.NonPF && !rec.getReadFailsVendorQualityCheckFlag()) continue;

                writer.write(rec.getSAMString());
            }
            writer.flush();
            if (printStream.checkError()) {
                return 1;
            }
            return 0;
        } catch (IOException e) {
View Full Code Here


    @Test
    public void testHeaderVersion() throws Exception {
        final String oldVersionHeader = "@HD\tVN:1.3\tSO:unsorted";
        final File inputSam = File.createTempFile("ViewSamTest.input.", ".sam");
        inputSam.deleteOnExit();
        final AsciiWriter writer = new AsciiWriter(new FileOutputStream(inputSam));
        writer.write(oldVersionHeader);
        writer.write("\n");
        writer.close();
        final File viewSamOutputFile = File.createTempFile("ViewSamTest.output.", ".sam");
        viewSamOutputFile.deleteOnExit();
        final ViewSam viewSam = new ViewSam();
        viewSam.INPUT = inputSam;
        final PrintStream viewSamPrintStream = new PrintStream(viewSamOutputFile);
View Full Code Here

TOP

Related Classes of htsjdk.samtools.util.AsciiWriter

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.