From fdde6d1475a06f70aa6ac4b101935584881923a2 Mon Sep 17 00:00:00 2001 From: jrobinso <933148+jrobinso@users.noreply.github.com> Date: Mon, 2 Oct 2023 08:46:54 -0700 Subject: [PATCH] Replace direct use of Sequence implementation constructors with factory method. Rename "fasta" package to "sequence" --- scripts/test_suite.args | 2 +- .../feature/genome/ColorSpaceSequence.java | 2 + .../org/broad/igv/feature/genome/Genome.java | 4 +- .../igv/feature/genome/GenomeImporter.java | 2 +- .../feature/genome/load/DotGenomeLoader.java | 13 ++-- .../genome/load/FastaGenomeLoader.java | 10 +--- .../feature/genome/load/GenbankLoader.java | 4 +- .../feature/genome/load/JsonGenomeLoader.java | 12 ++-- .../FastaBlockCompressedSequence.java | 6 +- .../{fasta => sequence}/FastaIndex.java | 2 +- .../FastaIndexedSequence.java | 9 ++- .../FastaSequenceParser.java | 3 +- .../{fasta => sequence}/FastaUtils.java | 2 +- .../{ => sequence}/InMemorySequence.java | 2 +- .../genome/{ => sequence}/Sequence.java | 2 +- .../genome/sequence/SequenceFactory.java | 60 +++++++++++++++++++ .../{ => sequence}/SequenceWrapper.java | 3 +- .../genome/{ => sequence}/TwoBitReader.java | 2 +- .../genome/{ => sequence}/TwoBitSequence.java | 4 +- .../java/org/broad/igv/tools/IgvTools.java | 2 +- .../org/broad/igv/util/TutorialUtils.java | 6 +- .../broad/igv/feature/genome/GenomeTest.java | 3 +- .../igv/feature/genome/TwoBitReaderTest.java | 1 + .../FastaBlockCompressedSequenceTest.java | 3 +- .../{fasta => sequence}/FastaIndexTest.java | 3 +- .../FastaIndexedSequenceTest.java | 3 +- .../FastaSequenceParserTest.java | 3 +- .../{fasta => sequence}/FastaUtilsTest.java | 4 +- .../org/broad/igv/tools/IGVToolsTest.java | 2 +- 29 files changed, 111 insertions(+), 63 deletions(-) rename src/main/java/org/broad/igv/feature/genome/{fasta => sequence}/FastaBlockCompressedSequence.java (94%) rename src/main/java/org/broad/igv/feature/genome/{fasta => sequence}/FastaIndex.java (99%) rename src/main/java/org/broad/igv/feature/genome/{fasta => sequence}/FastaIndexedSequence.java (95%) rename src/main/java/org/broad/igv/feature/genome/{fasta => sequence}/FastaSequenceParser.java (97%) rename src/main/java/org/broad/igv/feature/genome/{fasta => sequence}/FastaUtils.java (99%) rename src/main/java/org/broad/igv/feature/genome/{ => sequence}/InMemorySequence.java (98%) rename src/main/java/org/broad/igv/feature/genome/{ => sequence}/Sequence.java (97%) create mode 100644 src/main/java/org/broad/igv/feature/genome/sequence/SequenceFactory.java rename src/main/java/org/broad/igv/feature/genome/{ => sequence}/SequenceWrapper.java (99%) rename src/main/java/org/broad/igv/feature/genome/{ => sequence}/TwoBitReader.java (99%) rename src/main/java/org/broad/igv/feature/genome/{ => sequence}/TwoBitSequence.java (87%) rename src/test/java/org/broad/igv/feature/genome/{fasta => sequence}/FastaBlockCompressedSequenceTest.java (95%) rename src/test/java/org/broad/igv/feature/genome/{fasta => sequence}/FastaIndexTest.java (97%) rename src/test/java/org/broad/igv/feature/genome/{fasta => sequence}/FastaIndexedSequenceTest.java (97%) rename src/test/java/org/broad/igv/feature/genome/{fasta => sequence}/FastaSequenceParserTest.java (96%) rename src/test/java/org/broad/igv/feature/genome/{fasta => sequence}/FastaUtilsTest.java (98%) diff --git a/scripts/test_suite.args b/scripts/test_suite.args index 6331a3cfcb..d0081a816e 100644 --- a/scripts/test_suite.args +++ b/scripts/test_suite.args @@ -20,7 +20,7 @@ --add-exports org.igv/org.broad.igv.feature.dranger=junit --add-exports org.igv/org.broad.igv.feature.dsi=junit --add-exports org.igv/org.broad.igv.feature.genome=junit ---add-exports org.igv/org.broad.igv.feature.genome.fasta=junit +--add-exports org.igv/org.broad.igv.feature.genome.sequence=junit --add-exports org.igv/org.broad.igv.feature.tribble=junit --add-exports org.igv/org.broad.igv.feature.tribble.reader=junit --add-exports org.igv/org.broad.igv.oauth=junit diff --git a/src/main/java/org/broad/igv/feature/genome/ColorSpaceSequence.java b/src/main/java/org/broad/igv/feature/genome/ColorSpaceSequence.java index 3e1754ba76..0dada9d22c 100644 --- a/src/main/java/org/broad/igv/feature/genome/ColorSpaceSequence.java +++ b/src/main/java/org/broad/igv/feature/genome/ColorSpaceSequence.java @@ -25,6 +25,8 @@ package org.broad.igv.feature.genome; +import org.broad.igv.feature.genome.sequence.Sequence; + /** * Created with IntelliJ IDEA. * User: jrobinso diff --git a/src/main/java/org/broad/igv/feature/genome/Genome.java b/src/main/java/org/broad/igv/feature/genome/Genome.java index 3c78cbd6f7..e65244c2bc 100644 --- a/src/main/java/org/broad/igv/feature/genome/Genome.java +++ b/src/main/java/org/broad/igv/feature/genome/Genome.java @@ -38,11 +38,13 @@ import org.broad.igv.Globals; import org.broad.igv.feature.Chromosome; import org.broad.igv.feature.Cytoband; +import org.broad.igv.feature.genome.sequence.InMemorySequence; +import org.broad.igv.feature.genome.sequence.Sequence; +import org.broad.igv.feature.genome.sequence.SequenceWrapper; import org.broad.igv.logging.LogManager; import org.broad.igv.logging.Logger; import org.broad.igv.track.FeatureTrack; import org.broad.igv.track.Track; -import org.broad.igv.ui.panel.ReferenceFrame; import org.broad.igv.util.ResourceLocator; import org.broad.igv.util.liftover.Liftover; diff --git a/src/main/java/org/broad/igv/feature/genome/GenomeImporter.java b/src/main/java/org/broad/igv/feature/genome/GenomeImporter.java index e6d5e3e279..2090fc556d 100644 --- a/src/main/java/org/broad/igv/feature/genome/GenomeImporter.java +++ b/src/main/java/org/broad/igv/feature/genome/GenomeImporter.java @@ -31,7 +31,7 @@ import org.broad.igv.logging.*; import org.broad.igv.Globals; -import org.broad.igv.feature.genome.fasta.FastaUtils; +import org.broad.igv.feature.genome.sequence.FastaUtils; import org.broad.igv.feature.genome.load.GenomeDescriptor; import org.broad.igv.util.FileUtils; import org.broad.igv.util.HttpUtils; diff --git a/src/main/java/org/broad/igv/feature/genome/load/DotGenomeLoader.java b/src/main/java/org/broad/igv/feature/genome/load/DotGenomeLoader.java index 289c6882c7..81f2db4b5a 100644 --- a/src/main/java/org/broad/igv/feature/genome/load/DotGenomeLoader.java +++ b/src/main/java/org/broad/igv/feature/genome/load/DotGenomeLoader.java @@ -1,12 +1,13 @@ package org.broad.igv.feature.genome.load; import htsjdk.tribble.Feature; +import org.broad.igv.feature.genome.sequence.SequenceFactory; import org.broad.igv.logging.*; import org.broad.igv.feature.*; import org.broad.igv.feature.genome.Genome; -import org.broad.igv.feature.genome.Sequence; -import org.broad.igv.feature.genome.fasta.FastaBlockCompressedSequence; -import org.broad.igv.feature.genome.fasta.FastaIndexedSequence; +import org.broad.igv.feature.genome.sequence.Sequence; +import org.broad.igv.feature.genome.sequence.FastaBlockCompressedSequence; +import org.broad.igv.feature.genome.sequence.FastaIndexedSequence; import org.broad.igv.feature.gff.GFFFeatureSource; import org.broad.igv.track.FeatureCollectionSource; import org.broad.igv.track.FeatureTrack; @@ -97,11 +98,7 @@ public Genome loadGenome() throws IOException { if (sequencePath == null) { sequence = null; } else { - if (sequencePath.endsWith(".gz")) { - sequence = new FastaBlockCompressedSequence(sequencePath); - } else { - sequence = new FastaIndexedSequence(sequencePath); - } + sequence = SequenceFactory.getSequence(sequencePath); chromosOrdered = true; } diff --git a/src/main/java/org/broad/igv/feature/genome/load/FastaGenomeLoader.java b/src/main/java/org/broad/igv/feature/genome/load/FastaGenomeLoader.java index c236027dec..726c4bc810 100644 --- a/src/main/java/org/broad/igv/feature/genome/load/FastaGenomeLoader.java +++ b/src/main/java/org/broad/igv/feature/genome/load/FastaGenomeLoader.java @@ -1,11 +1,7 @@ package org.broad.igv.feature.genome.load; import org.broad.igv.feature.genome.Genome; -import org.broad.igv.feature.genome.Sequence; -import org.broad.igv.feature.genome.SequenceWrapper; -import org.broad.igv.feature.genome.fasta.FastaBlockCompressedSequence; -import org.broad.igv.feature.genome.fasta.FastaIndexedSequence; -import org.broad.igv.feature.genome.fasta.FastaUtils; +import org.broad.igv.feature.genome.sequence.*; import org.broad.igv.util.FileUtils; import org.broad.igv.util.HttpUtils; import org.broad.igv.util.Utilities; @@ -56,9 +52,7 @@ public Genome loadGenome() throws IOException { name = file.getName(); } - FastaIndexedSequence sequence = fastaPath.endsWith(".gz") ? - new FastaBlockCompressedSequence(fastaPath) : - new FastaIndexedSequence(fastaPath); + Sequence sequence = SequenceFactory.getSequence(fastaPath, fastaIndexPath); return new Genome(id, name, sequence, true); } diff --git a/src/main/java/org/broad/igv/feature/genome/load/GenbankLoader.java b/src/main/java/org/broad/igv/feature/genome/load/GenbankLoader.java index b3982bb138..41f6bfe5e2 100644 --- a/src/main/java/org/broad/igv/feature/genome/load/GenbankLoader.java +++ b/src/main/java/org/broad/igv/feature/genome/load/GenbankLoader.java @@ -3,8 +3,8 @@ import org.broad.igv.Globals; import org.broad.igv.feature.FeatureDB; import org.broad.igv.feature.genome.Genome; -import org.broad.igv.feature.genome.InMemorySequence; -import org.broad.igv.feature.genome.Sequence; +import org.broad.igv.feature.genome.sequence.InMemorySequence; +import org.broad.igv.feature.genome.sequence.Sequence; import org.broad.igv.track.FeatureTrack; import org.broad.igv.ui.IGV; diff --git a/src/main/java/org/broad/igv/feature/genome/load/JsonGenomeLoader.java b/src/main/java/org/broad/igv/feature/genome/load/JsonGenomeLoader.java index 4bcd63d53d..696ff9d299 100644 --- a/src/main/java/org/broad/igv/feature/genome/load/JsonGenomeLoader.java +++ b/src/main/java/org/broad/igv/feature/genome/load/JsonGenomeLoader.java @@ -7,14 +7,16 @@ import htsjdk.tribble.CloseableTribbleIterator; import htsjdk.tribble.Feature; import htsjdk.tribble.FeatureReader; +import org.broad.igv.feature.genome.sequence.Sequence; +import org.broad.igv.feature.genome.sequence.SequenceFactory; import org.broad.igv.logging.*; import org.broad.igv.Globals; import org.broad.igv.feature.CytoBandFileParser; import org.broad.igv.feature.FeatureDB; import org.broad.igv.feature.NamedFeature; import org.broad.igv.feature.genome.Genome; -import org.broad.igv.feature.genome.fasta.FastaBlockCompressedSequence; -import org.broad.igv.feature.genome.fasta.FastaIndexedSequence; +import org.broad.igv.feature.genome.sequence.FastaBlockCompressedSequence; +import org.broad.igv.feature.genome.sequence.FastaIndexedSequence; import org.broad.igv.track.TribbleFeatureSource; import org.broad.igv.ui.color.ColorUtilities; import org.broad.igv.util.FileUtils; @@ -24,8 +26,6 @@ import java.io.BufferedReader; import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; import java.util.*; public class JsonGenomeLoader extends GenomeLoader { @@ -71,9 +71,7 @@ public Genome loadGenome() throws IOException { gziIndexPath = FileUtils.getAbsolutePath(gziIndexPath, genomePath); } - FastaIndexedSequence sequence = fastaPath.endsWith(".gz") ? - new FastaBlockCompressedSequence(fastaPath, gziIndexPath, indexPath) : - new FastaIndexedSequence(fastaPath, indexPath); + Sequence sequence = SequenceFactory.getSequence(fastaPath, indexPath, gziIndexPath); JsonElement orderedElement = json.get("ordered"); boolean ordered = orderedElement != null && orderedElement.getAsBoolean(); diff --git a/src/main/java/org/broad/igv/feature/genome/fasta/FastaBlockCompressedSequence.java b/src/main/java/org/broad/igv/feature/genome/sequence/FastaBlockCompressedSequence.java similarity index 94% rename from src/main/java/org/broad/igv/feature/genome/fasta/FastaBlockCompressedSequence.java rename to src/main/java/org/broad/igv/feature/genome/sequence/FastaBlockCompressedSequence.java index 3d33b8ab2c..a538023029 100644 --- a/src/main/java/org/broad/igv/feature/genome/fasta/FastaBlockCompressedSequence.java +++ b/src/main/java/org/broad/igv/feature/genome/sequence/FastaBlockCompressedSequence.java @@ -1,4 +1,4 @@ -package org.broad.igv.feature.genome.fasta; +package org.broad.igv.feature.genome.sequence; import htsjdk.samtools.seekablestream.SeekableBufferedStream; import htsjdk.samtools.seekablestream.SeekableStream; @@ -20,12 +20,12 @@ public class FastaBlockCompressedSequence extends FastaIndexedSequence { Mapping[] gziMappings; Mapping zeroMapping = new Mapping(0, 0); - public FastaBlockCompressedSequence(String path) throws IOException { + FastaBlockCompressedSequence(String path) throws IOException { this(path, null, null); } - public FastaBlockCompressedSequence(String path, String gziIndexPath, String indexPath) throws IOException { + FastaBlockCompressedSequence(String path, String gziIndexPath, String indexPath) throws IOException { super(path, indexPath); diff --git a/src/main/java/org/broad/igv/feature/genome/fasta/FastaIndex.java b/src/main/java/org/broad/igv/feature/genome/sequence/FastaIndex.java similarity index 99% rename from src/main/java/org/broad/igv/feature/genome/fasta/FastaIndex.java rename to src/main/java/org/broad/igv/feature/genome/sequence/FastaIndex.java index bfdd61775f..34dd874542 100644 --- a/src/main/java/org/broad/igv/feature/genome/fasta/FastaIndex.java +++ b/src/main/java/org/broad/igv/feature/genome/sequence/FastaIndex.java @@ -23,7 +23,7 @@ * THE SOFTWARE. */ -package org.broad.igv.feature.genome.fasta; +package org.broad.igv.feature.genome.sequence; import org.broad.igv.logging.*; import org.broad.igv.Globals; diff --git a/src/main/java/org/broad/igv/feature/genome/fasta/FastaIndexedSequence.java b/src/main/java/org/broad/igv/feature/genome/sequence/FastaIndexedSequence.java similarity index 95% rename from src/main/java/org/broad/igv/feature/genome/fasta/FastaIndexedSequence.java rename to src/main/java/org/broad/igv/feature/genome/sequence/FastaIndexedSequence.java index f88b391a35..6d151acb73 100644 --- a/src/main/java/org/broad/igv/feature/genome/fasta/FastaIndexedSequence.java +++ b/src/main/java/org/broad/igv/feature/genome/sequence/FastaIndexedSequence.java @@ -23,12 +23,10 @@ * THE SOFTWARE. */ -package org.broad.igv.feature.genome.fasta; +package org.broad.igv.feature.genome.sequence; import htsjdk.samtools.seekablestream.SeekableStream; import org.broad.igv.logging.*; -import org.broad.igv.feature.genome.Sequence; -import org.broad.igv.util.FileUtils; import org.broad.igv.util.stream.IGVSeekableStreamFactory; import java.io.ByteArrayOutputStream; @@ -51,11 +49,12 @@ public class FastaIndexedSequence implements Sequence { private final ArrayList chromoNamesList; - public FastaIndexedSequence(String path) throws IOException { + FastaIndexedSequence(String path) throws IOException { this(path, null); } - public FastaIndexedSequence(String path, String indexPath) throws IOException { + + FastaIndexedSequence(String path, String indexPath) throws IOException { this.path = path; diff --git a/src/main/java/org/broad/igv/feature/genome/fasta/FastaSequenceParser.java b/src/main/java/org/broad/igv/feature/genome/sequence/FastaSequenceParser.java similarity index 97% rename from src/main/java/org/broad/igv/feature/genome/fasta/FastaSequenceParser.java rename to src/main/java/org/broad/igv/feature/genome/sequence/FastaSequenceParser.java index 71a85b0ca4..ab3bd05f86 100644 --- a/src/main/java/org/broad/igv/feature/genome/fasta/FastaSequenceParser.java +++ b/src/main/java/org/broad/igv/feature/genome/sequence/FastaSequenceParser.java @@ -23,14 +23,13 @@ * THE SOFTWARE. */ -package org.broad.igv.feature.genome.fasta; +package org.broad.igv.feature.genome.sequence; import org.broad.igv.util.ParsingUtils; import java.io.BufferedReader; import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.util.Arrays; import java.util.HashMap; import java.util.Map; diff --git a/src/main/java/org/broad/igv/feature/genome/fasta/FastaUtils.java b/src/main/java/org/broad/igv/feature/genome/sequence/FastaUtils.java similarity index 99% rename from src/main/java/org/broad/igv/feature/genome/fasta/FastaUtils.java rename to src/main/java/org/broad/igv/feature/genome/sequence/FastaUtils.java index b1058ec635..22fc43130a 100644 --- a/src/main/java/org/broad/igv/feature/genome/fasta/FastaUtils.java +++ b/src/main/java/org/broad/igv/feature/genome/sequence/FastaUtils.java @@ -23,7 +23,7 @@ * THE SOFTWARE. */ -package org.broad.igv.feature.genome.fasta; +package org.broad.igv.feature.genome.sequence; import org.broad.igv.logging.*; import org.broad.igv.Globals; diff --git a/src/main/java/org/broad/igv/feature/genome/InMemorySequence.java b/src/main/java/org/broad/igv/feature/genome/sequence/InMemorySequence.java similarity index 98% rename from src/main/java/org/broad/igv/feature/genome/InMemorySequence.java rename to src/main/java/org/broad/igv/feature/genome/sequence/InMemorySequence.java index 1731b5b42d..a84b97300c 100644 --- a/src/main/java/org/broad/igv/feature/genome/InMemorySequence.java +++ b/src/main/java/org/broad/igv/feature/genome/sequence/InMemorySequence.java @@ -23,7 +23,7 @@ * THE SOFTWARE. */ -package org.broad.igv.feature.genome; +package org.broad.igv.feature.genome.sequence; import java.util.*; diff --git a/src/main/java/org/broad/igv/feature/genome/Sequence.java b/src/main/java/org/broad/igv/feature/genome/sequence/Sequence.java similarity index 97% rename from src/main/java/org/broad/igv/feature/genome/Sequence.java rename to src/main/java/org/broad/igv/feature/genome/sequence/Sequence.java index d84bc2d22d..4f5494c342 100644 --- a/src/main/java/org/broad/igv/feature/genome/Sequence.java +++ b/src/main/java/org/broad/igv/feature/genome/sequence/Sequence.java @@ -23,7 +23,7 @@ * THE SOFTWARE. */ -package org.broad.igv.feature.genome; +package org.broad.igv.feature.genome.sequence; import org.broad.igv.ui.panel.ReferenceFrame; diff --git a/src/main/java/org/broad/igv/feature/genome/sequence/SequenceFactory.java b/src/main/java/org/broad/igv/feature/genome/sequence/SequenceFactory.java new file mode 100644 index 0000000000..5923606d9b --- /dev/null +++ b/src/main/java/org/broad/igv/feature/genome/sequence/SequenceFactory.java @@ -0,0 +1,60 @@ +package org.broad.igv.feature.genome.sequence; + +import org.broad.igv.logging.LogManager; +import org.broad.igv.logging.Logger; +import org.broad.igv.util.FileUtils; + +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; + + +public class SequenceFactory { + + private static Logger log = LogManager.getLogger(SequenceFactory.class); + + public static Sequence getSequence(String path) throws IOException { + return getSequence(path, null, null); + } + + + public static Sequence getSequence(String path, String indexPath) throws IOException { + return getSequence(path, indexPath, null); + } + + + /** + * Return the Sequence object for the associated paths. + *

+ * TODO -- this logic relieds on file extensions, won't neccessarily work for signed or DRS urls + * + * @param path + * @param indexPath + * @param gziIndexPath + * @return + * @throws IOException + */ + public static Sequence getSequence(String path, String indexPath, String gziIndexPath) throws IOException { + + String p; + if (FileUtils.isRemote(path)) { + try { + p = ((new URL(path)).getPath()); + } catch (MalformedURLException e) { + log.error("Error parsing url: " + path); + p = path; + } + } else { + p = path; + } + + if (gziIndexPath != null || p.endsWith(".gz")) { + return new FastaBlockCompressedSequence(path, gziIndexPath, indexPath); + } else if (p.endsWith(".2bit")) { + return new TwoBitSequence(path); + } else { + return new FastaIndexedSequence(path, indexPath); + } + } + +} diff --git a/src/main/java/org/broad/igv/feature/genome/SequenceWrapper.java b/src/main/java/org/broad/igv/feature/genome/sequence/SequenceWrapper.java similarity index 99% rename from src/main/java/org/broad/igv/feature/genome/SequenceWrapper.java rename to src/main/java/org/broad/igv/feature/genome/sequence/SequenceWrapper.java index 4a98ca76ad..11fc8a37f9 100644 --- a/src/main/java/org/broad/igv/feature/genome/SequenceWrapper.java +++ b/src/main/java/org/broad/igv/feature/genome/sequence/SequenceWrapper.java @@ -27,10 +27,9 @@ * To change this template, choose Tools | Templates * and open the template in the editor. */ -package org.broad.igv.feature.genome; +package org.broad.igv.feature.genome.sequence; import org.broad.igv.logging.*; -import org.broad.igv.ui.panel.ReferenceFrame; import org.broad.igv.util.ObjectCache; import java.util.Hashtable; diff --git a/src/main/java/org/broad/igv/feature/genome/TwoBitReader.java b/src/main/java/org/broad/igv/feature/genome/sequence/TwoBitReader.java similarity index 99% rename from src/main/java/org/broad/igv/feature/genome/TwoBitReader.java rename to src/main/java/org/broad/igv/feature/genome/sequence/TwoBitReader.java index 3f1567362b..982ed5664f 100644 --- a/src/main/java/org/broad/igv/feature/genome/TwoBitReader.java +++ b/src/main/java/org/broad/igv/feature/genome/sequence/TwoBitReader.java @@ -1,4 +1,4 @@ -package org.broad.igv.feature.genome; +package org.broad.igv.feature.genome.sequence; /** * Reader for UCSC ".2bit" sequence files. Reference: https://genome.ucsc.edu/FAQ/FAQformat.html#format7 diff --git a/src/main/java/org/broad/igv/feature/genome/TwoBitSequence.java b/src/main/java/org/broad/igv/feature/genome/sequence/TwoBitSequence.java similarity index 87% rename from src/main/java/org/broad/igv/feature/genome/TwoBitSequence.java rename to src/main/java/org/broad/igv/feature/genome/sequence/TwoBitSequence.java index dd5358793a..5e295a4f01 100644 --- a/src/main/java/org/broad/igv/feature/genome/TwoBitSequence.java +++ b/src/main/java/org/broad/igv/feature/genome/sequence/TwoBitSequence.java @@ -1,4 +1,4 @@ -package org.broad.igv.feature.genome; +package org.broad.igv.feature.genome.sequence; import java.io.IOException; import java.util.List; @@ -7,7 +7,7 @@ public class TwoBitSequence implements Sequence{ private TwoBitReader reader; - public TwoBitSequence(String path) throws IOException { + protected TwoBitSequence(String path) throws IOException { this.reader = new TwoBitReader(path); } diff --git a/src/main/java/org/broad/igv/tools/IgvTools.java b/src/main/java/org/broad/igv/tools/IgvTools.java index 3952a24326..a034ee9af7 100644 --- a/src/main/java/org/broad/igv/tools/IgvTools.java +++ b/src/main/java/org/broad/igv/tools/IgvTools.java @@ -54,7 +54,7 @@ import org.broad.igv.feature.GFFParser; import org.broad.igv.feature.Mutation; import org.broad.igv.feature.genome.*; -import org.broad.igv.feature.genome.fasta.FastaUtils; +import org.broad.igv.feature.genome.sequence.FastaUtils; import org.broad.igv.feature.genome.load.GenomeDescriptor; import org.broad.igv.feature.tribble.CodecFactory; import org.broad.igv.feature.tribble.GFFCodec; diff --git a/src/main/java/org/broad/igv/util/TutorialUtils.java b/src/main/java/org/broad/igv/util/TutorialUtils.java index 6be51a6c7b..671b14a859 100644 --- a/src/main/java/org/broad/igv/util/TutorialUtils.java +++ b/src/main/java/org/broad/igv/util/TutorialUtils.java @@ -30,7 +30,9 @@ import htsjdk.samtools.util.CloseableIterator; import org.broad.igv.Globals; import org.broad.igv.feature.genome.ChromosomeNameComparator; -import org.broad.igv.feature.genome.fasta.FastaIndexedSequence; +import org.broad.igv.feature.genome.sequence.FastaIndexedSequence; +import org.broad.igv.feature.genome.sequence.Sequence; +import org.broad.igv.feature.genome.sequence.SequenceFactory; import org.broad.igv.sam.SAMAlignment; import org.broad.igv.sam.reader.AlignmentReader; import org.broad.igv.sam.reader.AlignmentReaderFactory; @@ -56,7 +58,7 @@ public static void main(String[] args) throws IOException { static void extractFasta(String inputFasta, String outputFasta, String regionsFile) throws IOException { - FastaIndexedSequence inFasta = new FastaIndexedSequence(inputFasta); + Sequence inFasta = SequenceFactory.getSequence(inputFasta); List regions = parseRegions(new File(regionsFile)); diff --git a/src/test/java/org/broad/igv/feature/genome/GenomeTest.java b/src/test/java/org/broad/igv/feature/genome/GenomeTest.java index 74bfff69c3..1b68bba02e 100644 --- a/src/test/java/org/broad/igv/feature/genome/GenomeTest.java +++ b/src/test/java/org/broad/igv/feature/genome/GenomeTest.java @@ -26,7 +26,8 @@ package org.broad.igv.feature.genome; import org.broad.igv.AbstractHeadlessTest; -import org.broad.igv.feature.genome.fasta.FastaIndex; +import org.broad.igv.feature.genome.sequence.FastaIndex; +import org.broad.igv.feature.genome.sequence.Sequence; import org.broad.igv.util.TestUtils; import org.junit.Assume; import org.junit.Rule; diff --git a/src/test/java/org/broad/igv/feature/genome/TwoBitReaderTest.java b/src/test/java/org/broad/igv/feature/genome/TwoBitReaderTest.java index 711b8a8023..20f2fdba1d 100644 --- a/src/test/java/org/broad/igv/feature/genome/TwoBitReaderTest.java +++ b/src/test/java/org/broad/igv/feature/genome/TwoBitReaderTest.java @@ -1,5 +1,6 @@ package org.broad.igv.feature.genome; +import org.broad.igv.feature.genome.sequence.TwoBitReader; import org.broad.igv.util.TestUtils; import org.junit.Test; diff --git a/src/test/java/org/broad/igv/feature/genome/fasta/FastaBlockCompressedSequenceTest.java b/src/test/java/org/broad/igv/feature/genome/sequence/FastaBlockCompressedSequenceTest.java similarity index 95% rename from src/test/java/org/broad/igv/feature/genome/fasta/FastaBlockCompressedSequenceTest.java rename to src/test/java/org/broad/igv/feature/genome/sequence/FastaBlockCompressedSequenceTest.java index af1cfb283d..1c1e8db7c8 100644 --- a/src/test/java/org/broad/igv/feature/genome/fasta/FastaBlockCompressedSequenceTest.java +++ b/src/test/java/org/broad/igv/feature/genome/sequence/FastaBlockCompressedSequenceTest.java @@ -1,6 +1,5 @@ -package org.broad.igv.feature.genome.fasta; +package org.broad.igv.feature.genome.sequence; -import org.broad.igv.feature.genome.Sequence; import org.junit.Test; import static org.junit.Assert.assertEquals; diff --git a/src/test/java/org/broad/igv/feature/genome/fasta/FastaIndexTest.java b/src/test/java/org/broad/igv/feature/genome/sequence/FastaIndexTest.java similarity index 97% rename from src/test/java/org/broad/igv/feature/genome/fasta/FastaIndexTest.java rename to src/test/java/org/broad/igv/feature/genome/sequence/FastaIndexTest.java index 4371b34708..306fc3ceb1 100644 --- a/src/test/java/org/broad/igv/feature/genome/fasta/FastaIndexTest.java +++ b/src/test/java/org/broad/igv/feature/genome/sequence/FastaIndexTest.java @@ -23,10 +23,9 @@ * THE SOFTWARE. */ -package org.broad.igv.feature.genome.fasta; +package org.broad.igv.feature.genome.sequence; import org.broad.igv.AbstractHeadlessTest; -import org.broad.igv.feature.genome.fasta.FastaIndex; import org.broad.igv.util.TestUtils; import org.junit.Before; import org.junit.Test; diff --git a/src/test/java/org/broad/igv/feature/genome/fasta/FastaIndexedSequenceTest.java b/src/test/java/org/broad/igv/feature/genome/sequence/FastaIndexedSequenceTest.java similarity index 97% rename from src/test/java/org/broad/igv/feature/genome/fasta/FastaIndexedSequenceTest.java rename to src/test/java/org/broad/igv/feature/genome/sequence/FastaIndexedSequenceTest.java index bf92cb5532..7720ac9e3a 100644 --- a/src/test/java/org/broad/igv/feature/genome/fasta/FastaIndexedSequenceTest.java +++ b/src/test/java/org/broad/igv/feature/genome/sequence/FastaIndexedSequenceTest.java @@ -23,9 +23,8 @@ * THE SOFTWARE. */ -package org.broad.igv.feature.genome.fasta; +package org.broad.igv.feature.genome.sequence; -import org.broad.igv.feature.genome.SequenceWrapper; import org.broad.igv.util.TestUtils; import org.junit.BeforeClass; import org.junit.Test; diff --git a/src/test/java/org/broad/igv/feature/genome/fasta/FastaSequenceParserTest.java b/src/test/java/org/broad/igv/feature/genome/sequence/FastaSequenceParserTest.java similarity index 96% rename from src/test/java/org/broad/igv/feature/genome/fasta/FastaSequenceParserTest.java rename to src/test/java/org/broad/igv/feature/genome/sequence/FastaSequenceParserTest.java index 07610f227c..91039212b3 100644 --- a/src/test/java/org/broad/igv/feature/genome/fasta/FastaSequenceParserTest.java +++ b/src/test/java/org/broad/igv/feature/genome/sequence/FastaSequenceParserTest.java @@ -23,9 +23,8 @@ * THE SOFTWARE. */ -package org.broad.igv.feature.genome.fasta; +package org.broad.igv.feature.genome.sequence; -import org.broad.igv.feature.genome.InMemorySequence; import org.junit.BeforeClass; import org.junit.Test; diff --git a/src/test/java/org/broad/igv/feature/genome/fasta/FastaUtilsTest.java b/src/test/java/org/broad/igv/feature/genome/sequence/FastaUtilsTest.java similarity index 98% rename from src/test/java/org/broad/igv/feature/genome/fasta/FastaUtilsTest.java rename to src/test/java/org/broad/igv/feature/genome/sequence/FastaUtilsTest.java index ac94556f38..561d8d056c 100644 --- a/src/test/java/org/broad/igv/feature/genome/fasta/FastaUtilsTest.java +++ b/src/test/java/org/broad/igv/feature/genome/sequence/FastaUtilsTest.java @@ -23,14 +23,12 @@ * THE SOFTWARE. */ -package org.broad.igv.feature.genome.fasta; +package org.broad.igv.feature.genome.sequence; import org.broad.igv.AbstractHeadlessTest; import org.broad.igv.exceptions.DataLoadException; import org.broad.igv.feature.genome.Genome; import org.broad.igv.feature.genome.GenomeManager; -import org.broad.igv.feature.genome.fasta.FastaIndex; -import org.broad.igv.feature.genome.fasta.FastaUtils; import org.broad.igv.util.TestUtils; import org.junit.Ignore; import org.junit.Test; diff --git a/src/test/java/org/broad/igv/tools/IGVToolsTest.java b/src/test/java/org/broad/igv/tools/IGVToolsTest.java index 2a1ff455c5..071c5432a8 100644 --- a/src/test/java/org/broad/igv/tools/IGVToolsTest.java +++ b/src/test/java/org/broad/igv/tools/IGVToolsTest.java @@ -29,7 +29,7 @@ import org.broad.igv.data.Dataset; import org.broad.igv.data.expression.ExpressionFileParser; import org.broad.igv.feature.FeatureDB; -import org.broad.igv.feature.genome.fasta.FastaIndex; +import org.broad.igv.feature.genome.sequence.FastaIndex; import org.broad.igv.feature.genome.Genome; import org.broad.igv.sam.Alignment; import org.broad.igv.sam.reader.AlignmentReader;