@Override protected Index doInBackground() throws Exception { int binSize = IgvTools.LINEAR_BIN_SIZE; FeatureCodec codec = CodecFactory.getCodec( file.getAbsolutePath(), GenomeManager.getInstance().getCurrentGenome()); if (codec != null) { try { Index index = IndexFactory.createLinearIndex(file, codec, binSize); if (index != null) { IgvTools.writeTribbleIndex(index, idxFile.getAbsolutePath()); } return index; } catch (TribbleException.MalformedFeatureFile e) { StringBuffer buf = new StringBuffer(); buf.append("<html>Files must be sorted by start position prior to indexing.<br>"); buf.append(e.getMessage()); buf.append( "<br><br>Note: igvtools can be used to sort the file, select \"File > Run igvtools...\"."); MessageUtils.showMessage(buf.toString()); } } else { throw new DataLoadException("Unknown File Type", file.getAbsolutePath()); } return null; }
@Test public void testLoadGFFAliasedChrs() throws Exception { String filepath = TestUtils.DATA_DIR + "gff/aliased.unsorted.gff"; Genome genome = IgvTools.loadGenome(TestUtils.DATA_DIR + "genomes/hg18_truncated_aliased.genome"); List<Track> tracks = trackLoader.load(new ResourceLocator(filepath), genome); assertEquals(1, tracks.size()); FeatureTrack track = (FeatureTrack) tracks.get(0); assertEquals("aliased.unsorted.gff", track.getName()); List<Feature> features = track.getFeatures("chr1", 0, Integer.MAX_VALUE); assertEquals(56, features.size()); features = track.getFeatures("chr5", 0, Integer.MAX_VALUE); assertEquals(16, features.size()); // Non-aliased features = track.getFeatures("NC_007072.3", 0, Integer.MAX_VALUE); assertEquals(30, features.size()); }