Skip to content

Commit

Permalink
responded to first round of comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesemery committed Dec 4, 2018
1 parent 5eaf6d9 commit 5dca768
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
14 changes: 7 additions & 7 deletions src/main/java/htsjdk/variant/variantcontext/Genotype.java
Original file line number Diff line number Diff line change
Expand Up @@ -202,28 +202,28 @@ protected GenotypeType determineType() {
}

boolean sawNoCall = false, sawMultipleAlleles = false;
Allele firstAllele = null;
Allele firstCallAllele = null;

for ( int i = 0; i < alleles.size(); i++ ) {
final Allele allele = alleles.get(i);
if ( allele.isNoCall() ) {
sawNoCall = true;
} else if ( firstAllele == null ) {
firstAllele = allele;
} else if ( !allele.equals(firstAllele) )
} else if ( firstCallAllele == null ) {
firstCallAllele = allele;
} else if ( !allele.equals(firstCallAllele) )
sawMultipleAlleles = true;
}

if ( sawNoCall ) {
if ( firstAllele == null )
if ( firstCallAllele == null )
return GenotypeType.NO_CALL;
return GenotypeType.MIXED;
}

if ( firstAllele == null )
if ( firstCallAllele == null )
throw new IllegalStateException("BUG: there are no alleles present in this genotype but the alleles list is not null");

return sawMultipleAlleles ? GenotypeType.HET : firstAllele.isReference() ? GenotypeType.HOM_REF : GenotypeType.HOM_VAR;
return sawMultipleAlleles ? GenotypeType.HET : firstCallAllele.isReference() ? GenotypeType.HOM_REF : GenotypeType.HOM_VAR;
}

/**
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/htsjdk/variant/variantcontext/VariantContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -1354,8 +1354,11 @@ private void validateGenotypes() {
if ( this.genotypes == null ) throw new IllegalStateException("Genotypes is null");

for ( int i = 0; i < genotypes.size(); i++ ) {
if ( genotypes.get(i).isAvailable() ) {
for ( Allele gAllele : genotypes.get(i).getAlleles() ) {
Genotype genotype = genotypes.get(i);
if ( genotype.isAvailable() ) {
final List<Allele> alleles = genotype.getAlleles();
for ( int j = 0; j < alleles.size(); j++ ) {
final Allele gAllele = alleles.get(j);
if ( ! hasAllele(gAllele) && gAllele.isCalled() )
throw new IllegalStateException("Allele in genotype " + gAllele + " not in the variant context " + alleles);
}
Expand Down Expand Up @@ -1688,7 +1691,8 @@ public boolean hasSymbolicAlleles() {
}

public static boolean hasSymbolicAlleles( final List<Allele> alleles ) {
for (int i = 0; i < alleles.size(); i++ ) {
int size = alleles.size();
for (int i = 0; i < size; i++ ) {
if (alleles.get(i).isSymbolic()) {
return true;
}
Expand Down

0 comments on commit 5dca768

Please sign in to comment.