Skip to content

Commit 3621810

Browse files
committed
Resolve conflicts after merging develop, #TASK-2303
2 parents cd4c96c + bc82ec4 commit 3621810

File tree

287 files changed

+7062
-2252
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

287 files changed

+7062
-2252
lines changed

misc/sync_dependency.sh

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
#!/bin/bash
2+
3+
function yellow (){
4+
echo "$(tput setaf 3)$1$(tput setaf 7)"
5+
}
6+
function green (){
7+
echo "$(tput setaf 2)$1$(tput setaf 7)"
8+
}
9+
function cyan (){
10+
echo "$(tput setaf 6)$1$(tput setaf 7)"
11+
}
12+
13+
function printUsage(){
14+
echo ""
15+
yellow "Release an OpenCB project."
16+
echo ""
17+
echo "Usage: $(basename $0) --biodata|-b|--java-common-libs|-j"
18+
echo ""
19+
cyan "Options:"
20+
green " -j --java-common-libs STRING Update java-common-libs dependency"
21+
green " -b --biodata STRING Update biodata dependency"
22+
echo ""
23+
}
24+
25+
## Check if the repo status is clean.
26+
function check_repo_clean() {
27+
GIT_STATUS=$(git status --short)
28+
if [ -n "$GIT_STATUS" ]; then
29+
yellow "Repository is not clean:"
30+
yellow "$GIT_STATUS"
31+
exit
32+
fi
33+
}
34+
35+
## This function removes TASK-XXX- if exists, otherwise it adds it.
36+
function toggle_version() {
37+
local BRANCH=$1
38+
if [[ "$POM_DEPENDENCY_VERSION" == *"$BRANCH"* ]]; then
39+
## Remove TASK-XXX- from the current version
40+
## Example: remove 'TASK-1234-' from 2.6.0-TASK-1234-SNAPSHOT
41+
NEW_VERSION=${POM_DEPENDENCY_VERSION/"$BRANCH-"}
42+
else
43+
## Add 'TASK-XXX-' to the current version
44+
## Example: 2.6.0-SNAPSHOT --> 2.6.0-TASK-1234-SNAPSHOT
45+
CLEAN_RELEASE_VERSION=$(echo "$POM_DEPENDENCY_VERSION" | cut -d "-" -f 1)
46+
TAG_VERSION=$(echo "$POM_DEPENDENCY_VERSION" | cut -d "-" -f 2)
47+
NEW_VERSION="$CLEAN_RELEASE_VERSION-$BRANCH-$TAG_VERSION"
48+
fi
49+
}
50+
51+
## Change version in the dependency.
52+
## Usage: update_dependency "$DEPENDENCY_REPO" "$NEW_VERSION" "$BRANCH_NAME"
53+
function update_dependency() {
54+
## Save current directory
55+
local pwd=$PWD
56+
cd "$1" || exit 2
57+
check_repo_clean
58+
git checkout "$3"
59+
## Check branch exists
60+
local BRANCH=$(git branch --show-current)
61+
if [ "$BRANCH" != "$3" ]; then
62+
yellow "Branch '$3' does not exist"
63+
exit
64+
fi
65+
## Rename and commit new version
66+
mvn versions:set -DnewVersion="$2" -DgenerateBackupPoms=false
67+
git commit -am "Update version to $2"
68+
## Restore directory
69+
cd "$pwd" || exit 2
70+
}
71+
72+
## At least one parameter is required.
73+
if [ -z "$1" ]; then
74+
printUsage
75+
exit 1
76+
fi
77+
78+
while [[ $# -gt 0 ]]; do
79+
key="$1"
80+
if [ -n "$2" ]; then
81+
DEPENDENCY_REPO="$2"
82+
fi
83+
case $key in
84+
-h | --help)
85+
printUsage
86+
exit 0
87+
;;
88+
-j | --java-common-libs)
89+
LIB="JAVA_COMMONS_LIB"
90+
if [ -z "$DEPENDENCY_REPO" ]; then
91+
DEPENDENCY_REPO="../java-common-libs"
92+
else
93+
shift
94+
fi
95+
shift # past argument
96+
;;
97+
-b | --biodata)
98+
LIB="BIODATA"
99+
if [ -z "$DEPENDENCY_REPO" ]; then
100+
DEPENDENCY_REPO="../biodata"
101+
else
102+
shift
103+
fi
104+
shift # past argument
105+
;;
106+
*) # unknown option
107+
echo "Unknown option $key"
108+
printUsage
109+
exit 1
110+
;;
111+
esac
112+
done
113+
114+
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
115+
CURRENT_DIR=$PWD
116+
cd "$SCRIPT_DIR" || exit 2
117+
cd ..
118+
BRANCH_NAME=$(git branch --show-current)
119+
if [[ "$BRANCH_NAME" == "TASK-"* ]]; then
120+
check_repo_clean "$BRANCH_NAME"
121+
else
122+
yellow "[$BRANCH_NAME] The branch name must start with TASK-"
123+
yellow "$GIT_STATUS"
124+
exit
125+
fi
126+
127+
function update_library(){
128+
local LIBRARY="$1"
129+
POM_DEPENDENCY_VERSION=$(grep -m 1 "$LIBRARY" pom.xml | cut -d ">" -f 2 | cut -d "<" -f 1)
130+
toggle_version "$BRANCH_NAME"
131+
update_dependency "$DEPENDENCY_REPO" "$NEW_VERSION" "$BRANCH_NAME"
132+
mvn versions:set-property -Dproperty=java-common-libs.version -DnewVersion="$NEW_VERSION" -DgenerateBackupPoms=false
133+
git commit -am "Update '$LIBRARY' dependency to $NEW_VERSION"
134+
}
135+
136+
137+
if [ "$LIB" = "JAVA_COMMONS_LIB" ];then
138+
update_library java-common-libs.version
139+
fi
140+
if [ "$LIB" = "BIODATA" ];then
141+
update_library biodata.version
142+
fi
143+
144+
yellow "The new dependency version is $NEW_VERSION"
145+
cd "$CURRENT_DIR" || exit 2

opencga

Lines changed: 0 additions & 33 deletions
This file was deleted.

opencga-analysis/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<parent>
2323
<groupId>org.opencb.opencga</groupId>
2424
<artifactId>opencga</artifactId>
25-
<version>2.4.11-SNAPSHOT</version>
25+
<version>2.6.0-SNAPSHOT</version>
2626
<relativePath>../pom.xml</relativePath>
2727
</parent>
2828

opencga-analysis/src/main/java/org/opencb/opencga/analysis/AnalysisUtils.java

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66
import org.opencb.opencga.catalog.db.api.FileDBAdaptor;
77
import org.opencb.opencga.catalog.exceptions.CatalogException;
88
import org.opencb.opencga.catalog.managers.FileManager;
9+
import org.opencb.opencga.catalog.managers.JobManager;
910
import org.opencb.opencga.core.exceptions.ToolException;
11+
import org.opencb.opencga.core.models.common.Enums;
1012
import org.opencb.opencga.core.models.file.File;
13+
import org.opencb.opencga.core.models.job.Job;
1114
import org.opencb.opencga.core.response.OpenCGAResult;
1215

1316
import java.io.*;
@@ -121,4 +124,54 @@ public static Map<String, Map<String, Float>> parseRelatednessThresholds(Path th
121124
}
122125
return thresholds;
123126
}
127+
128+
public static boolean waitFor(String jobId, String study, JobManager jobManager, String token) throws ToolException, CatalogException {
129+
Query query = new Query("id", jobId);
130+
OpenCGAResult<Job> result = jobManager.search(study, query, QueryOptions.empty(), token);
131+
Job job = result.first();
132+
String status = job.getInternal().getStatus().getId();
133+
134+
while (status.equals(Enums.ExecutionStatus.PENDING) || status.equals(Enums.ExecutionStatus.RUNNING)
135+
|| status.equals(Enums.ExecutionStatus.QUEUED) || status.equals(Enums.ExecutionStatus.READY)
136+
|| status.equals(Enums.ExecutionStatus.REGISTERING)) {
137+
try {
138+
// Sleep for 30 seconds
139+
Thread.sleep(30000);
140+
result = jobManager.search(study, query, QueryOptions.empty(), token);
141+
job = result.first();
142+
} catch (CatalogException | InterruptedException e) {
143+
new ToolException("Error waiting for job '" + jobId + "': " + e.getMessage());
144+
}
145+
status = job.getInternal().getStatus().getId();
146+
}
147+
return status.equals(Enums.ExecutionStatus.DONE) ? true : false;
148+
}
149+
150+
public static Job getJob(String jobId, String study, JobManager jobManager, String token) throws ToolException, CatalogException {
151+
Query query = new Query("id", jobId);
152+
OpenCGAResult<Job> result = jobManager.search(study, query, QueryOptions.empty(), token);
153+
Job job = result.first();
154+
if (job == null) {
155+
new ToolException("Error getting job '" + jobId + "' from study '" + study + "'.");
156+
}
157+
return job;
158+
}
159+
160+
public static final String JOBS_IN_JOBDIR = "JOBS";
161+
162+
public static String getJobBaseDir(String path) {
163+
int index = path.indexOf(JOBS_IN_JOBDIR);
164+
if (index == -1) {
165+
return null;
166+
}
167+
return path.substring(0, index + 5);
168+
}
169+
170+
public static String getJobFileRelativePath(String path) {
171+
int index = path.indexOf(JOBS_IN_JOBDIR);
172+
if (index == -1) {
173+
return null;
174+
}
175+
return path.substring(index + 5);
176+
}
124177
}

opencga-analysis/src/main/java/org/opencb/opencga/analysis/alignment/AlignmentStorageManager.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ public OpenCGAResult<GeneCoverageStats> coverageStats(String studyIdStr, String
228228
}
229229
String species = projectQueryResult.first().getOrganism().getScientificName();
230230
String assembly = projectQueryResult.first().getOrganism().getAssembly();
231+
String dataRelease = projectQueryResult.first().getCellbase().getDataRelease();
231232

232233
for (String geneName : geneNames) {
233234

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

249250

250251
// Query CellBase to get gene coordinates and then apply the offset (up and downstream) to create a gene region
251-
CellBaseClient cellBaseClient = new CellBaseClient(storageEngineFactory.getVariantStorageEngine().getConfiguration().getCellbase()
252+
CellBaseClient cellBaseClient = new CellBaseClient(species, assembly, dataRelease, projectQueryResult.first().getCellbase()
252253
.toClientConfiguration());
253-
GeneClient geneClient = new GeneClient(species, assembly, cellBaseClient.getClientConfiguration());
254+
GeneClient geneClient = cellBaseClient.getGeneClient();
254255
Gene gene = geneClient.get(Collections.singletonList(geneName), QueryOptions.empty()).firstResult();
255256
if (gene != null) {
256257
List<TranscriptCoverageStats> transcriptCoverageStatsList = new ArrayList<>();
@@ -445,9 +446,10 @@ public List<Region> mergeRegions(List<Region> regions, List<String> genes, boole
445446
// Query CellBase to get gene coordinates and then apply the offset (up and downstream) to create a gene region
446447
String species = projectQueryResult.first().getOrganism().getScientificName();
447448
String assembly = projectQueryResult.first().getOrganism().getAssembly();
448-
CellBaseClient cellBaseClient = new CellBaseClient(storageEngineFactory.getVariantStorageEngine().getConfiguration().getCellbase()
449+
String dataRelease = projectQueryResult.first().getCellbase().getDataRelease();
450+
CellBaseClient cellBaseClient = new CellBaseClient(species, assembly, dataRelease, projectQueryResult.first().getCellbase()
449451
.toClientConfiguration());
450-
GeneClient geneClient = new GeneClient(species, assembly, cellBaseClient.getClientConfiguration());
452+
GeneClient geneClient = cellBaseClient.getGeneClient();
451453
List<Gene> response = geneClient.get(genes, QueryOptions.empty()).allResults();
452454
if (CollectionUtils.isNotEmpty(response)) {
453455
for (Gene gene : response) {
@@ -500,15 +502,13 @@ private void updateRegionMap(Region region, Map<String, Region> map) {
500502
// PRIVATE METHODS
501503
//-------------------------------------------------------------------------
502504

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

508510
// Query CellBase to get gene coordinates and then apply the offset (up and downstream) to create a gene region
509-
CellBaseClient cellBaseClient = new CellBaseClient(storageEngineFactory.getVariantStorageEngine().getConfiguration().getCellbase()
510-
.toClientConfiguration());
511-
GeneClient geneClient = new GeneClient(species, assembly, cellBaseClient.getClientConfiguration());
511+
GeneClient geneClient = cellBaseClient.getGeneClient();
512512
Gene gene = geneClient.get(Collections.singletonList(geneName), QueryOptions.empty()).firstResult();
513513
if (gene != null) {
514514
// Create region from gene coordinates

opencga-analysis/src/main/java/org/opencb/opencga/analysis/clinical/ClinicalInterpretationManager.java

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import org.opencb.biodata.tools.clinical.ClinicalVariantCreator;
3636
import org.opencb.biodata.tools.clinical.DefaultClinicalVariantCreator;
3737
import org.opencb.biodata.tools.pedigree.ModeOfInheritance;
38-
import org.opencb.cellbase.client.rest.CellBaseClient;
3938
import org.opencb.commons.datastore.core.DataResult;
4039
import org.opencb.commons.datastore.core.FacetField;
4140
import org.opencb.commons.datastore.core.Query;
@@ -98,7 +97,6 @@ public class ClinicalInterpretationManager extends StorageManager {
9897
private ClinicalVariantEngine clinicalVariantEngine;
9998
private VariantStorageManager variantStorageManager;
10099

101-
protected CellBaseClient cellBaseClient;
102100
protected AlignmentStorageManager alignmentStorageManager;
103101

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

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

144141
this.catalogQueryUtils = new VariantCatalogQueryUtils(catalogManager);
@@ -328,7 +325,7 @@ public OpenCGAResult<ClinicalVariant> get(Query query, QueryOptions queryOptions
328325
&& CollectionUtils.isNotEmpty(clinicalVariant.getEvidences())) {
329326
for (ClinicalVariantEvidence primaryFindingEvidence : primaryFinding.getEvidences()) {
330327
for (ClinicalVariantEvidence clinicalVariantEvidence : clinicalVariant.getEvidences()) {
331-
if (matchEvidence(primaryFindingEvidence, clinicalVariantEvidence)) {
328+
if (ClinicalUtils.matchEvidence(primaryFindingEvidence, clinicalVariantEvidence)) {
332329
clinicalVariantEvidence.setReview(primaryFindingEvidence.getReview());
333330
}
334331
}
@@ -357,27 +354,6 @@ public OpenCGAResult<ClinicalVariant> get(Query query, QueryOptions queryOptions
357354
return result;
358355
}
359356

360-
private boolean matchEvidence(ClinicalVariantEvidence ev1, ClinicalVariantEvidence ev2) {
361-
// Check panel ID
362-
if (ev1.getPanelId() != null && ev2.getPanelId() != null && !ev1.getPanelId().equals(ev2.getPanelId())) {
363-
return false;
364-
}
365-
if (StringUtils.isNotEmpty(ev1.getPanelId()) || StringUtils.isNotEmpty(ev2.getPanelId())) {
366-
return false;
367-
}
368-
if (ev1.getGenomicFeature() != null && ev2.getGenomicFeature() != null) {
369-
if (ev1.getGenomicFeature().getTranscriptId() != null && ev2.getGenomicFeature().getTranscriptId() != null
370-
&& ev1.getGenomicFeature().getTranscriptId().equals(ev2.getGenomicFeature().getTranscriptId())) {
371-
return true;
372-
}
373-
if (ev1.getGenomicFeature().getId() != null && ev2.getGenomicFeature().getId() != null
374-
&& ev1.getGenomicFeature().getId().equals(ev2.getGenomicFeature().getId())) {
375-
return true;
376-
}
377-
}
378-
return false;
379-
}
380-
381357
/*--------------------------------------------------------------------------*/
382358

383359
private ClinicalVariant createClinicalVariant(Variant variant, Map<String, Set<String>> genePanelMap,

0 commit comments

Comments
 (0)