make the size of a GenomeLoc int instead of long
it will never be bigger than an int and it's actually useful to be an int so we can use it as parameters to array/list/hash size creation.
This commit is contained in:
parent
5af3999a2d
commit
e1d69e4060
|
|
@ -436,7 +436,7 @@ public class GenomeLoc implements Comparable<GenomeLoc>, Serializable, HasGenome
|
|||
* never be < 1.
|
||||
*/
|
||||
@Ensures("result > 0")
|
||||
public long size() {
|
||||
public int size() {
|
||||
return stop - start + 1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -314,10 +314,10 @@ public class IntervalUtils {
|
|||
* @param reference The reference for the intervals.
|
||||
* @return A map of contig names with their sizes.
|
||||
*/
|
||||
public static Map<String, Long> getContigSizes(File reference) {
|
||||
public static Map<String, Integer> getContigSizes(File reference) {
|
||||
ReferenceDataSource referenceSource = new ReferenceDataSource(reference);
|
||||
List<GenomeLoc> locs = GenomeLocSortedSet.createSetFromSequenceDictionary(referenceSource.getReference().getSequenceDictionary()).toList();
|
||||
Map<String, Long> lengths = new LinkedHashMap<String, Long>();
|
||||
Map<String, Integer> lengths = new LinkedHashMap<String, Integer>();
|
||||
for (GenomeLoc loc: locs)
|
||||
lengths.put(loc.getContig(), loc.size());
|
||||
return lengths;
|
||||
|
|
|
|||
|
|
@ -8,13 +8,12 @@ import org.broadinstitute.sting.BaseTest;
|
|||
import org.broadinstitute.sting.commandline.IntervalBinding;
|
||||
import org.broadinstitute.sting.gatk.GenomeAnalysisEngine;
|
||||
import org.broadinstitute.sting.gatk.datasources.reference.ReferenceDataSource;
|
||||
import org.broadinstitute.sting.utils.GenomeLocSortedSet;
|
||||
import org.testng.Assert;
|
||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||
import org.broadinstitute.sting.utils.GenomeLoc;
|
||||
import org.broadinstitute.sting.utils.GenomeLocParser;
|
||||
import org.broadinstitute.sting.utils.GenomeLocSortedSet;
|
||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||
import org.broadinstitute.sting.utils.fasta.CachingIndexedFastaSequenceFile;
|
||||
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
|
@ -341,7 +340,7 @@ public class IntervalUtilsUnitTest extends BaseTest {
|
|||
|
||||
@Test
|
||||
public void testGetContigLengths() {
|
||||
Map<String, Long> lengths = IntervalUtils.getContigSizes(new File(BaseTest.hg18Reference));
|
||||
Map<String, Integer> lengths = IntervalUtils.getContigSizes(new File(BaseTest.hg18Reference));
|
||||
Assert.assertEquals((long)lengths.get("chr1"), 247249719);
|
||||
Assert.assertEquals((long)lengths.get("chr2"), 242951149);
|
||||
Assert.assertEquals((long)lengths.get("chr3"), 199501827);
|
||||
|
|
|
|||
Loading…
Reference in New Issue