Skip to content

Commit

Permalink
Merge branch 'develop' into TASK-5343
Browse files Browse the repository at this point in the history
  • Loading branch information
jtarraga committed Mar 27, 2024
2 parents 21be031 + 040d59a commit 828f25a
Show file tree
Hide file tree
Showing 165 changed files with 1,739 additions and 1,621 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/manual-deploy-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ jobs:
outputs:
version: ${{ steps.get_project_version.outputs.version }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: '10'
ref: "${{ inputs.branch }}"
- name: Set up JDK 8
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '8'
Expand All @@ -41,7 +41,7 @@ jobs:
fi
- name: Maven Build (skip tests)
run: mvn -T 2 clean install -DskipTests -P${{ inputs.hadoop }},RClient -Dopencga.war.name=opencga -Dcheckstyle.skip
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: build-folder
path: build
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/manual-deploy-ext-tools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ jobs:
outputs:
version: ${{ steps.get_project_version.outputs.version }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: '10'
ref: "${{ inputs.branch }}"
- name: Set up JDK 8
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '8'
Expand All @@ -41,7 +41,7 @@ jobs:
fi
- name: Maven Build (skip tests)
run: mvn -T 2 clean install -DskipTests
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: build-folder
path: build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
uses: opencb/java-common-libs/.github/workflows/deploy-docker-hub-workflow.yml@develop
needs: build
with:
cli: python3 ./build/cloud/docker/docker-build.py push --images base,init
cli: python3 ./build/cloud/docker/docker-build.py push --images base,init --tag ${{ needs.build.outputs.version }}
secrets: inherit

deploy-python:
Expand Down
8 changes: 7 additions & 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>3.0.0-SNAPSHOT</version>
<version>3.1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down Expand Up @@ -287,6 +287,12 @@
<version>${jetty-for-hadoop-test.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.http2</groupId>
<artifactId>http2-hpack</artifactId>
<version>${jetty-for-hadoop-test.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-io</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
import org.opencb.opencga.core.models.job.Job;
import org.opencb.opencga.core.response.OpenCGAResult;

import java.io.*;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.nio.file.Path;
import java.util.*;

Expand Down Expand Up @@ -46,6 +48,26 @@ public static File getBamFileBySampleId(String sampleId, String studyId, FileMan
return (fileQueryResult.getNumResults() == 0) ? null : fileQueryResult.first();
}

public static File getBwFileBySampleId(String sampleId, String studyId, FileManager fileManager, String token) throws ToolException {
// Look for the bam file for each sample
OpenCGAResult<File> fileQueryResult;

Query query = new Query(FileDBAdaptor.QueryParams.FORMAT.key(), File.Format.BIGWIG)
.append(FileDBAdaptor.QueryParams.SAMPLE_IDS.key(), sampleId);
try {
fileQueryResult = fileManager.search(studyId, query, QueryOptions.empty(), token);
} catch (CatalogException e) {
throw new ToolException(e);
}

// Sanity check
if (fileQueryResult.getNumResults() > 1) {
throw new ToolException("Found more than one BIGWIG files (" + fileQueryResult.getNumResults() + ") for sample " + sampleId);
}

return (fileQueryResult.getNumResults() == 0) ? null : fileQueryResult.first();
}

public static File getBamFile(String filename, String sampleId, String studyId, FileManager fileManager, String token) throws ToolException {
// Look for the bam file for each sample
OpenCGAResult<File> fileQueryResult;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* 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.opencga.analysis.alignment;

import org.opencb.opencga.catalog.exceptions.CatalogException;
import org.opencb.opencga.catalog.managers.CatalogManager;
import org.opencb.opencga.core.exceptions.ToolException;
import org.opencb.opencga.core.models.file.*;
import org.opencb.opencga.core.response.OpenCGAResult;

import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Collections;

public class AlignmentAnalysisUtils {

public static File linkAndUpdate(File bamCatalogFile, Path outPath, String jobId, String study, CatalogManager catalogManager, String token)
throws CatalogException, ToolException {
// Link BW file and update sample info
FileLinkParams fileLinkParams = new FileLinkParams()
.setUri(outPath.toString())
.setPath(Paths.get(jobId).resolve(outPath.getFileName()).toString());
OpenCGAResult<File> fileResult = catalogManager.getFileManager().link(study, fileLinkParams, true, token);
if (fileResult.getNumResults() != 1) {
throw new ToolException("It could not link OpenCGA file catalog file for '" + outPath + "'");
}
File outCatalogFile = fileResult.first();

// Updating file: samples, related file
FileUpdateParams updateParams = new FileUpdateParams()
.setSampleIds(bamCatalogFile.getSampleIds())
.setRelatedFiles(Collections.singletonList(new SmallRelatedFileParams()
.setFile(bamCatalogFile.getId())
.setRelation(FileRelatedFile.Relation.ALIGNMENT)));
try {
OpenCGAResult<File> updateResult = catalogManager.getFileManager().update(study, outCatalogFile.getId(), updateParams, null,
token);
if (updateResult.getNumUpdated() != 1) {
catalogManager.getFileManager().unlink(study, outCatalogFile.getId(), token);
throw new ToolException("It could not update OpenCGA file catalog (" + outCatalogFile.getId()
+ ") from alignment file ID '" + bamCatalogFile.getId() + "'");
}
} catch (CatalogException e) {
catalogManager.getFileManager().unlink(study, outCatalogFile.getId(), token);
throw e;
}
return outCatalogFile;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* 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.opencga.analysis.alignment;

public class AlignmentConstants {

public static final String BAM_EXTENSION = ".bam";
public static final String BAI_EXTENSION = ".bai";
public static final String CRAM_EXTENSION = ".cram";
public static final String CRAI_EXTENSION = ".crai";
public static final String BIGWIG_EXTENSION = ".bw";
}
Loading

0 comments on commit 828f25a

Please sign in to comment.