Killing off some FindBugs 'Usability' issues

This commit is contained in:
Eric Banks 2012-08-16 13:32:44 -04:00
parent 611d9b61e2
commit dac3958461
12 changed files with 11 additions and 25 deletions

View File

@ -142,8 +142,6 @@ public class GeneralPloidyIndelGenotypeLikelihoods extends GeneralPloidyGenotype
List<Integer> numSeenBases = new ArrayList<Integer>(this.alleles.size());
if (!hasReferenceSampleData) {
final int numHaplotypes = haplotypeMap.size();
final int readCounts[] = new int[pileup.getNumberOfElements()];
readHaplotypeLikelihoods = pairModel.computeGeneralReadHaplotypeLikelihoods(pileup, haplotypeMap, refContext, eventLength, IndelGenotypeLikelihoodsCalculationModel.getIndelLikelihoodMap(), readCounts);
n = readHaplotypeLikelihoods.length;

View File

@ -55,10 +55,8 @@ public class ArgumentDefinitionGroup implements Iterable<ArgumentDefinition> {
* Does the name of this argument group match the name of another?
*/
public boolean groupNameMatches( ArgumentDefinitionGroup other ) {
if( this.groupName == null && other.groupName == null )
return true;
if( this.groupName == null && other.groupName != null )
return false;
if( this.groupName == null )
return other.groupName == null;
return this.groupName.equals(other.groupName);
}

View File

@ -30,7 +30,6 @@ import org.broadinstitute.sting.gatk.CommandLineGATK;
import org.broadinstitute.sting.gatk.arguments.StandardVariantContextInputArgumentCollection;
import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.datasources.rmd.ReferenceOrderedDataSource;
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
import org.broadinstitute.sting.gatk.walkers.RodWalker;
import org.broadinstitute.sting.utils.GenomeLoc;
@ -142,9 +141,6 @@ public class BeagleOutputToVCF extends RodWalker<Integer, Integer> {
hInfo.add(new VCFFilterHeaderLine("BGL_RM_WAS_G", "This 'G' site was set to monomorphic by Beagle"));
hInfo.add(new VCFFilterHeaderLine("BGL_RM_WAS_T", "This 'T' site was set to monomorphic by Beagle"));
// Open output file specified by output VCF ROD
final List<ReferenceOrderedDataSource> dataSources = this.getToolkit().getRodDataSources();
if ( comp.isBound() ) {
hInfo.add(new VCFInfoHeaderLine("ACH", 1, VCFHeaderLineType.Integer, "Allele Count from Comparison ROD at this site"));
hInfo.add(new VCFInfoHeaderLine("ANH", 1, VCFHeaderLineType.Integer, "Allele Frequency from Comparison ROD at this site"));

View File

@ -183,7 +183,7 @@ public class UnifiedGenotyperEngine {
for ( final GenotypeLikelihoodsCalculationModel.Model model : models ) {
final Map<String, AlignmentContext> stratifiedContexts = getFilteredAndStratifiedContexts(UAC, refContext, rawContext, model);
if ( stratifiedContexts == null ) {
results.add(UAC.OutputMode == OUTPUT_MODE.EMIT_ALL_SITES && UAC.GenotypingMode == GenotypeLikelihoodsCalculationModel.GENOTYPING_MODE.GENOTYPE_GIVEN_ALLELES ? generateEmptyContext(tracker, refContext, stratifiedContexts, rawContext) : null);
results.add(UAC.OutputMode == OUTPUT_MODE.EMIT_ALL_SITES && UAC.GenotypingMode == GenotypeLikelihoodsCalculationModel.GENOTYPING_MODE.GENOTYPE_GIVEN_ALLELES ? generateEmptyContext(tracker, refContext, null, rawContext) : null);
}
else {
final VariantContext vc = calculateLikelihoods(tracker, refContext, stratifiedContexts, AlignmentContextUtils.ReadOrientation.COMPLETE, null, true, model);
@ -202,7 +202,7 @@ public class UnifiedGenotyperEngine {
final List<VariantCallContext> withAllSamples = new ArrayList<VariantCallContext>(calls.size());
for ( final VariantCallContext call : calls ) {
if ( call == null )
withAllSamples.add(call);
withAllSamples.add(null);
else {
final VariantContext withoutMissing = VariantContextUtils.addMissingSamples(call, allSamples);
withAllSamples.add(new VariantCallContext(withoutMissing, call.confidentlyCalled, call.shouldEmit));

View File

@ -645,7 +645,7 @@ public class PhaseByTransmission extends RodWalker<HashMap<Byte,Integer>, HashMa
bestChildGenotype.clear();
bestChildGenotype.add(childGenotype.getKey());
}
else if(configurationLikelihood == bestConfigurationLikelihood) {
else if(MathUtils.compareDoubles(configurationLikelihood, bestConfigurationLikelihood) == 0) {
bestFirstParentGenotype.add(firstParentGenotype.getKey());
bestSecondParentGenotype.add(secondParentGenotype.getKey());
bestChildGenotype.add(childGenotype.getKey());

View File

@ -8,8 +8,6 @@ import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
import org.broadinstitute.sting.gatk.walkers.RodWalker;
import org.broadinstitute.sting.utils.R.RScriptExecutorException;
import org.broadinstitute.sting.utils.codecs.vcf.VCFConstants;
import org.broadinstitute.sting.utils.codecs.vcf.VCFHeader;
import org.broadinstitute.sting.utils.codecs.vcf.VCFUtils;
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
@ -18,7 +16,6 @@ import org.broadinstitute.sting.utils.help.DocumentedGATKFeature;
import org.broadinstitute.sting.utils.text.XReadLines;
import org.broadinstitute.sting.utils.variantcontext.Genotype;
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
import org.broadinstitute.sting.utils.variantcontext.VariantContextBuilder;
import org.broadinstitute.sting.utils.variantcontext.VariantContextUtils;
import java.io.*;
@ -95,7 +92,6 @@ public class VariantsToBinaryPed extends RodWalker<Integer,Integer> {
// write to the fam file, the first six columns of the standard ped file
// first, load data from the input meta data file
Map<String,Map<String,String>> metaValues = new HashMap<String,Map<String,String>>();
Set<String> samplesToUse = new HashSet<String>();
logger.debug("Reading in metadata...");
try {
if ( metaDataFile.getAbsolutePath().endsWith(".fam") ) {

View File

@ -199,9 +199,9 @@ public class MannWhitneyU {
else if ( z > n ) { return 0.0; }
else {
if ( z > ((double) n) /2 ) {
return 1.0-1/((double)Arithmetic.factorial(n))*uniformSumHelper(z, (int) Math.floor(z), n, 0);
return 1.0-1/(Arithmetic.factorial(n))*uniformSumHelper(z, (int) Math.floor(z), n, 0);
} else {
return 1/((double)Arithmetic.factorial(n))*uniformSumHelper(z, (int) Math.floor(z), n, 0);
return 1/(Arithmetic.factorial(n))*uniformSumHelper(z, (int) Math.floor(z), n, 0);
}
}
}

View File

@ -767,7 +767,7 @@ public class MathUtils {
for (byte v : vals) {
sum += v;
}
return (byte) Math.floor(sum / vals.length);
return (byte) (sum / vals.length);
}
public static double averageDouble(List<Double> vals) {
@ -1044,7 +1044,6 @@ public class MathUtils {
// the list is assumed *not* to be sorted
final Comparable x = list.get(orderStat);
ListIterator iterator = list.listIterator();
ArrayList lessThanX = new ArrayList();
ArrayList equalToX = new ArrayList();
ArrayList greaterThanX = new ArrayList();

View File

@ -563,7 +563,6 @@ public class Utils {
List<T> t = new ArrayList<T>(c.keySet());
Collections.sort(t);
List<V> l = new ArrayList<V>();
List<String> pairs = new ArrayList<String>();
for ( T k : t ) {
pairs.add(k + "=" + c.get(k));

View File

@ -53,7 +53,7 @@ public class VCFHeaderLine implements Comparable {
*/
public VCFHeaderLine(String key, String value) {
if ( key == null )
throw new IllegalArgumentException("VCFHeaderLine: key cannot be null: key = " + key);
throw new IllegalArgumentException("VCFHeaderLine: key cannot be null");
mKey = key;
mValue = value;
}

View File

@ -587,7 +587,7 @@ public class GenericDocumentationHandler extends DocumentedGATKFeatureHandler {
private List<Map<String, Object>> docForEnumArgument(Class enumClass) {
ClassDoc doc = this.getDoclet().getClassDocForClass(enumClass);
if (doc == null) // || ! doc.isEnum() )
throw new RuntimeException("Tried to get docs for enum " + enumClass + " but got instead: " + doc);
throw new RuntimeException("Tried to get docs for enum " + enumClass + " but got null instead");
List<Map<String, Object>> bindings = new ArrayList<Map<String, Object>>();
for (final FieldDoc field : doc.fields(false)) {

View File

@ -51,7 +51,7 @@ public class CycleCovariate implements StandardCovariate {
private static final int MAXIMUM_CYCLE_VALUE = 1000;
private static final int CUSHION_FOR_INDELS = 4;
private static String default_platform = null;
private String default_platform = null;
private static final EnumSet<NGSPlatform> DISCRETE_CYCLE_PLATFORMS = EnumSet.of(NGSPlatform.ILLUMINA, NGSPlatform.SOLID, NGSPlatform.PACBIO, NGSPlatform.COMPLETE_GENOMICS);
private static final EnumSet<NGSPlatform> FLOW_CYCLE_PLATFORMS = EnumSet.of(NGSPlatform.LS454, NGSPlatform.ION_TORRENT);