Use byte[] instead of String in an attempt to cut down on memory usage

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@3139 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
ebanks 2010-04-09 05:32:54 +00:00
parent 7025f5b51d
commit e286623f6f
2 changed files with 16 additions and 16 deletions

View File

@ -114,7 +114,7 @@ public class PlinkRod extends BasicReferenceOrderedDatum implements Iterator<Pli
}
public Map<String, List<String>> getGenotypes() {
public Map<String, List<byte[]>> getGenotypes() {
return currentVariant.getGenotypes();
}
@ -169,6 +169,7 @@ public class PlinkRod extends BasicReferenceOrderedDatum implements Iterator<Pli
sampleNames = new ArrayList<String>();
String line;
long counter = 0;
do {
line = reader.readLine();
incorporateInfo(seqVars,snpOffsets,line);
@ -425,7 +426,7 @@ class PlinkVariantInfo implements Comparable {
private String variantName;
private GenomeLoc loc;
private Map<String, List<String>> genotypes = new HashMap<String, List<String>>();
private Map<String, List<byte[]>> genotypes = new HashMap<String, List<byte[]>>();
// for indels
private boolean isIndel = false;
@ -450,7 +451,7 @@ class PlinkVariantInfo implements Comparable {
return variantName;
}
public Map<String, List<String>> getGenotypes() {
public Map<String, List<byte[]>> getGenotypes() {
return genotypes;
}
@ -511,13 +512,13 @@ class PlinkVariantInfo implements Comparable {
public void addGenotypeEntry(String[] alleleStrings, String sampleName) {
ArrayList<String> alleles = new ArrayList<String>(2);
ArrayList<byte[]> alleles = new ArrayList<byte[]>(2);
for ( String alleleString : alleleStrings ) {
if ( alleleString.equals(PlinkRod.SEQUENOM_NO_CALL) )
alleles.add(Allele.NO_CALL_STRING);
alleles.add(Allele.NO_CALL_STRING.getBytes());
else
alleles.add(alleleString);
alleles.add(alleleString.getBytes());
}
genotypes.put(sampleName, alleles);

View File

@ -386,32 +386,31 @@ public class VariantContextAdaptors {
VariantContext convert(String name, Object input, Allele refAllele) {
PlinkRod plink = (PlinkRod)input;
HashMap<String, Allele> alleles = new HashMap<String, Allele>(); // use String keys to help maintain uniqueness
alleles.put(refAllele.isNull() ? Allele.NULL_ALLELE_STRING : new String(refAllele.getBases()), refAllele);
HashSet<Allele> alleles = new HashSet<Allele>();
alleles.add(refAllele);
Set<Genotype> genotypes = new HashSet<Genotype>();
Map<String, List<String>> genotypeSets = plink.getGenotypes();
Map<String, List<byte[]>> genotypeSets = plink.getGenotypes();
// for each sample
for ( Map.Entry<String, List<String>> genotype : genotypeSets.entrySet() ) {
for ( Map.Entry<String, List<byte[]>> genotype : genotypeSets.entrySet() ) {
ArrayList<Allele> myAlleles = new ArrayList<Allele>(2);
// for each allele
for ( String alleleString : genotype.getValue() ) {
for ( byte[] alleleString : genotype.getValue() ) {
Allele allele;
if ( alleleString.equals(Allele.NO_CALL_STRING) ) {
if ( Allele.wouldBeNoCallAllele(alleleString) ) {
allele = Allele.NO_CALL;
} else {
if ( !plink.isIndel() ) {
allele = new Allele(alleleString, refAllele.basesMatch(alleleString));
} else if ( alleleString.equals(Allele.NULL_ALLELE_STRING) ) {
} else if ( Allele.wouldBeNullAllele(alleleString) ) {
allele = new Allele(alleleString, plink.isInsertion());
} else {
allele = new Allele(alleleString, !plink.isInsertion());
}
if ( !alleles.containsKey(alleleString) )
alleles.put(alleleString, allele);
alleles.add(allele);
}
myAlleles.add(allele);
@ -424,7 +423,7 @@ public class VariantContextAdaptors {
// create the variant context
try {
GenomeLoc loc = GenomeLocParser.setStop(plink.getLocation(), plink.getLocation().getStop() + plink.getLength()-1);
VariantContext vc = new VariantContext(plink.getVariantName(), loc, alleles.values(), genotypes);
VariantContext vc = new VariantContext(plink.getVariantName(), loc, alleles, genotypes);
vc.validate();
return vc;
} catch (IllegalArgumentException e) {