-dbSNP rod should not implement VariantBackedByGenotype since dbsnp records have no genotype data
-added code to cache the allele list so it didn't need to get recomputed each time it was requested. git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@2260 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
855face681
commit
1e8dcc30da
|
|
@ -2,12 +2,7 @@ package org.broadinstitute.sting.gatk.refdata;
|
||||||
|
|
||||||
import net.sf.samtools.util.SequenceUtil;
|
import net.sf.samtools.util.SequenceUtil;
|
||||||
import org.broadinstitute.sting.utils.*;
|
import org.broadinstitute.sting.utils.*;
|
||||||
import org.broadinstitute.sting.utils.genotype.BasicGenotype;
|
|
||||||
import org.broadinstitute.sting.utils.genotype.DiploidGenotype;
|
|
||||||
import org.broadinstitute.sting.utils.genotype.Genotype;
|
|
||||||
import org.broadinstitute.sting.utils.genotype.VariantBackedByGenotype;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -22,7 +17,7 @@ import java.util.List;
|
||||||
* Time: 10:47:14 AM
|
* Time: 10:47:14 AM
|
||||||
* To change this template use File | Settings | File Templates.
|
* To change this template use File | Settings | File Templates.
|
||||||
*/
|
*/
|
||||||
public class rodDbSNP extends BasicReferenceOrderedDatum implements VariationRod, VariantBackedByGenotype {
|
public class rodDbSNP extends BasicReferenceOrderedDatum implements VariationRod {
|
||||||
public GenomeLoc loc; // genome location of SNP
|
public GenomeLoc loc; // genome location of SNP
|
||||||
// Reference sequence chromosome or scaffold
|
// Reference sequence chromosome or scaffold
|
||||||
// Start and stop positions in chrom
|
// Start and stop positions in chrom
|
||||||
|
|
@ -50,6 +45,10 @@ public class rodDbSNP extends BasicReferenceOrderedDatum implements VariationRod
|
||||||
|
|
||||||
public int weight; // The quality of the alignment
|
public int weight; // The quality of the alignment
|
||||||
|
|
||||||
|
// cache the allele list so it doesn't need to get recomputed each time
|
||||||
|
private List<String> alleleList = null;
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
@ -73,7 +72,6 @@ public class rodDbSNP extends BasicReferenceOrderedDatum implements VariationRod
|
||||||
*
|
*
|
||||||
* @return the reference base or bases, as a string
|
* @return the reference base or bases, as a string
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public String getReference() {
|
public String getReference() {
|
||||||
return refBases;
|
return refBases;
|
||||||
}
|
}
|
||||||
|
|
@ -83,7 +81,6 @@ public class rodDbSNP extends BasicReferenceOrderedDatum implements VariationRod
|
||||||
*
|
*
|
||||||
* @return the log based error estimate
|
* @return the log based error estimate
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public double getNegLog10PError() {
|
public double getNegLog10PError() {
|
||||||
return 4; // -log10(0.0001)
|
return 4; // -log10(0.0001)
|
||||||
}
|
}
|
||||||
|
|
@ -111,14 +108,17 @@ public class rodDbSNP extends BasicReferenceOrderedDatum implements VariationRod
|
||||||
* @return an alternate allele list
|
* @return an alternate allele list
|
||||||
*/
|
*/
|
||||||
public List<String> getAlleleList() {
|
public List<String> getAlleleList() {
|
||||||
List<String> ret; //ref first!!!!!
|
if ( alleleList == null ) {
|
||||||
if (onFwdStrand())
|
// add ref first
|
||||||
ret = Arrays.asList(observed.split("/"));
|
if ( onFwdStrand() )
|
||||||
|
alleleList = Arrays.asList(observed.split("/"));
|
||||||
else
|
else
|
||||||
ret = Arrays.asList(SequenceUtil.reverseComplement(observed).split("/"));
|
alleleList = Arrays.asList(SequenceUtil.reverseComplement(observed).split("/"));
|
||||||
if (ret.size() > 0 && ret.contains(getReference()) && !ret.get(0).equals(this.getReference()))
|
if ( alleleList.size() > 0 && alleleList.contains(getReference()) && !alleleList.get(0).equals(this.getReference()) )
|
||||||
Collections.swap(ret,ret.indexOf(getReference()),0);
|
Collections.swap(alleleList, alleleList.indexOf(getReference()), 0);
|
||||||
return ret;
|
}
|
||||||
|
|
||||||
|
return alleleList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean onFwdStrand() {
|
public boolean onFwdStrand() {
|
||||||
|
|
@ -130,13 +130,11 @@ public class rodDbSNP extends BasicReferenceOrderedDatum implements VariationRod
|
||||||
*
|
*
|
||||||
* @return VariantFrequency with the stored frequency
|
* @return VariantFrequency with the stored frequency
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public double getNonRefAlleleFrequency() {
|
public double getNonRefAlleleFrequency() {
|
||||||
return 0; // dbSNP doesn't know the allele frequency
|
return 0; // dbSNP doesn't know the allele frequency
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return the VARIANT_TYPE of the current variant */
|
/** @return the VARIANT_TYPE of the current variant */
|
||||||
@Override
|
|
||||||
public VARIANT_TYPE getType() {
|
public VARIANT_TYPE getType() {
|
||||||
return VARIANT_TYPE.SNP;
|
return VARIANT_TYPE.SNP;
|
||||||
}// ----------------------------------------------------------------------
|
}// ----------------------------------------------------------------------
|
||||||
|
|
@ -167,7 +165,6 @@ public class rodDbSNP extends BasicReferenceOrderedDatum implements VariationRod
|
||||||
*
|
*
|
||||||
* @return a char, representing the alternate base
|
* @return a char, representing the alternate base
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public char getAlternativeBaseForSNP() {
|
public char getAlternativeBaseForSNP() {
|
||||||
if (!isSNP()) throw new StingException("We're not a SNP; called in DbSNP rod at position " + this.loc);
|
if (!isSNP()) throw new StingException("We're not a SNP; called in DbSNP rod at position " + this.loc);
|
||||||
if (!isBiallelic()) throw new StingException("We're not biallelic; at position " + this.loc);
|
if (!isBiallelic()) throw new StingException("We're not biallelic; at position " + this.loc);
|
||||||
|
|
@ -182,7 +179,6 @@ public class rodDbSNP extends BasicReferenceOrderedDatum implements VariationRod
|
||||||
*
|
*
|
||||||
* @return a char, representing the alternate base
|
* @return a char, representing the alternate base
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public char getReferenceForSNP() {
|
public char getReferenceForSNP() {
|
||||||
if (!isSNP()) throw new StingException("We're not a SNP; called in DbSNP rod at position " + this.loc);
|
if (!isSNP()) throw new StingException("We're not a SNP; called in DbSNP rod at position " + this.loc);
|
||||||
if (refBases.length() != 1) throw new StingException("The reference base in DbSNP must be zero, at position " + this.loc + " was " + refBases);
|
if (refBases.length() != 1) throw new StingException("The reference base in DbSNP must be zero, at position " + this.loc + " was " + refBases);
|
||||||
|
|
@ -280,47 +276,7 @@ public class rodDbSNP extends BasicReferenceOrderedDatum implements VariationRod
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBiallelic() {
|
public boolean isBiallelic() {
|
||||||
// TODO Auto-generated method stub
|
return getAlleleList().size() == 2;
|
||||||
return observed.indexOf('/') == observed.lastIndexOf('/');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get the genotype
|
|
||||||
*
|
|
||||||
* @return a map in lexigraphical order of the genotypes
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public org.broadinstitute.sting.utils.genotype.Genotype getCalledGenotype() {
|
|
||||||
return new BasicGenotype(getLocation(),
|
|
||||||
BasicGenotype.alleleListToString(getAlleleList()),
|
|
||||||
Utils.stringToChar(getReference()),
|
|
||||||
getNegLog10PError());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get the likelihoods
|
|
||||||
*
|
|
||||||
* @return an array in lexigraphical order of the likelihoods
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<org.broadinstitute.sting.utils.genotype.Genotype> getGenotypes() {
|
|
||||||
ArrayList<Genotype> list = new ArrayList<Genotype>();
|
|
||||||
list.add(getCalledGenotype());
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* do we have the specified genotype? not all backedByGenotypes
|
|
||||||
* have all the genotype data.
|
|
||||||
*
|
|
||||||
* @param x the genotype
|
|
||||||
*
|
|
||||||
* @return true if available, false otherwise
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean hasGenotype(DiploidGenotype x) {
|
|
||||||
return (!x.toString().equals(BasicGenotype.alleleListToString(getAlleleList()))) ? false : true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static rodDbSNP getFirstRealSNP(RODRecordList<ReferenceOrderedDatum> dbsnpList) {
|
public static rodDbSNP getFirstRealSNP(RODRecordList<ReferenceOrderedDatum> dbsnpList) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue