Skip to content

Commit

Permalink
Merge pull request #2201 from opencb/TASK-2420
Browse files Browse the repository at this point in the history
TASK-2420 - Sample-variant-stats error 'Unable to index with indexId='ALL' if query is not empty'
  • Loading branch information
j-coll authored Nov 29, 2022
2 parents 03083ec + 9772ee8 commit 5c99104
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,9 @@ public Query parseQuery(Query query, QueryOptions queryOptions, CellBaseUtils ce
panelGenes.addAll(xrefs.getGenes());
query.put(GENE.key(), panelGenes);
query.put(SKIP_MISSING_GENES, true);

// Remove "false" value if exists
query.remove(PANEL_INTERSECTION.key());
} else {
logger.info("Panel intersection");
// Intersect panel with query!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public class VariantAnalysisTest {
public static Object[][] parameters() {
return new Object[][]{
{MongoDBVariantStorageEngine.STORAGE_ENGINE_ID},
// {HadoopVariantStorageEngine.STORAGE_ENGINE_ID}
{HadoopVariantStorageEngine.STORAGE_ENGINE_ID}
};
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.opencb.opencga.core.models.variant;

import com.fasterxml.jackson.annotation.JsonInclude;
import org.opencb.commons.datastore.core.Query;
import org.opencb.opencga.core.tools.ToolParams;

Expand All @@ -12,6 +13,7 @@ public class AnnotationVariantQueryParams extends ToolParams {
private String panelModeOfInheritance;
private String panelConfidence;
private String panelRoleInCancer;
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
private boolean panelIntersection;
private String cohortStatsRef;
private String cohortStatsAlt;
Expand All @@ -28,6 +30,7 @@ public class AnnotationVariantQueryParams extends ToolParams {
private String functionalScore;
private String clinical;
private String clinicalSignificance;
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
private boolean clinicalConfirmedStatus;

public AnnotationVariantQueryParams() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package org.opencb.opencga.core.models.variant;

import com.fasterxml.jackson.annotation.JsonInclude;
import org.opencb.commons.datastore.core.Query;

public class VariantExportParams extends VariantQueryParams {
Expand All @@ -28,6 +29,7 @@ public class VariantExportParams extends VariantQueryParams {
private String exclude;
private Integer limit;
private Integer skip;
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
private boolean summary;

public VariantExportParams() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
package org.opencb.opencga.core.models.variant;

import org.opencb.biodata.models.variant.metadata.Aggregation;
import org.opencb.opencga.core.api.ParamConstants;
import org.opencb.opencga.core.common.YesNoAuto;
import org.opencb.opencga.core.tools.ToolParams;

public class VariantIndexParams extends ToolParams {
Expand Down Expand Up @@ -98,12 +96,12 @@ public VariantIndexParams(String file,
private String loadHomRef;
private String postLoadCheck;
private String includeGenotypes;
private String includeSampleData = ParamConstants.ALL;
private String includeSampleData;
private String merge;
private String deduplicationPolicy;

private boolean calculateStats;
private Aggregation aggregated = Aggregation.NONE;
private Aggregation aggregated;
private String aggregationMappingFile;

private boolean annotate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@

package org.opencb.opencga.core.models.variant;

import com.fasterxml.jackson.annotation.JsonInclude;
import org.opencb.commons.datastore.core.Query;

/**
* Do not use native values (like boolean or int), so they are null by default.
* When using native values (like boolean or int), set add
* {@code @JsonInclude(JsonInclude.Include.NON_DEFAULT)} so they are null by default.
*/
public class VariantQueryParams extends BasicVariantQueryParams {

Expand All @@ -34,7 +36,9 @@ public class VariantQueryParams extends BasicVariantQueryParams {
private String includeSample;
private String includeFile;
private String includeSampleData;
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
private boolean includeSampleId;
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
private boolean includeGenotype;

private String file;
Expand Down Expand Up @@ -79,7 +83,9 @@ public class VariantQueryParams extends BasicVariantQueryParams {
private String customAnnotation;

private String unknownGenotype;
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
private boolean sampleMetadata = false;
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
private boolean sort = false;


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.opencb.opencga.core.models.variant;

import org.junit.Test;

import static org.junit.Assert.*;

public class VariantQueryParamsTest {

@Test
public void test() {
VariantQueryParams params = new VariantQueryParams();
assertEquals(0, params.toObjectMap().size());
assertEquals(0, params.toParams().size());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public final class VariantQueryParam implements QueryParam {

public static final String SAMPLE_METADATA_DESCR
= "Return the samples metadata group by study. Sample names will appear in the same order as their corresponding genotypes.";
public static final VariantQueryParam SAMPLE_METADATA = new VariantQueryParam("sampleMetadata", TEXT_ARRAY, SAMPLE_METADATA_DESCR);
public static final VariantQueryParam SAMPLE_METADATA = new VariantQueryParam("sampleMetadata", BOOLEAN, SAMPLE_METADATA_DESCR);

public static final String INCLUDE_SAMPLE_DATA_DESCR
= "List of Sample Data keys (i.e. FORMAT column from VCF file) from Sample Data to include in the output. e.g: DP,AD. "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
import org.opencb.biodata.models.variant.avro.ClinicalSignificance;
import org.opencb.biodata.models.variant.avro.VariantType;
import org.opencb.biodata.models.variant.metadata.VariantFileHeaderComplexLine;
import org.opencb.opencga.core.models.variant.VariantAnnotationConstants;
import org.opencb.commons.datastore.core.Query;
import org.opencb.commons.datastore.core.QueryOptions;
import org.opencb.commons.datastore.core.QueryParam;
import org.opencb.opencga.core.models.variant.VariantAnnotationConstants;
import org.opencb.opencga.storage.core.metadata.VariantStorageMetadataManager;
import org.opencb.opencga.storage.core.metadata.models.SampleMetadata;
import org.opencb.opencga.storage.core.metadata.models.StudyMetadata;
Expand Down Expand Up @@ -272,6 +272,11 @@ protected void preProcessAnnotationParams(Query query) {
query.put(TYPE.key(), new ArrayList<>(types));
}

if (VariantQueryUtils.isValidParam(query, ANNOT_CLINICAL_CONFIRMED_STATUS)
&& !query.getBoolean(ANNOT_CLINICAL_CONFIRMED_STATUS.key())) {
// Remove false value if exists
query.remove(ANNOT_CLINICAL_CONFIRMED_STATUS.key());
}
if (VariantQueryUtils.isValidParam(query, ANNOT_CLINICAL_SIGNIFICANCE)) {
String v = query.getString(ANNOT_CLINICAL_SIGNIFICANCE.key());
QueryOperation operator = VariantQueryUtils.checkOperator(v);
Expand Down Expand Up @@ -716,6 +721,10 @@ protected void preProcessStudyParams(Query query, QueryOptions options) {
formats = Collections.singletonList(NONE);
}

if (VariantQueryUtils.isValidParam(query, SAMPLE_METADATA) && !query.getBoolean(SAMPLE_METADATA.key())) {
// Remove false value if exists
query.remove(SAMPLE_METADATA.key());
}
query.put(INCLUDE_SAMPLE_DATA.key(), formats);
query.remove(INCLUDE_GENOTYPE.key(), formats);
}
Expand Down

0 comments on commit 5c99104

Please sign in to comment.