-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into TASK-5343
- Loading branch information
Showing
165 changed files
with
1,739 additions
and
1,621 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
...-analysis/src/main/java/org/opencb/opencga/analysis/alignment/AlignmentAnalysisUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
opencga-analysis/src/main/java/org/opencb/opencga/analysis/alignment/AlignmentConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
} |
Oops, something went wrong.