Skip to content

Commit

Permalink
ALS-6330: (WIP) Integration test refactor, variant explorer fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
ramari16 committed Jun 5, 2024
1 parent b0407fc commit eab1e2f
Show file tree
Hide file tree
Showing 38 changed files with 122,060 additions and 1,256 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ public BucketIndexBySample(VariantStore variantStore, String storageDir) throws
});

// For each patient set the patientBucketCharMask entry to 0 or 1 if they have a variant in the bucket.

// todo: implement for variant explorer
int indexOfBucket = Collections.binarySearch(bucketList, bucketKey) + 2; //patientBucketCharMasks has bookend bits
for(int x = 0; x < patientIds.size(); x++) {
if(patientMaskForBucket[0].testBit(x)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,6 @@ static VariantMask emptyInstance() {
}

Set<Integer> patientMaskToPatientIdSet(List<String> patientIds);

boolean isEmpty();
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package edu.harvard.hms.dbmi.avillach.hpds.data.genotype;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
Expand Down Expand Up @@ -75,6 +76,13 @@ public Set<Integer> patientMaskToPatientIdSet(List<String> patientIds) {
return ids;
}

@Override
@JsonIgnore
public boolean isEmpty() {
// because the bitmasks are padded with 11 on each end
return bitmask.bitCount() <= 4;
}

private VariantMask union(VariantMaskBitmaskImpl variantMaskBitmask) {
return new VariantMaskBitmaskImpl(variantMaskBitmask.bitmask.or(this.bitmask));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package edu.harvard.hms.dbmi.avillach.hpds.data.genotype;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.math.BigInteger;
Expand Down Expand Up @@ -59,6 +60,12 @@ public Set<Integer> patientMaskToPatientIdSet(List<String> patientIds) {
.collect(Collectors.toSet());
}

@Override
@JsonIgnore
public boolean isEmpty() {
return this.patientIndexes.isEmpty();
}

private VariantMask union(VariantMaskSparseImpl variantMask) {
HashSet<Integer> union = new HashSet<>(variantMask.patientIndexes);
union.addAll(this.patientIndexes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,32 @@ public Optional<VariableVariantMasks> getMasks(String variant, VariantBucketHold
}
return bucketCache.lastValue == null ? Optional.empty() : Optional.ofNullable(bucketCache.lastValue.get(variant));
}
public List<VariableVariantMasks> getMasksForDbSnpSpec(String variant) {
String[] segments = variant.split(",");
if (segments.length < 2) {
log.error("Less than 2 segments found in this variant : " + variant);
}

int chrOffset = Integer.parseInt(segments[1]) / BUCKET_SIZE;
String contig = segments[0];

// if (Level.DEBUG.equals(log.getEffectiveLevel())) {
// log.debug("Getting masks for variant " + variant + " Same bucket test: " + (bucketCache.lastValue != null
// && contig.contentEquals(bucketCache.lastContig) && chrOffset == bucketCache.lastChunkOffset));
// }

// todo: don't bother doing a lookup if this node does not have the chromosome specified
FileBackedJsonIndexStorage<Integer, ConcurrentHashMap<String, VariableVariantMasks>> indexedStorage = variantMaskStorage.get(contig);
if (indexedStorage == null) {
return List.of();
} else {
ConcurrentHashMap<String, VariableVariantMasks> specToMaskMap = indexedStorage.get(chrOffset);
return specToMaskMap.entrySet().stream()
.filter(entry -> entry.getKey().startsWith(variant))
.map(Map.Entry::getValue)
.collect(Collectors.toList());
}
}

public String[] getHeaders() {
return vcfHeaders;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class VariantMetadataLoader {
GZIP_FLAG_COLUMN=3,
FILE_COLUMN = 0;

public static void main(String[] args) throws Exception{
public static void main(String[] args) throws IOException {
File vcfIndexFile;

log.info(new File(".").getAbsolutePath());
Expand Down
2 changes: 0 additions & 2 deletions etl/src/test/resources/bucketIndexBySampleTest_vcfIndex.tsv

This file was deleted.

9 changes: 0 additions & 9 deletions etl/src/test/resources/log4j.properties

This file was deleted.

13 changes: 0 additions & 13 deletions etl/src/test/resources/test.vcf

This file was deleted.

1,001 changes: 0 additions & 1,001 deletions etl/src/test/resources/test_3.vcf

This file was deleted.

13 changes: 0 additions & 13 deletions etl/src/test/resources/test_4.vcf

This file was deleted.

5 changes: 0 additions & 5 deletions etl/src/test/resources/test_vcfIndex.tsv

This file was deleted.

35 changes: 35 additions & 0 deletions integration-test/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>edu.harvard.hms.dbmi.avillach.hpds</groupId>
<artifactId>pic-sure-hpds</artifactId>
<version>3.0.0-SNAPSHOT</version>
</parent>

<artifactId>integration-test</artifactId>

<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>edu.harvard.hms.dbmi.avillach.hpds</groupId>
<artifactId>etl</artifactId>
</dependency>
<dependency>
<groupId>edu.harvard.hms.dbmi.avillach.hpds</groupId>
<artifactId>data</artifactId>
</dependency>
<dependency>
<groupId>edu.harvard.hms.dbmi.avillach.hpds</groupId>
<artifactId>service</artifactId>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package edu.harvard.hms.dbmi.avillach.hpds.test;

public class Main {
public static void main(String[] args) {
System.out.println("Hello world!");
}
}
Loading

0 comments on commit eab1e2f

Please sign in to comment.