Skip to content

Commit

Permalink
Merge branch 'TASK-5564' into TASK-5387
Browse files Browse the repository at this point in the history
  • Loading branch information
jtarraga committed Aug 13, 2024
2 parents 562e78d + 938c5c4 commit 2161a9e
Show file tree
Hide file tree
Showing 12 changed files with 274 additions and 13 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/pull-request-approved.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Pull request approve workflow

on:
pull_request_review:
types: [ submitted ]

jobs:
build:
uses: opencb/java-common-libs/.github/workflows/build-java-app-workflow.yml@develop

test:
name: "Test analysis"
uses: ./.github/workflows/test-analysis.yml
needs: build
secrets: inherit
4 changes: 2 additions & 2 deletions .github/workflows/test-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ jobs:
name: Test and push Sonar analysis
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: Set up JDK 11
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
Expand Down
2 changes: 1 addition & 1 deletion biodata-external/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<artifactId>biodata</artifactId>
<groupId>org.opencb.biodata</groupId>
<version>3.2.0-SNAPSHOT</version>
<version>3.3.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion biodata-formats/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>org.opencb.biodata</groupId>
<artifactId>biodata</artifactId>
<version>3.2.0-SNAPSHOT</version>
<version>3.3.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion biodata-models/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>org.opencb.biodata</groupId>
<artifactId>biodata</artifactId>
<version>3.2.0-SNAPSHOT</version>
<version>3.3.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
147 changes: 147 additions & 0 deletions biodata-models/src/main/java/org/opencb/biodata/models/core/Snp.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
/*
* <!--
* ~ Copyright 2015-2017 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.biodata.models.core;

import java.util.List;

public class Snp {
private String id;
private String chromosome;
private int position;
private String reference;
private List<String> alternates;
private String type;
private String source;
private String version;
private SnpAnnotation annotation;

public Snp() {
}

public Snp(String id, String chromosome, int position, String reference, List<String> alternates, String type,
String source, String version, SnpAnnotation annotation) {
this.id = id;
this.chromosome = chromosome;
this.position = position;
this.reference = reference;
this.alternates = alternates;
this.type = type;
this.source = source;
this.version = version;
this.annotation = annotation;
}

@Override
public String toString() {
final StringBuilder sb = new StringBuilder("Snp{");
sb.append("id='").append(id).append('\'');
sb.append(", chromosome='").append(chromosome).append('\'');
sb.append(", position=").append(position);
sb.append(", reference='").append(reference).append('\'');
sb.append(", alternates=").append(alternates);
sb.append(", type='").append(type).append('\'');
sb.append(", source='").append(source).append('\'');
sb.append(", version='").append(version).append('\'');
sb.append(", annotation=").append(annotation);
sb.append('}');
return sb.toString();
}

public String getId() {
return id;
}

public Snp setId(String id) {
this.id = id;
return this;
}

public String getChromosome() {
return chromosome;
}

public Snp setChromosome(String chromosome) {
this.chromosome = chromosome;
return this;
}

public int getPosition() {
return position;
}

public Snp setPosition(int position) {
this.position = position;
return this;
}

public String getReference() {
return reference;
}

public Snp setReference(String reference) {
this.reference = reference;
return this;
}

public List<String> getAlternates() {
return alternates;
}

public Snp setAlternates(List<String> alternates) {
this.alternates = alternates;
return this;
}

public String getType() {
return type;
}

public Snp setType(String type) {
this.type = type;
return this;
}

public String getSource() {
return source;
}

public Snp setSource(String source) {
this.source = source;
return this;
}

public String getVersion() {
return version;
}

public Snp setVersion(String version) {
this.version = version;
return this;
}

public SnpAnnotation getAnnotation() {
return annotation;
}

public Snp setAnnotation(SnpAnnotation annotation) {
this.annotation = annotation;
return this;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* <!--
* ~ Copyright 2015-2017 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.biodata.models.core;

import org.opencb.biodata.models.variant.avro.PopulationFrequency;

import java.util.List;
import java.util.Map;

public class SnpAnnotation {

private List<String> flags;
private String gene;
private List<PopulationFrequency> populationFrequencies;
private Map<String, Object> additionalAttributes;

public SnpAnnotation() {
}

public SnpAnnotation(List<String> flags, String gene, List<PopulationFrequency> populationFrequencies, Map<String, Object> additionalAttributes) {
this.flags = flags;
this.gene = gene;
this.populationFrequencies = populationFrequencies;
this.additionalAttributes = additionalAttributes;
}

public List<String> getFlags() {
return flags;
}

public SnpAnnotation setFlags(List<String> flags) {
this.flags = flags;
return this;
}

public String getGene() {
return gene;
}

public SnpAnnotation setGene(String gene) {
this.gene = gene;
return this;
}

public List<PopulationFrequency> getPopulationFrequencies() {
return populationFrequencies;
}

public SnpAnnotation setPopulationFrequencies(List<PopulationFrequency> populationFrequencies) {
this.populationFrequencies = populationFrequencies;
return this;
}

public Map<String, Object> getAdditionalAttributes() {
return additionalAttributes;
}

public SnpAnnotation setAdditionalAttributes(Map<String, Object> additionalAttributes) {
this.additionalAttributes = additionalAttributes;
return this;
}
}
8 changes: 7 additions & 1 deletion biodata-tools/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>org.opencb.biodata</groupId>
<artifactId>biodata</artifactId>
<version>3.2.0-SNAPSHOT</version>
<version>3.3.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down Expand Up @@ -53,6 +53,12 @@
<dependency>
<groupId>com.databricks</groupId>
<artifactId>SnpEff</artifactId>
<exclusions>
<exclusion>
<groupId>distlib</groupId>
<artifactId>distlib</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.rocksdb</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
Expand All @@ -62,7 +63,7 @@ public class BamManager implements AutoCloseable {

public static final int DEFAULT_WINDOW_SIZE = 1;
public static final int MAX_NUM_RECORDS = 50000;
public static final int MAX_REGION_COVERAGE = 100000;
public static final int MAX_REGION_COVERAGE = 500000;
public static final String COVERAGE_BIGWIG_EXTENSION = ".bw";

private Logger logger;
Expand Down Expand Up @@ -191,7 +192,10 @@ public Path calculateBigWigCoverage(Path bigWigPath, int windowSize) throws IOEx
return bigWigPath;
}


/**
* @deprecated (since getFileHeader().getTextHeader() is deprecated !)
*/
@Deprecated
public String header() {
return samReader.getFileHeader().getTextHeader();
}
Expand Down Expand Up @@ -338,7 +342,7 @@ public List<Chunk> getChunks(Region region) {
BAMIndex index = samReader.indexing().getIndex();
return index.getSpanOverlapping(sequenceIndex, start, end).getChunks();
}
return null;
return Collections.emptyList();
}

public List<String> getBreakpoints(Region region) throws IOException {
Expand Down Expand Up @@ -378,7 +382,7 @@ public List<String> getBreakpoints(Region region) throws IOException {
}
}
}
return null;
return Collections.emptyList();
}

/**
Expand Down Expand Up @@ -445,7 +449,7 @@ public AlignmentGlobalStats stats(Region region, AlignmentFilters<SAMRecord> fil
return calculateGlobalStats(iterator(region, filters, options));
}

private AlignmentGlobalStats calculateGlobalStats(BamIterator<SAMRecord> iterator) throws IOException {
private AlignmentGlobalStats calculateGlobalStats(BamIterator<SAMRecord> iterator) {
AlignmentGlobalStats alignmentGlobalStats = new AlignmentGlobalStats();
SamRecordAlignmentGlobalStatsCalculator calculator = new SamRecordAlignmentGlobalStatsCalculator();
while (iterator.hasNext()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1394,6 +1394,8 @@ private Variant newVariant(Variant variant, VariantKeyFields keyFields, Structur
normalizedVariant.getSv().setCiStartRight(sv.getCiStartRight());
normalizedVariant.getSv().setCiEndLeft(sv.getCiEndLeft());
normalizedVariant.getSv().setCiEndRight(sv.getCiEndRight());
normalizedVariant.getSv().setLeftSvInsSeq(sv.getLeftSvInsSeq());
normalizedVariant.getSv().setRightSvInsSeq(sv.getRightSvInsSeq());

// Variant will never have CopyNumber, because the Alternate is normalized from <CNxx> to <CNV>
normalizedVariant.getSv().setCopyNumber(keyFields.getCopyNumber());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,14 @@ public void testNormalizeSvToIndel() throws NonStandardCompliantSampleField {

}

@Test
public void testNormalizeWithInsSeq() throws NonStandardCompliantSampleField {
Variant variant = new Variant("1:799984<800001<800022:-:ACCACACCCACACAACACACA...TGTGGTGTGTGTGGTGTG");
Variant normVar = new VariantNormalizer().normalize(Collections.singletonList(variant), false).get(0);
assertEquals(variant, normVar);
assertEquals(variant.toString(), normVar.toString());
}

@Test
public void testNormalizeBND() throws NonStandardCompliantSampleField {
normalizeBnd(newVariant(101, 100, "", ".[9:10["), newVariant(100, 99, "A", "A[chr9:10["));
Expand Down
Loading

0 comments on commit 2161a9e

Please sign in to comment.