-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ALS-6330: Fix test compile issues. Add variant list processor integra…
…tion test. Fix bug caused by bitmask paddings
- Loading branch information
Showing
16 changed files
with
149 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 0 additions & 7 deletions
7
integration-test/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/test/Main.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
service/src/main/resources/application-integration-test.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
128 changes: 128 additions & 0 deletions
128
...est/java/edu/harvard/hms/dbmi/avillach/hpds/test/VariantListProcessorIntegrationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
package edu.harvard.hms.dbmi.avillach.hpds.test; | ||
|
||
import edu.harvard.hms.dbmi.avillach.hpds.data.query.Filter; | ||
import edu.harvard.hms.dbmi.avillach.hpds.data.query.Query; | ||
import edu.harvard.hms.dbmi.avillach.hpds.processing.VariantListProcessor; | ||
import edu.harvard.hms.dbmi.avillach.hpds.test.util.BuildIntegrationTestEnvironment; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.test.context.ActiveProfiles; | ||
import org.springframework.test.context.junit.jupiter.SpringExtension; | ||
|
||
import java.io.IOException; | ||
import java.util.*; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
@ExtendWith(SpringExtension.class) | ||
@EnableAutoConfiguration | ||
@SpringBootTest(classes = edu.harvard.hms.dbmi.avillach.hpds.service.HpdsApplication.class) | ||
@ActiveProfiles("integration-test") | ||
public class VariantListProcessorIntegrationTest { | ||
|
||
private static Logger log = LoggerFactory.getLogger(VariantListProcessorIntegrationTest.class); | ||
|
||
@Autowired | ||
private VariantListProcessor variantListProcessor; | ||
|
||
@BeforeAll | ||
public static void beforeAll() { | ||
BuildIntegrationTestEnvironment instance = BuildIntegrationTestEnvironment.INSTANCE; | ||
} | ||
|
||
@Test | ||
public void runVcfExcerptQuery_validGeneWithVariantQuery() throws IOException { | ||
Query query = new Query(); | ||
List<Query.VariantInfoFilter> variantInfoFilters = new ArrayList<>(); | ||
Query.VariantInfoFilter variantInfoFilter = new Query.VariantInfoFilter(); | ||
variantInfoFilter.categoryVariantInfoFilters = Map.of("Gene_with_variant", new String[]{"LOC102723996"}); | ||
variantInfoFilters.add(variantInfoFilter); | ||
query.setVariantInfoFilters(variantInfoFilters); | ||
|
||
String vcfExerpt = variantListProcessor.runVcfExcerptQuery(query, true); | ||
log.debug(vcfExerpt); | ||
String[] vcfExcerptLines = vcfExerpt.split("\\n"); | ||
|
||
int totalExpectedPatients = 16; | ||
int totalExpectedVariants = 4; | ||
|
||
// there should be a line per variant, plus one line for the header | ||
assertEquals(totalExpectedVariants + 1, vcfExcerptLines.length); | ||
List<String> header = Arrays.asList(vcfExcerptLines[0].split("\\t")); | ||
String[] variantLines = Arrays.copyOfRange(vcfExcerptLines, 1, vcfExcerptLines.length); | ||
Arrays.stream(variantLines).forEach(line -> { | ||
String[] columns = line.split("\\t"); | ||
assertEquals("chr21", columns[0]); | ||
int patientCount = 0; | ||
for (String column : columns) { | ||
if ("1/1".equals(column) || "0/1".equals(column)) | ||
patientCount++; | ||
} | ||
assertTrue(patientCount > 0); | ||
assertEquals(patientCount + "/" + totalExpectedPatients, getValueAtColumn(columns, header, "Patients with this variant in subset")); | ||
assertEquals("LOC102723996", getValueAtColumn(columns, header, "Gene_with_variant")); | ||
}); | ||
} | ||
|
||
|
||
@Test | ||
public void runVcfExcerptQuery_validGeneWithVariantAndPhenoQuery() throws IOException { | ||
Query query = new Query(); | ||
List<Query.VariantInfoFilter> variantInfoFilters = new ArrayList<>(); | ||
Query.VariantInfoFilter variantInfoFilter = new Query.VariantInfoFilter(); | ||
variantInfoFilter.categoryVariantInfoFilters = Map.of("Gene_with_variant", new String[]{"LOC102723996"}); | ||
variantInfoFilters.add(variantInfoFilter); | ||
query.setVariantInfoFilters(variantInfoFilters); | ||
query.setNumericFilters(Map.of("\\open_access-1000Genomes\\data\\SYNTHETIC_AGE\\", new Filter.DoubleFilter(35.0, 45.0))); | ||
|
||
String vcfExerpt = variantListProcessor.runVcfExcerptQuery(query, true); | ||
log.debug(vcfExerpt); | ||
String[] vcfExcerptLines = vcfExerpt.split("\\n"); | ||
|
||
int totalExpectedPatients = 4; | ||
int totalExpectedVariants = 2; | ||
|
||
// there should be a line per variant, plus one line for the header | ||
assertEquals(totalExpectedVariants + 1, vcfExcerptLines.length); | ||
List<String> header = Arrays.asList(vcfExcerptLines[0].split("\\t")); | ||
String[] variantLines = Arrays.copyOfRange(vcfExcerptLines, 1, vcfExcerptLines.length); | ||
Arrays.stream(variantLines).forEach(line -> { | ||
String[] columns = line.split("\\t"); | ||
assertEquals("chr21", columns[0]); | ||
int patientCount = 0; | ||
for (String column : columns) { | ||
if ("1/1".equals(column) || "0/1".equals(column)) | ||
patientCount++; | ||
} | ||
assertTrue(patientCount > 0); | ||
assertEquals(patientCount + "/" + totalExpectedPatients, getValueAtColumn(columns, header, "Patients with this variant in subset")); | ||
assertEquals("LOC102723996", getValueAtColumn(columns, header, "Gene_with_variant")); | ||
}); | ||
} | ||
|
||
@Test | ||
public void runVcfExcerptQuery_validQueryNoResults() throws IOException { | ||
Query query = new Query(); | ||
List<Query.VariantInfoFilter> variantInfoFilters = new ArrayList<>(); | ||
Query.VariantInfoFilter variantInfoFilter = new Query.VariantInfoFilter(); | ||
variantInfoFilter.categoryVariantInfoFilters = Map.of("Gene_with_variant", new String[]{"LOC102723996"}); | ||
variantInfoFilters.add(variantInfoFilter); | ||
query.setVariantInfoFilters(variantInfoFilters); | ||
query.setNumericFilters(Map.of("\\open_access-1000Genomes\\data\\SYNTHETIC_AGE\\", new Filter.DoubleFilter(0.0, 1.0))); | ||
|
||
String vcfExerpt = variantListProcessor.runVcfExcerptQuery(query, true); | ||
assertEquals("No Variants Found", vcfExerpt); | ||
|
||
} | ||
|
||
private static String getValueAtColumn(String[] rowColumns, List<String> header, String key) { | ||
return rowColumns[header.indexOf(key)]; | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 1 addition & 2 deletions
3
...test/src/test/resources/test_vcfIndex.tsv → service/src/test/resources/test_vcfIndex.tsv
Large diffs are not rendered by default.
Oops, something went wrong.