Skip to content

Commit 5d77219

Browse files
Merge branch 'release-3.x.x' into TASK-7751
2 parents d583e78 + e8f4cdf commit 5d77219

13 files changed

Lines changed: 970 additions & 28 deletions

File tree

.github/workflows/pull-request-approved.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77

88
jobs:
99
calculate-xetabase-branch:
10+
if: github.event.review.state == 'approved'
1011
name: Calculate Xetabase branch
1112
runs-on: ubuntu-22.04
1213
outputs:
@@ -24,13 +25,14 @@ jobs:
2425
chmod +x ./.github/workflows/scripts/get-xetabase-branch.sh
2526
echo "github.event.pull_request.base.ref: ${{ github.event.pull_request.base.ref }}"
2627
echo "github.event.pull_request.head.ref: ${{ github.event.pull_request.head.ref }}"
27-
xetabase_branch=$(./.github/workflows/scripts/get-xetabase-branch.sh ${{ github.event.pull_request.head.ref }})
28+
xetabase_branch=$(./.github/workflows/scripts/get-xetabase-branch.sh ${{ github.event.pull_request.base.ref }})
2829
echo "__Xetabase ref:__ \"${xetabase_branch}\"" | tee -a ${GITHUB_STEP_SUMMARY}
2930
echo "xetabase_branch=${xetabase_branch}" >> $GITHUB_OUTPUT
3031
env:
3132
ZETTA_REPO_ACCESS_TOKEN: ${{ secrets.ZETTA_REPO_ACCESS_TOKEN }}
3233

3334
test:
35+
if: github.event.review.state == 'approved'
3436
name: "Run all tests before merging"
3537
needs: calculate-xetabase-branch
3638
uses: opencb/java-common-libs/.github/workflows/test-xetabase-workflow.yml@develop

.github/workflows/scripts/get-xetabase-branch.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ get_xetabase_branch() {
1919
return 0
2020
fi
2121

22-
# Check if the branch name starts with "release-" and follows the patterns "release-a.b.x" or "release-a.b.c.x"
23-
if [[ "$input_branch" =~ ^release-([0-9]+)\.([0-9]+)\.x$ ]] || [[ "$input_branch" =~ ^release-([0-9]+)\.([0-9]+)\.([0-9]+)\.x$ ]]; then
22+
# Check if the branch name starts with "release-" and follows the patterns "release-a.x.x" or "release-a.b.x"
23+
if [[ "$input_branch" =~ ^release-([0-9]+)\.x\.x$ ]] || [[ "$input_branch" =~ ^release-([0-9]+)\.([0-9]+)\.x$ ]]; then
2424
# Extract the MAJOR part of the branch name
2525
MAJOR=${BASH_REMATCH[1]}
26-
# Calculate the XETABASE_MAJOR by subtracting 3 from MAJOR
26+
# Calculate the XETABASE_MAJOR by subtracting 1 from MAJOR
2727
XETABASE_MAJOR=$((MAJOR - 1))
2828
# Check if the XETABASE_MAJOR is negative
2929
if (( XETABASE_MAJOR < 0 )); then
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/*
2+
* Copyright 2015-2020 OpenCB
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.opencb.biodata.formats.variant;
18+
19+
import org.opencb.biodata.models.variant.avro.AlleleOrigin;
20+
21+
import java.util.HashMap;
22+
import java.util.Map;
23+
24+
/**
25+
* Created by fjlopez on 22/06/15.
26+
*/
27+
public class VariantAnnotationUtils {
28+
29+
private static final Map<String, AlleleOrigin> ORIGIN_STRING_TO_ALLELE_ORIGIN = new HashMap<>();
30+
private static final Map<Character, Character> COMPLEMENTARY_NT = new HashMap<>();
31+
32+
static {
33+
34+
///////////////////////////////////////////////////////////////////////
35+
///// ClinVar and Cosmic allele origins to SO terms ///////////////
36+
///////////////////////////////////////////////////////////////////////
37+
ORIGIN_STRING_TO_ALLELE_ORIGIN.put("germline", AlleleOrigin.germline_variant);
38+
ORIGIN_STRING_TO_ALLELE_ORIGIN.put("maternal", AlleleOrigin.maternal_variant);
39+
ORIGIN_STRING_TO_ALLELE_ORIGIN.put("de novo", AlleleOrigin.de_novo_variant);
40+
ORIGIN_STRING_TO_ALLELE_ORIGIN.put("paternal", AlleleOrigin.paternal_variant);
41+
ORIGIN_STRING_TO_ALLELE_ORIGIN.put("somatic", AlleleOrigin.somatic_variant);
42+
43+
COMPLEMENTARY_NT.put('A', 'T');
44+
COMPLEMENTARY_NT.put('a', 't');
45+
COMPLEMENTARY_NT.put('C', 'G');
46+
COMPLEMENTARY_NT.put('c', 'g');
47+
COMPLEMENTARY_NT.put('G', 'C');
48+
COMPLEMENTARY_NT.put('g', 'c');
49+
COMPLEMENTARY_NT.put('T', 'A');
50+
COMPLEMENTARY_NT.put('t', 'a');
51+
COMPLEMENTARY_NT.put('N', 'N');
52+
COMPLEMENTARY_NT.put('n', 'n');
53+
}
54+
55+
public static String reverseComplement(String string) {
56+
return reverseComplement(string, false);
57+
}
58+
59+
public static String reverseComplement(String string, boolean failOnUnknownNt) {
60+
StringBuilder stringBuilder = new StringBuilder(string).reverse();
61+
for (int i = 0; i < stringBuilder.length(); i++) {
62+
char nextNt = stringBuilder.charAt(i);
63+
// Protection against weird characters, e.g. alternate:"TBS" found in ClinVar
64+
if (VariantAnnotationUtils.COMPLEMENTARY_NT.containsKey(nextNt)) {
65+
stringBuilder.setCharAt(i, VariantAnnotationUtils.COMPLEMENTARY_NT.get(nextNt));
66+
} else {
67+
if (failOnUnknownNt) {
68+
throw new IllegalArgumentException("Unknown nucleotide: '" + nextNt+ "'. "
69+
+ "Unable to reverse-complement sequence '" + string + "'.");
70+
} else {
71+
return null;
72+
}
73+
}
74+
}
75+
return stringBuilder.toString();
76+
}
77+
78+
public static AlleleOrigin parseAlleleOrigin(String alleleOrigin) {
79+
return ORIGIN_STRING_TO_ALLELE_ORIGIN.get(alleleOrigin);
80+
}
81+
82+
}

0 commit comments

Comments
 (0)