Skip to content

Commit

Permalink
Merge pull request #2317 from opencb/TASK-4816
Browse files Browse the repository at this point in the history
TASK-4816 - Error fetching original call for INDELs export step from exomiser from complex contigs
  • Loading branch information
juanfeSanahuja authored Jul 31, 2023
2 parents d69eb73 + 45fd837 commit 41b33a1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.opencb.biodata.models.core.Region;
import org.opencb.biodata.models.variant.StudyEntry;
import org.opencb.biodata.models.variant.Variant;
import org.opencb.biodata.models.variant.VariantBuilder;
import org.opencb.biodata.models.variant.annotation.ConsequenceTypeMappings;
import org.opencb.biodata.models.variant.avro.*;
import org.opencb.commons.datastore.core.*;
Expand Down Expand Up @@ -515,9 +516,18 @@ public static boolean isHpo(String value) {
*/
public static boolean isVariantId(String value) {
int count = StringUtils.countMatches(value, ':');
return count == 3
// It may have more colons if is a symbolic alternate like <DUP:TANDEM>, or a breakend 4:100:C:]15:300]A
|| count > 3 && StringUtils.containsAny(value, '<', '[', ']');
if (count == 3) {
return true;
}
if (count > 3) {
try {
new VariantBuilder(value);
} catch (RuntimeException e) {
return false;
}
return true;
}
return false;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,22 +435,27 @@ public void isVariantId() {
checkIsVariantId("1:1000:A:T");
checkIsVariantId("1:1000-2000:A:T");
checkIsVariantId("1:1000-2000:A:<DUP:TANDEM>");
checkIsVariantId("HLA-DRB1*04:03:01:3349:GAGACAGAG:-", true);
checkIsVariantId("HLA-DRB1*04:03:01:3349:GAGACAGAG:-:2", false);
checkIsVariantId("11:14525312:-:]11:14521700].");
checkIsVariantId("4:100:C:[15:300[A");
checkIsVariantId("4:100:C:]15:300]A");
checkIsVariantId("rs123");
}

public void checkIsVariantId(String v) {

boolean actual = VariantQueryUtils.isVariantId(v);
boolean expected;
try {
new Variant(v);
expected = true;
} catch (Exception e) {
expected = false;
}
checkIsVariantId(v, expected);
}

public void checkIsVariantId(String v, boolean expected) {
boolean actual = VariantQueryUtils.isVariantId(v);
assertEquals(v, expected, actual);
}

Expand Down

0 comments on commit 41b33a1

Please sign in to comment.