Skip to content

Commit

Permalink
Resolve conflicts after merging develop, #TASK-2303
Browse files Browse the repository at this point in the history
  • Loading branch information
jtarraga committed Jan 10, 2023
2 parents cd4c96c + bc82ec4 commit 3621810
Show file tree
Hide file tree
Showing 287 changed files with 7,062 additions and 2,252 deletions.
145 changes: 145 additions & 0 deletions misc/sync_dependency.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
#!/bin/bash

function yellow (){
echo "$(tput setaf 3)$1$(tput setaf 7)"
}
function green (){
echo "$(tput setaf 2)$1$(tput setaf 7)"
}
function cyan (){
echo "$(tput setaf 6)$1$(tput setaf 7)"
}

function printUsage(){
echo ""
yellow "Release an OpenCB project."
echo ""
echo "Usage: $(basename $0) --biodata|-b|--java-common-libs|-j"
echo ""
cyan "Options:"
green " -j --java-common-libs STRING Update java-common-libs dependency"
green " -b --biodata STRING Update biodata dependency"
echo ""
}

## Check if the repo status is clean.
function check_repo_clean() {
GIT_STATUS=$(git status --short)
if [ -n "$GIT_STATUS" ]; then
yellow "Repository is not clean:"
yellow "$GIT_STATUS"
exit
fi
}

## This function removes TASK-XXX- if exists, otherwise it adds it.
function toggle_version() {
local BRANCH=$1
if [[ "$POM_DEPENDENCY_VERSION" == *"$BRANCH"* ]]; then
## Remove TASK-XXX- from the current version
## Example: remove 'TASK-1234-' from 2.6.0-TASK-1234-SNAPSHOT
NEW_VERSION=${POM_DEPENDENCY_VERSION/"$BRANCH-"}
else
## Add 'TASK-XXX-' to the current version
## Example: 2.6.0-SNAPSHOT --> 2.6.0-TASK-1234-SNAPSHOT
CLEAN_RELEASE_VERSION=$(echo "$POM_DEPENDENCY_VERSION" | cut -d "-" -f 1)
TAG_VERSION=$(echo "$POM_DEPENDENCY_VERSION" | cut -d "-" -f 2)
NEW_VERSION="$CLEAN_RELEASE_VERSION-$BRANCH-$TAG_VERSION"
fi
}

## Change version in the dependency.
## Usage: update_dependency "$DEPENDENCY_REPO" "$NEW_VERSION" "$BRANCH_NAME"
function update_dependency() {
## Save current directory
local pwd=$PWD
cd "$1" || exit 2
check_repo_clean
git checkout "$3"
## Check branch exists
local BRANCH=$(git branch --show-current)
if [ "$BRANCH" != "$3" ]; then
yellow "Branch '$3' does not exist"
exit
fi
## Rename and commit new version
mvn versions:set -DnewVersion="$2" -DgenerateBackupPoms=false
git commit -am "Update version to $2"
## Restore directory
cd "$pwd" || exit 2
}

## At least one parameter is required.
if [ -z "$1" ]; then
printUsage
exit 1
fi

while [[ $# -gt 0 ]]; do
key="$1"
if [ -n "$2" ]; then
DEPENDENCY_REPO="$2"
fi
case $key in
-h | --help)
printUsage
exit 0
;;
-j | --java-common-libs)
LIB="JAVA_COMMONS_LIB"
if [ -z "$DEPENDENCY_REPO" ]; then
DEPENDENCY_REPO="../java-common-libs"
else
shift
fi
shift # past argument
;;
-b | --biodata)
LIB="BIODATA"
if [ -z "$DEPENDENCY_REPO" ]; then
DEPENDENCY_REPO="../biodata"
else
shift
fi
shift # past argument
;;
*) # unknown option
echo "Unknown option $key"
printUsage
exit 1
;;
esac
done

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
CURRENT_DIR=$PWD
cd "$SCRIPT_DIR" || exit 2
cd ..
BRANCH_NAME=$(git branch --show-current)
if [[ "$BRANCH_NAME" == "TASK-"* ]]; then
check_repo_clean "$BRANCH_NAME"
else
yellow "[$BRANCH_NAME] The branch name must start with TASK-"
yellow "$GIT_STATUS"
exit
fi

function update_library(){
local LIBRARY="$1"
POM_DEPENDENCY_VERSION=$(grep -m 1 "$LIBRARY" pom.xml | cut -d ">" -f 2 | cut -d "<" -f 1)
toggle_version "$BRANCH_NAME"
update_dependency "$DEPENDENCY_REPO" "$NEW_VERSION" "$BRANCH_NAME"
mvn versions:set-property -Dproperty=java-common-libs.version -DnewVersion="$NEW_VERSION" -DgenerateBackupPoms=false
git commit -am "Update '$LIBRARY' dependency to $NEW_VERSION"
}


if [ "$LIB" = "JAVA_COMMONS_LIB" ];then
update_library java-common-libs.version
fi
if [ "$LIB" = "BIODATA" ];then
update_library biodata.version
fi

yellow "The new dependency version is $NEW_VERSION"
cd "$CURRENT_DIR" || exit 2
33 changes: 0 additions & 33 deletions opencga

This file was deleted.

2 changes: 1 addition & 1 deletion opencga-analysis/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>org.opencb.opencga</groupId>
<artifactId>opencga</artifactId>
<version>2.4.11-SNAPSHOT</version>
<version>2.6.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
import org.opencb.opencga.catalog.db.api.FileDBAdaptor;
import org.opencb.opencga.catalog.exceptions.CatalogException;
import org.opencb.opencga.catalog.managers.FileManager;
import org.opencb.opencga.catalog.managers.JobManager;
import org.opencb.opencga.core.exceptions.ToolException;
import org.opencb.opencga.core.models.common.Enums;
import org.opencb.opencga.core.models.file.File;
import org.opencb.opencga.core.models.job.Job;
import org.opencb.opencga.core.response.OpenCGAResult;

import java.io.*;
Expand Down Expand Up @@ -121,4 +124,54 @@ public static Map<String, Map<String, Float>> parseRelatednessThresholds(Path th
}
return thresholds;
}

public static boolean waitFor(String jobId, String study, JobManager jobManager, String token) throws ToolException, CatalogException {
Query query = new Query("id", jobId);
OpenCGAResult<Job> result = jobManager.search(study, query, QueryOptions.empty(), token);
Job job = result.first();
String status = job.getInternal().getStatus().getId();

while (status.equals(Enums.ExecutionStatus.PENDING) || status.equals(Enums.ExecutionStatus.RUNNING)
|| status.equals(Enums.ExecutionStatus.QUEUED) || status.equals(Enums.ExecutionStatus.READY)
|| status.equals(Enums.ExecutionStatus.REGISTERING)) {
try {
// Sleep for 30 seconds
Thread.sleep(30000);
result = jobManager.search(study, query, QueryOptions.empty(), token);
job = result.first();
} catch (CatalogException | InterruptedException e) {
new ToolException("Error waiting for job '" + jobId + "': " + e.getMessage());
}
status = job.getInternal().getStatus().getId();
}
return status.equals(Enums.ExecutionStatus.DONE) ? true : false;
}

public static Job getJob(String jobId, String study, JobManager jobManager, String token) throws ToolException, CatalogException {
Query query = new Query("id", jobId);
OpenCGAResult<Job> result = jobManager.search(study, query, QueryOptions.empty(), token);
Job job = result.first();
if (job == null) {
new ToolException("Error getting job '" + jobId + "' from study '" + study + "'.");
}
return job;
}

public static final String JOBS_IN_JOBDIR = "JOBS";

public static String getJobBaseDir(String path) {
int index = path.indexOf(JOBS_IN_JOBDIR);
if (index == -1) {
return null;
}
return path.substring(0, index + 5);
}

public static String getJobFileRelativePath(String path) {
int index = path.indexOf(JOBS_IN_JOBDIR);
if (index == -1) {
return null;
}
return path.substring(index + 5);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ public OpenCGAResult<GeneCoverageStats> coverageStats(String studyIdStr, String
}
String species = projectQueryResult.first().getOrganism().getScientificName();
String assembly = projectQueryResult.first().getOrganism().getAssembly();
String dataRelease = projectQueryResult.first().getCellbase().getDataRelease();

for (String geneName : geneNames) {

Expand All @@ -248,9 +249,9 @@ public OpenCGAResult<GeneCoverageStats> coverageStats(String studyIdStr, String


// Query CellBase to get gene coordinates and then apply the offset (up and downstream) to create a gene region
CellBaseClient cellBaseClient = new CellBaseClient(storageEngineFactory.getVariantStorageEngine().getConfiguration().getCellbase()
CellBaseClient cellBaseClient = new CellBaseClient(species, assembly, dataRelease, projectQueryResult.first().getCellbase()
.toClientConfiguration());
GeneClient geneClient = new GeneClient(species, assembly, cellBaseClient.getClientConfiguration());
GeneClient geneClient = cellBaseClient.getGeneClient();
Gene gene = geneClient.get(Collections.singletonList(geneName), QueryOptions.empty()).firstResult();
if (gene != null) {
List<TranscriptCoverageStats> transcriptCoverageStatsList = new ArrayList<>();
Expand Down Expand Up @@ -445,9 +446,10 @@ public List<Region> mergeRegions(List<Region> regions, List<String> genes, boole
// Query CellBase to get gene coordinates and then apply the offset (up and downstream) to create a gene region
String species = projectQueryResult.first().getOrganism().getScientificName();
String assembly = projectQueryResult.first().getOrganism().getAssembly();
CellBaseClient cellBaseClient = new CellBaseClient(storageEngineFactory.getVariantStorageEngine().getConfiguration().getCellbase()
String dataRelease = projectQueryResult.first().getCellbase().getDataRelease();
CellBaseClient cellBaseClient = new CellBaseClient(species, assembly, dataRelease, projectQueryResult.first().getCellbase()
.toClientConfiguration());
GeneClient geneClient = new GeneClient(species, assembly, cellBaseClient.getClientConfiguration());
GeneClient geneClient = cellBaseClient.getGeneClient();
List<Gene> response = geneClient.get(genes, QueryOptions.empty()).allResults();
if (CollectionUtils.isNotEmpty(response)) {
for (Gene gene : response) {
Expand Down Expand Up @@ -500,15 +502,13 @@ private void updateRegionMap(Region region, Map<String, Region> map) {
// PRIVATE METHODS
//-------------------------------------------------------------------------

public Map<String, List<Region>> getExonRegionsPerTranscript(String geneName, String species, String assembly)
public Map<String, List<Region>> getExonRegionsPerTranscript(String geneName, CellBaseClient cellBaseClient)
throws StorageEngineException, IOException {
// Init region map, where key = transcript and value = list of exon regions
Map<String, List<Region>> regionMap = new HashMap<>();

// Query CellBase to get gene coordinates and then apply the offset (up and downstream) to create a gene region
CellBaseClient cellBaseClient = new CellBaseClient(storageEngineFactory.getVariantStorageEngine().getConfiguration().getCellbase()
.toClientConfiguration());
GeneClient geneClient = new GeneClient(species, assembly, cellBaseClient.getClientConfiguration());
GeneClient geneClient = cellBaseClient.getGeneClient();
Gene gene = geneClient.get(Collections.singletonList(geneName), QueryOptions.empty()).firstResult();
if (gene != null) {
// Create region from gene coordinates
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.opencb.biodata.tools.clinical.ClinicalVariantCreator;
import org.opencb.biodata.tools.clinical.DefaultClinicalVariantCreator;
import org.opencb.biodata.tools.pedigree.ModeOfInheritance;
import org.opencb.cellbase.client.rest.CellBaseClient;
import org.opencb.commons.datastore.core.DataResult;
import org.opencb.commons.datastore.core.FacetField;
import org.opencb.commons.datastore.core.Query;
Expand Down Expand Up @@ -98,7 +97,6 @@ public class ClinicalInterpretationManager extends StorageManager {
private ClinicalVariantEngine clinicalVariantEngine;
private VariantStorageManager variantStorageManager;

protected CellBaseClient cellBaseClient;
protected AlignmentStorageManager alignmentStorageManager;

private VariantCatalogQueryUtils catalogQueryUtils;
Expand Down Expand Up @@ -138,7 +136,6 @@ public ClinicalInterpretationManager(CatalogManager catalogManager, StorageEngin
this.clinicalAnalysisManager = catalogManager.getClinicalAnalysisManager();
this.variantStorageManager = new VariantStorageManager(catalogManager, StorageEngineFactory.get(storageConfiguration));

this.cellBaseClient = new CellBaseClient(storageConfiguration.getCellbase().toClientConfiguration());
this.alignmentStorageManager = new AlignmentStorageManager(catalogManager, StorageEngineFactory.get(storageConfiguration));

this.catalogQueryUtils = new VariantCatalogQueryUtils(catalogManager);
Expand Down Expand Up @@ -328,7 +325,7 @@ public OpenCGAResult<ClinicalVariant> get(Query query, QueryOptions queryOptions
&& CollectionUtils.isNotEmpty(clinicalVariant.getEvidences())) {
for (ClinicalVariantEvidence primaryFindingEvidence : primaryFinding.getEvidences()) {
for (ClinicalVariantEvidence clinicalVariantEvidence : clinicalVariant.getEvidences()) {
if (matchEvidence(primaryFindingEvidence, clinicalVariantEvidence)) {
if (ClinicalUtils.matchEvidence(primaryFindingEvidence, clinicalVariantEvidence)) {
clinicalVariantEvidence.setReview(primaryFindingEvidence.getReview());
}
}
Expand Down Expand Up @@ -357,27 +354,6 @@ public OpenCGAResult<ClinicalVariant> get(Query query, QueryOptions queryOptions
return result;
}

private boolean matchEvidence(ClinicalVariantEvidence ev1, ClinicalVariantEvidence ev2) {
// Check panel ID
if (ev1.getPanelId() != null && ev2.getPanelId() != null && !ev1.getPanelId().equals(ev2.getPanelId())) {
return false;
}
if (StringUtils.isNotEmpty(ev1.getPanelId()) || StringUtils.isNotEmpty(ev2.getPanelId())) {
return false;
}
if (ev1.getGenomicFeature() != null && ev2.getGenomicFeature() != null) {
if (ev1.getGenomicFeature().getTranscriptId() != null && ev2.getGenomicFeature().getTranscriptId() != null
&& ev1.getGenomicFeature().getTranscriptId().equals(ev2.getGenomicFeature().getTranscriptId())) {
return true;
}
if (ev1.getGenomicFeature().getId() != null && ev2.getGenomicFeature().getId() != null
&& ev1.getGenomicFeature().getId().equals(ev2.getGenomicFeature().getId())) {
return true;
}
}
return false;
}

/*--------------------------------------------------------------------------*/

private ClinicalVariant createClinicalVariant(Variant variant, Map<String, Set<String>> genePanelMap,
Expand Down
Loading

0 comments on commit 3621810

Please sign in to comment.