Skip to content

Commit

Permalink
test: add Pharmacogenomics Junit tests, #TASK-4769, #TASK-4761
Browse files Browse the repository at this point in the history
  • Loading branch information
jtarraga committed Aug 21, 2023
1 parent 4bca68d commit a8bada3
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class GenericMongoDBAdaptorTest {

protected String cellBaseName;

private static final String DATASET_BASENAME = "cellbase-v5.6-dr4";
private static final String DATASET_BASENAME = "cellbase-v5.7-dr6";
private static final String DATASET_EXTENSION = ".tar.gz";
private static final String DATASET_URL = "http://reports.test.zettagenomics.com/cellbase/test-data/";
private static final String DATASET_TMP_DIR = "/tmp/cb";
Expand Down Expand Up @@ -135,7 +135,9 @@ private void downloadAndPopulate() throws IOException, ExecutionException, Class
Path tmpPath = Paths.get(DATASET_TMP_DIR);
tmpPath.toFile().mkdirs();

logger.info("Downloading " + url + " into " + tmpPath);
URLUtils.download(url, tmpPath);

Path tmpFile = tmpPath.resolve(DATASET_BASENAME + DATASET_EXTENSION);
String commandline = "tar -xvzf " + tmpFile.toAbsolutePath() + " -C " + tmpPath;
logger.info("Running: " + commandline);
Expand Down Expand Up @@ -206,6 +208,12 @@ private void downloadAndPopulate() throws IOException, ExecutionException, Class
// clinical_variants.full.json.gz
loadData("clinical_variants", "clinical_variants", baseDir.resolve("clinical_variants.full.json.gz"));

// pharmacogenomics.json.gz
loadData("pharmacogenomics", "pharmacogenomics", baseDir.resolve("pharmacogenomics/pharmacogenomics.json.gz"));

// pubmed.json.gz
loadData("pubmed", "pubmed", baseDir.resolve("pubmed/pubmed.json.gz"));

// Clean temporary dir
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* Copyright 2015-2020 OpenCB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.opencb.cellbase.lib.impl.core;

import org.hamcrest.CoreMatchers;
import org.junit.jupiter.api.Test;
import org.opencb.biodata.models.core.Gene;
import org.opencb.biodata.models.pharma.PharmaChemical;
import org.opencb.biodata.models.variant.avro.Constraint;
import org.opencb.biodata.models.variant.avro.Expression;
import org.opencb.biodata.models.variant.avro.ExpressionCall;
import org.opencb.cellbase.core.api.GeneQuery;
import org.opencb.cellbase.core.api.PharmaChemicalQuery;
import org.opencb.cellbase.core.api.query.AbstractQuery;
import org.opencb.cellbase.core.api.query.LogicalList;
import org.opencb.cellbase.core.result.CellBaseDataResult;
import org.opencb.cellbase.lib.GenericMongoDBAdaptorTest;
import org.opencb.cellbase.lib.managers.GeneManager;
import org.opencb.cellbase.lib.managers.PharmacogenomicsManager;

import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* Created by jtarraga on 08/21/23.
*/
public class PharmacogenomicsMongoDBAdaptorTest extends GenericMongoDBAdaptorTest {

public PharmacogenomicsMongoDBAdaptorTest() throws IOException {
super();
}

@Test
public void testQueryName() throws Exception {
PharmacogenomicsManager pharmacogenomicsManager = cellBaseManagerFactory.getPharmacogenomicsManager(SPECIES, ASSEMBLY);

Map<String, String> paramMap = new HashMap<>();
paramMap.put("name", "galantamine");
paramMap.put("include", "id,name");
paramMap.put(AbstractQuery.DATA_RELEASE, String.valueOf(dataRelease));

PharmaChemicalQuery chemicalQuery = new PharmaChemicalQuery(paramMap);
chemicalQuery.setCount(Boolean.TRUE);

CellBaseDataResult<PharmaChemical> cellBaseDataResult = pharmacogenomicsManager.search(chemicalQuery);

Check failure on line 64 in cellbase-lib/src/test/java/org/opencb/cellbase/lib/impl/core/PharmacogenomicsMongoDBAdaptorTest.java

View workflow job for this annotation

GitHub Actions / Surefire tests report

PharmacogenomicsMongoDBAdaptorTest.testQueryName

Data not found in release 1. {}
Raw output
org.opencb.cellbase.core.exception.CellBaseException: Data not found in release 1. {}
	at org.opencb.cellbase.lib.impl.core.PharmacogenomicsMongoDBAdaptorTest.testQueryName(PharmacogenomicsMongoDBAdaptorTest.java:64)

assertEquals(1, cellBaseDataResult.getNumMatches());
assertEquals("PA449726", cellBaseDataResult.first().getId());
}

@Test
public void testQuery() throws Exception {
PharmacogenomicsManager pharmacogenomicsManager = cellBaseManagerFactory.getPharmacogenomicsManager(SPECIES, ASSEMBLY);

PharmaChemicalQuery chemicalQuery = new PharmaChemicalQuery();
chemicalQuery.setGeneNames(Collections.singletonList("PRKCE"));
chemicalQuery.setDataRelease(dataRelease);
chemicalQuery.setCount(Boolean.TRUE);

CellBaseDataResult<PharmaChemical> cellBaseDataResult = pharmacogenomicsManager.search(chemicalQuery);

Check failure on line 79 in cellbase-lib/src/test/java/org/opencb/cellbase/lib/impl/core/PharmacogenomicsMongoDBAdaptorTest.java

View workflow job for this annotation

GitHub Actions / Surefire tests report

PharmacogenomicsMongoDBAdaptorTest.testQuery

Data not found in release 1. {}
Raw output
org.opencb.cellbase.core.exception.CellBaseException: Data not found in release 1. {}
	at org.opencb.cellbase.lib.impl.core.PharmacogenomicsMongoDBAdaptorTest.testQuery(PharmacogenomicsMongoDBAdaptorTest.java:79)

assertEquals(6, cellBaseDataResult.getNumMatches());
}
}

0 comments on commit a8bada3

Please sign in to comment.