now that the design is stable, pull the setReference and setLocation methods back out of Genotype and stick them into constructors of implementing classes
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@1931 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
3091443dc7
commit
5cdbdd9e5b
|
|
@ -54,12 +54,8 @@ public abstract class EMGenotypeCalculationModel extends GenotypeCalculationMode
|
||||||
for ( String sample : GLs.keySet() ) {
|
for ( String sample : GLs.keySet() ) {
|
||||||
|
|
||||||
// create the call
|
// create the call
|
||||||
Genotype call = GenotypeWriterFactory.createSupportedCall(OUTPUT_FORMAT);
|
|
||||||
call.setReference(ref);
|
|
||||||
|
|
||||||
// get the context
|
|
||||||
AlignmentContext context = contexts.get(sample).getContext(StratifiedContext.OVERALL);
|
AlignmentContext context = contexts.get(sample).getContext(StratifiedContext.OVERALL);
|
||||||
call.setLocation(context.getLocation());
|
Genotype call = GenotypeWriterFactory.createSupportedCall(OUTPUT_FORMAT, ref, context.getLocation());
|
||||||
|
|
||||||
if ( call instanceof ReadBacked ) {
|
if ( call instanceof ReadBacked ) {
|
||||||
((ReadBacked)call).setReads(context.getReads());
|
((ReadBacked)call).setReads(context.getReads());
|
||||||
|
|
|
||||||
|
|
@ -321,11 +321,8 @@ public class JointEstimateGenotypeCalculationModel extends GenotypeCalculationMo
|
||||||
for ( String sample : GLs.keySet() ) {
|
for ( String sample : GLs.keySet() ) {
|
||||||
|
|
||||||
// create the call
|
// create the call
|
||||||
Genotype call = GenotypeWriterFactory.createSupportedCall(OUTPUT_FORMAT);
|
|
||||||
call.setReference(ref);
|
|
||||||
|
|
||||||
AlignmentContext context = contexts.get(sample).getContext(StratifiedContext.OVERALL);
|
AlignmentContext context = contexts.get(sample).getContext(StratifiedContext.OVERALL);
|
||||||
call.setLocation(context.getLocation());
|
Genotype call = GenotypeWriterFactory.createSupportedCall(OUTPUT_FORMAT, ref, context.getLocation());
|
||||||
|
|
||||||
if ( call instanceof ReadBacked ) {
|
if ( call instanceof ReadBacked ) {
|
||||||
((ReadBacked)call).setReads(context.getReads());
|
((ReadBacked)call).setReads(context.getReads());
|
||||||
|
|
|
||||||
|
|
@ -44,9 +44,7 @@ public class PointEstimateGenotypeCalculationModel extends EMGenotypeCalculation
|
||||||
|
|
||||||
// create the genotype call object
|
// create the genotype call object
|
||||||
// create the call
|
// create the call
|
||||||
Genotype call = GenotypeWriterFactory.createSupportedCall(OUTPUT_FORMAT);
|
Genotype call = GenotypeWriterFactory.createSupportedCall(OUTPUT_FORMAT, ref, context.getLocation());
|
||||||
call.setReference(ref);
|
|
||||||
call.setLocation(context.getLocation());
|
|
||||||
|
|
||||||
Pair<ReadBackedPileup, GenotypeLikelihoods> discoveryGL = getSingleSampleLikelihoods(ref, sampleContext, priors, StratifiedContext.OVERALL);
|
Pair<ReadBackedPileup, GenotypeLikelihoods> discoveryGL = getSingleSampleLikelihoods(ref, sampleContext, priors, StratifiedContext.OVERALL);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -113,11 +113,6 @@ public class BasicGenotype implements Genotype {
|
||||||
return mLocation;
|
return mLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the location
|
|
||||||
public void setLocation(GenomeLoc loc) {
|
|
||||||
mLocation = loc;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns true if the genotype is a point genotype, false if it's a indel / deletion
|
* returns true if the genotype is a point genotype, false if it's a indel / deletion
|
||||||
*
|
*
|
||||||
|
|
@ -150,11 +145,6 @@ public class BasicGenotype implements Genotype {
|
||||||
return mRef;
|
return mRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the reference base
|
|
||||||
public void setReference(char refBase) {
|
|
||||||
mRef = Character.toUpperCase(refBase);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return this genotype as a variant
|
* return this genotype as a variant
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -52,12 +52,6 @@ public interface Genotype {
|
||||||
*/
|
*/
|
||||||
public GenomeLoc getLocation();
|
public GenomeLoc getLocation();
|
||||||
|
|
||||||
/**
|
|
||||||
* set the location.
|
|
||||||
* @param loc the location
|
|
||||||
*/
|
|
||||||
public void setLocation(GenomeLoc loc);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns true if the genotype is a point genotype, false if it's a indel / deletion
|
* returns true if the genotype is a point genotype, false if it's a indel / deletion
|
||||||
*
|
*
|
||||||
|
|
@ -80,12 +74,6 @@ public interface Genotype {
|
||||||
*/
|
*/
|
||||||
public char getReference();
|
public char getReference();
|
||||||
|
|
||||||
/**
|
|
||||||
* set the reference base.
|
|
||||||
* @param ref the ref base
|
|
||||||
*/
|
|
||||||
public void setReference(char ref);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return this genotype as a variant
|
* return this genotype as a variant
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package org.broadinstitute.sting.utils.genotype;
|
package org.broadinstitute.sting.utils.genotype;
|
||||||
|
|
||||||
import net.sf.samtools.SAMFileHeader;
|
import net.sf.samtools.SAMFileHeader;
|
||||||
|
import org.broadinstitute.sting.utils.GenomeLoc;
|
||||||
import org.broadinstitute.sting.utils.StingException;
|
import org.broadinstitute.sting.utils.StingException;
|
||||||
import org.broadinstitute.sting.utils.genotype.geli.*;
|
import org.broadinstitute.sting.utils.genotype.geli.*;
|
||||||
import org.broadinstitute.sting.utils.genotype.glf.*;
|
import org.broadinstitute.sting.utils.genotype.glf.*;
|
||||||
|
|
@ -74,15 +75,15 @@ public class GenotypeWriterFactory {
|
||||||
* @param format the format
|
* @param format the format
|
||||||
* @return an unpopulated genotype call object
|
* @return an unpopulated genotype call object
|
||||||
*/
|
*/
|
||||||
public static Genotype createSupportedCall(GENOTYPE_FORMAT format) {
|
public static Genotype createSupportedCall(GENOTYPE_FORMAT format, char ref, GenomeLoc loc) {
|
||||||
switch (format) {
|
switch (format) {
|
||||||
case VCF:
|
case VCF:
|
||||||
return new VCFGenotypeCall();
|
return new VCFGenotypeCall(ref, loc);
|
||||||
case GELI:
|
case GELI:
|
||||||
case GELI_BINARY:
|
case GELI_BINARY:
|
||||||
return new GeliGenotypeCall();
|
return new GeliGenotypeCall(ref, loc);
|
||||||
case GLF:
|
case GLF:
|
||||||
return new GLFGenotypeCall();
|
return new GLFGenotypeCall(ref, loc);
|
||||||
default:
|
default:
|
||||||
throw new StingException("Genotype format " + format.toString() + " is not implemented");
|
throw new StingException("Genotype format " + format.toString() + " is not implemented");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,22 +34,16 @@ public class GeliGenotypeCall implements Genotype, ReadBacked, PosteriorsBacked
|
||||||
* Generate a single sample genotype object
|
* Generate a single sample genotype object
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public GeliGenotypeCall() {
|
public GeliGenotypeCall(char ref, GenomeLoc loc) {
|
||||||
|
mRefBase = ref;
|
||||||
|
mLocation = loc;
|
||||||
|
|
||||||
// fill in empty data
|
// fill in empty data
|
||||||
mRefBase = 'N';
|
|
||||||
mPosteriors = new double[10];
|
mPosteriors = new double[10];
|
||||||
Arrays.fill(mPosteriors, Double.MIN_VALUE);
|
Arrays.fill(mPosteriors, Double.MIN_VALUE);
|
||||||
mReads = new ArrayList<SAMRecord>();
|
mReads = new ArrayList<SAMRecord>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setReference(char refBase) {
|
|
||||||
mRefBase = Character.toUpperCase(refBase);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLocation(GenomeLoc loc) {
|
|
||||||
mLocation = loc;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setReads(List<SAMRecord> reads) {
|
public void setReads(List<SAMRecord> reads) {
|
||||||
mReads = new ArrayList<SAMRecord>(reads);
|
mReads = new ArrayList<SAMRecord>(reads);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,24 +31,18 @@ public class GLFGenotypeCall implements Genotype, ReadBacked, LikelihoodsBacked
|
||||||
* Generate a single sample genotype object, containing everything we need to represent calls out of a genotyper object
|
* Generate a single sample genotype object, containing everything we need to represent calls out of a genotyper object
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public GLFGenotypeCall() {
|
public GLFGenotypeCall(char ref, GenomeLoc loc) {
|
||||||
|
mRefBase = ref;
|
||||||
|
mGenotype = Utils.dupString(ref, 2);
|
||||||
|
|
||||||
// fill in empty data
|
// fill in empty data
|
||||||
mRefBase = 'N';
|
mLocation = loc;
|
||||||
mGenotype = "NN";
|
|
||||||
mLikelihoods = new double[10];
|
mLikelihoods = new double[10];
|
||||||
Arrays.fill(mLikelihoods, Double.MIN_VALUE);
|
Arrays.fill(mLikelihoods, Double.MIN_VALUE);
|
||||||
mReads = new ArrayList<SAMRecord>();
|
mReads = new ArrayList<SAMRecord>();
|
||||||
mNegLog10PError = Double.MIN_VALUE;
|
mNegLog10PError = Double.MIN_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setReference(char refBase) {
|
|
||||||
mRefBase = Character.toUpperCase(refBase);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLocation(GenomeLoc loc) {
|
|
||||||
mLocation = loc;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setReads(List<SAMRecord> reads) {
|
public void setReads(List<SAMRecord> reads) {
|
||||||
mReads = new ArrayList<SAMRecord>(reads);
|
mReads = new ArrayList<SAMRecord>(reads);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,23 +37,17 @@ public class VCFGenotypeCall implements Genotype, ReadBacked, PosteriorsBacked,
|
||||||
* Generate a single sample genotype object
|
* Generate a single sample genotype object
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public VCFGenotypeCall() {
|
public VCFGenotypeCall(char ref, GenomeLoc loc) {
|
||||||
|
mRefBase = ref;
|
||||||
|
mLocation = loc;
|
||||||
|
|
||||||
// fill in empty data
|
// fill in empty data
|
||||||
mRefBase = 'N';
|
|
||||||
mPosteriors = new double[10];
|
mPosteriors = new double[10];
|
||||||
Arrays.fill(mPosteriors, Double.MIN_VALUE);
|
Arrays.fill(mPosteriors, Double.MIN_VALUE);
|
||||||
mSampleName = "";
|
mSampleName = "";
|
||||||
mReads = new ArrayList<SAMRecord>();
|
mReads = new ArrayList<SAMRecord>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setReference(char refBase) {
|
|
||||||
mRefBase = Character.toUpperCase(refBase);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLocation(GenomeLoc loc) {
|
|
||||||
mLocation = loc;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setReads(List<SAMRecord> reads) {
|
public void setReads(List<SAMRecord> reads) {
|
||||||
mReads = new ArrayList<SAMRecord>(reads);
|
mReads = new ArrayList<SAMRecord>(reads);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -145,8 +145,7 @@ class FakeGenotype extends GLFGenotypeCall implements Comparable<FakeGenotype> {
|
||||||
* @param negLog10PError the confidence score
|
* @param negLog10PError the confidence score
|
||||||
*/
|
*/
|
||||||
public FakeGenotype(GenomeLoc location, String genotype, char ref, double negLog10PError, double likelihoods[]) {
|
public FakeGenotype(GenomeLoc location, String genotype, char ref, double negLog10PError, double likelihoods[]) {
|
||||||
setLocation(location);
|
super(ref, location);
|
||||||
setReference(ref);
|
|
||||||
setLikelihoods(likelihoods);
|
setLikelihoods(likelihoods);
|
||||||
setGenotype(genotype);
|
setGenotype(genotype);
|
||||||
setNegLog10PError(negLog10PError);
|
setNegLog10PError(negLog10PError);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue