From 78867688059bc03fdcd318227e9713d683b8b8d0 Mon Sep 17 00:00:00 2001 From: Tim Fennell Date: Tue, 13 Sep 2016 16:06:29 -0400 Subject: [PATCH] Added a secondary constructor to IntervalList that takes a dict. (#703) --- src/main/java/htsjdk/samtools/SAMFileHeader.java | 6 ++++++ src/main/java/htsjdk/samtools/util/IntervalList.java | 11 +++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/java/htsjdk/samtools/SAMFileHeader.java b/src/main/java/htsjdk/samtools/SAMFileHeader.java index 22d18a627..47543c2a6 100644 --- a/src/main/java/htsjdk/samtools/SAMFileHeader.java +++ b/src/main/java/htsjdk/samtools/SAMFileHeader.java @@ -120,6 +120,12 @@ public SAMFileHeader() { setAttribute(VERSION_TAG, CURRENT_VERSION); } + /** Constructor that initializes the sequence dictionary with the provided one. */ + public SAMFileHeader(final SAMSequenceDictionary dict) { + this(); + setSequenceDictionary(dict); + } + public String getVersion() { return (String) getAttribute("VN"); } diff --git a/src/main/java/htsjdk/samtools/util/IntervalList.java b/src/main/java/htsjdk/samtools/util/IntervalList.java index 8b46a1ceb..32b7176f5 100644 --- a/src/main/java/htsjdk/samtools/util/IntervalList.java +++ b/src/main/java/htsjdk/samtools/util/IntervalList.java @@ -71,12 +71,15 @@ /** Constructs a new interval list using the supplied header information. */ public IntervalList(final SAMFileHeader header) { - if (header == null) { - throw new IllegalArgumentException("SAMFileHeader must be supplied."); - } + if (header == null) throw new IllegalArgumentException("SAMFileHeader must be supplied."); this.header = header; } + /** Constructs a new interval list using the supplied header information. */ + public IntervalList(final SAMSequenceDictionary dict) { + this(new SAMFileHeader(dict)); + } + /** Gets the header (if there is one) for the interval list. */ public SAMFileHeader getHeader() { return header; } @@ -769,4 +772,4 @@ public int compare(final Interval lhs, final Interval rhs) { return retval; } -} \ No newline at end of file +}