// Path: src/main/java/org/seqdoop/hadoop_bam/util/SAMHeaderReader.java
// public final class SAMHeaderReader {
// 	/** A String property corresponding to a ValidationStringency
// 	 * value. If set, the given stringency is used when any part of the
// 	 * Hadoop-BAM library reads SAM or BAM.
// 	 */
// 	public static final String VALIDATION_STRINGENCY_PROPERTY =
// 		"hadoopbam.samheaderreader.validation-stringency";
// 
// 	public static SAMFileHeader readSAMHeaderFrom(Path path, Configuration conf)
// 		throws IOException
// 	{
// 		InputStream i = path.getFileSystem(conf).open(path);
// 		final SAMFileHeader h = readSAMHeaderFrom(i, conf);
// 		i.close();
// 		return h;
// 	}
// 
// 	/** Does not close the stream. */
// 	public static SAMFileHeader readSAMHeaderFrom(
// 		final InputStream in, final Configuration conf)
// 	{
// 		final ValidationStringency
// 			stringency = getValidationStringency(conf);
// 		SamReaderFactory readerFactory = SamReaderFactory.makeDefault()
// 				.setOption(SamReaderFactory.Option.EAGERLY_DECODE, false)
// 				.setUseAsyncIo(false);
// 		if (stringency != null) {
// 			readerFactory.validationStringency(stringency);
// 		}
// 
// 		final ReferenceSource refSource = getReferenceSource(conf);
// 		if (null != refSource) {
// 			readerFactory.referenceSource(refSource);
// 		}
// 		return readerFactory.open(SamInputResource.of(in)).getFileHeader();
// 	}
// 
// 	public static ValidationStringency getValidationStringency(
// 		final Configuration conf)
// 	{
// 		final String p = conf.get(VALIDATION_STRINGENCY_PROPERTY);
// 		return p == null ? null : ValidationStringency.valueOf(p);
// 	}
// 
// 	public static ReferenceSource getReferenceSource(
// 			final Configuration conf)
// 	{
// 		//TODO: There isn't anything particularly CRAM-specific about reference source or validation
// 		// stringency other than that a reference source is required for CRAM files. We should move
// 		// the reference source and validation stringency property names and utility methods out of
// 		// CRAMInputFormat and SAMHeaderReader and combine them together into a single class for extracting
// 		// configuration params, but it would break backward compatibility with existing code that
// 		// is dependent on the CRAMInputFormat.REFERENCE_SOURCE_PATH_PROPERTY.
// 		final String refSourcePath = conf.get(CRAMInputFormat.REFERENCE_SOURCE_PATH_PROPERTY);
// 		return refSourcePath == null ? null : new ReferenceSource(NIOFileUtil.asPath(refSourcePath));
// 	}
// }


import htsjdk.samtools.*;
import htsjdk.samtools.cram.CRAMException;
import org.apache.hadoop.conf.Configuration;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.seqdoop.hadoop_bam.util.SAMHeaderReader;
import java.io.InputStream;
import java.net.URI;
import static org.junit.Assert.assertEquals;
package org.seqdoop.hadoop_bam;




public class TestSAMHeaderReader {
    @Rule
    public ExpectedException thrown= ExpectedException.none();

    @Test
    public void testBAMHeaderReaderNoReference() throws Exception {

        final Configuration conf = new Configuration();

        InputStream inputStream = ClassLoader.getSystemClassLoader().getResourceAsStream("test.bam");
        final SamReader samReader = SamReaderFactory.makeDefault().open(SamInputResource.of(inputStream));
        int sequenceCount = samReader.getFileHeader().getSequenceDictionary().size();
        samReader.close();

        inputStream = ClassLoader.getSystemClassLoader().getResourceAsStream("test.bam");
// Path: src/main/java/org/seqdoop/hadoop_bam/util/SAMHeaderReader.java
// public final class SAMHeaderReader {
// 	/** A String property corresponding to a ValidationStringency
// 	 * value. If set, the given stringency is used when any part of the
// 	 * Hadoop-BAM library reads SAM or BAM.
// 	 */
// 	public static final String VALIDATION_STRINGENCY_PROPERTY =
// 		"hadoopbam.samheaderreader.validation-stringency";
// 
// 	public static SAMFileHeader readSAMHeaderFrom(Path path, Configuration conf)
// 		throws IOException
// 	{
// 		InputStream i = path.getFileSystem(conf).open(path);
// 		final SAMFileHeader h = readSAMHeaderFrom(i, conf);
// 		i.close();
// 		return h;
// 	}
// 
// 	/** Does not close the stream. */
// 	public static SAMFileHeader readSAMHeaderFrom(
// 		final InputStream in, final Configuration conf)
// 	{
// 		final ValidationStringency
// 			stringency = getValidationStringency(conf);
// 		SamReaderFactory readerFactory = SamReaderFactory.makeDefault()
// 				.setOption(SamReaderFactory.Option.EAGERLY_DECODE, false)
// 				.setUseAsyncIo(false);
// 		if (stringency != null) {
// 			readerFactory.validationStringency(stringency);
// 		}
// 
// 		final ReferenceSource refSource = getReferenceSource(conf);
// 		if (null != refSource) {
// 			readerFactory.referenceSource(refSource);
// 		}
// 		return readerFactory.open(SamInputResource.of(in)).getFileHeader();
// 	}
// 
// 	public static ValidationStringency getValidationStringency(
// 		final Configuration conf)
// 	{
// 		final String p = conf.get(VALIDATION_STRINGENCY_PROPERTY);
// 		return p == null ? null : ValidationStringency.valueOf(p);
// 	}
// 
// 	public static ReferenceSource getReferenceSource(
// 			final Configuration conf)
// 	{
// 		//TODO: There isn't anything particularly CRAM-specific about reference source or validation
// 		// stringency other than that a reference source is required for CRAM files. We should move
// 		// the reference source and validation stringency property names and utility methods out of
// 		// CRAMInputFormat and SAMHeaderReader and combine them together into a single class for extracting
// 		// configuration params, but it would break backward compatibility with existing code that
// 		// is dependent on the CRAMInputFormat.REFERENCE_SOURCE_PATH_PROPERTY.
// 		final String refSourcePath = conf.get(CRAMInputFormat.REFERENCE_SOURCE_PATH_PROPERTY);
// 		return refSourcePath == null ? null : new ReferenceSource(NIOFileUtil.asPath(refSourcePath));
// 	}
// }


// Path: src/test/java/org/seqdoop/hadoop_bam/TestSAMHeaderReader.java
import htsjdk.samtools.*;
import htsjdk.samtools.cram.CRAMException;
import org.apache.hadoop.conf.Configuration;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.seqdoop.hadoop_bam.util.SAMHeaderReader;
import java.io.InputStream;
import java.net.URI;
import static org.junit.Assert.assertEquals;

package org.seqdoop.hadoop_bam;




public class TestSAMHeaderReader {
    @Rule
    public ExpectedException thrown= ExpectedException.none();

    @Test
    public void testBAMHeaderReaderNoReference() throws Exception {

        final Configuration conf = new Configuration();

        InputStream inputStream = ClassLoader.getSystemClassLoader().getResourceAsStream("test.bam");
        final SamReader samReader = SamReaderFactory.makeDefault().open(SamInputResource.of(inputStream));
        int sequenceCount = samReader.getFileHeader().getSequenceDictionary().size();
        samReader.close();

        inputStream = ClassLoader.getSystemClassLoader().getResourceAsStream("test.bam");
        SAMFileHeader samHeader = SAMHeaderReader.readSAMHeaderFrom(inputStream, conf);