Skip to content

Commit

Permalink
Merge pull request #340 from AdamaJava/update_htsjdk
Browse files Browse the repository at this point in the history
Update htsjdk to 4.0.2
  • Loading branch information
holmeso authored Dec 1, 2023
2 parents 56d6487 + af2a56e commit 35a1f9e
Show file tree
Hide file tree
Showing 62 changed files with 1,701 additions and 1,840 deletions.
2 changes: 1 addition & 1 deletion q3panel/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies {
api 'org.apache.commons:commons-lang3:3.4'
api 'net.sf.trove4j:core:3.1.0'
api 'net.sf.jopt-simple:jopt-simple:4.6'
api 'com.github.samtools:htsjdk:2.24.1'
api 'com.github.samtools:htsjdk:4.0.2'

api group: 'com.io7m.xom',name: 'xom', version: '1.2.10'
}
2 changes: 1 addition & 1 deletion q3tiledaligner/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dependencies {
api project(':qcommon')
api project(':qio')

api 'com.github.samtools:htsjdk:2.24.1'
api 'com.github.samtools:htsjdk:4.0.2'
api 'net.sf.trove4j:core:3.1.0'
api 'org.apache.commons:commons-lang3:3.4'
api 'net.sf.jopt-simple:jopt-simple:4.6'
Expand Down
2 changes: 1 addition & 1 deletion q3vcftools/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies {
api project(':qcommon')
api project(':qio')

api 'com.github.samtools:htsjdk:2.24.1'
api 'com.github.samtools:htsjdk:4.0.2'
api 'net.sf.jopt-simple:jopt-simple:4.6'
api 'net.sf.trove4j:core:3.1.0'
api group: 'com.jcraft', name: 'jsch', version: '0.1.54'
Expand Down
2 changes: 1 addition & 1 deletion qannotate/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ dependencies {
api project(':qio')
api project(':qbamfilter')

api 'com.github.samtools:htsjdk:2.24.1'
api 'com.github.samtools:htsjdk:4.0.2'
api 'net.sf.jopt-simple:jopt-simple:4.6'
api name: 'snpEff', version: '4.0e'
api 'com.fasterxml.jackson.core:jackson-databind:2.6.7'
Expand Down
2 changes: 1 addition & 1 deletion qbamfilter/src/org/qcmg/qbamfilter/filter/CigarFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class CigarFilter implements SamRecordFilter{
*
*/
public CigarFilter(String operatorName, Comparator comp, String value )throws Exception{
this.value = Integer.valueOf(value);
this.value = Integer.parseInt(value);
op = comp;
if(operatorName.equalsIgnoreCase("M")){operator = CigarOperator.M;}
else if(operatorName.equalsIgnoreCase("I")){operator = CigarOperator.I;}
Expand Down
177 changes: 107 additions & 70 deletions qbamfilter/src/org/qcmg/qbamfilter/filter/Comparator.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ public enum Comparator {
/**
* @param v1
* @param v2
* it convert string v1 and v2 into integer when Comparator is GreatEqual, SamallEqual,Great and Small
* it converts string v1 and v2 into integer when Comparator is GreatEqual, SmallEqual,Great and Small
* then do integer comparison for v1 and v2. Otherwise it straightly does String comparison ignoring Case
* for Comparator Equal and NotEqual
* @return true if v1 is GreatEqual than v2 for Comparator GreatEqual;
* @return true if v1 is Great than v2 for Comparator Great;
* @return true if v1 is Greater than v2 for Comparator Great;
* @return true if v1 is SmallEqual than v2 for Comparator SmallEqual;
* @return true if v1 is Small than v2 for Comparator Small;
* @return true if v1 and v2 are same string for Comparator Equal
Expand All @@ -44,21 +44,21 @@ public enum Comparator {
*/
public boolean eval(String v1, String v2) {
switch(this){
case GreatEqual: return Integer.valueOf(v1) >= Integer.valueOf(v2);
case SmallEqual: return Integer.valueOf(v1) <= Integer.valueOf(v2);
case Great: return Integer.valueOf(v1) > Integer.valueOf(v2);
case Small: return Integer.valueOf(v1) < Integer.valueOf(v2);
case GreatEqual: return Integer.parseInt(v1) >= Integer.parseInt(v2);
case SmallEqual: return Integer.parseInt(v1) <= Integer.parseInt(v2);
case Great: return Integer.parseInt(v1) > Integer.parseInt(v2);
case Small: return Integer.parseInt(v1) < Integer.parseInt(v2);
case Equal: return v1.equalsIgnoreCase(v2);
case NotEqual: return !(v1.equalsIgnoreCase(v2));
case NotEqual: return ! v1.equalsIgnoreCase(v2);
case StartWith: return v1.toLowerCase().startsWith(v2.toLowerCase());
case NotStartWith: return !v1.toLowerCase().startsWith(v2.toLowerCase());
case NotStartWith: return ! v1.toLowerCase().startsWith(v2.toLowerCase());
case EndWith: return v1.toLowerCase().endsWith(v2.toLowerCase());
case NotEndWith: return ! v1.toLowerCase().endsWith(v2.toLowerCase());
case Contain: return v1.toLowerCase().contains(v2.toLowerCase());
case NotContain: return !v1.toLowerCase().contains(v2.toLowerCase());
case NotContain: return ! v1.toLowerCase().contains(v2.toLowerCase());
}

throw new AssertionError("Unknow comparator mark:" + this);
throw new AssertionError("Unknown comparator mark:" + this);
}


Expand All @@ -74,15 +74,27 @@ public boolean eval(String v1, String v2) {
* @return true if v1 is not equal to v2 for Comparator NotEqual;
*/
public boolean eval(int v1, int v2){
switch(this){
case GreatEqual: return (v1 >= v2);
case SmallEqual: return (v1 <= v2 );
case Great: return (v1 > v2);
case Small: return (v1 < v2);
case Equal: return (v1 == v2);
case NotEqual: return (v1 != v2);
switch (this) {
case GreatEqual -> {
return (v1 >= v2);
}
case SmallEqual -> {
return (v1 <= v2);
}
case Great -> {
return (v1 > v2);
}
case Small -> {
return (v1 < v2);
}
case Equal -> {
return (v1 == v2);
}
case NotEqual -> {
return (v1 != v2);
}
}
throw new AssertionError("Unknow comparator mark:" + this);
throw new AssertionError("Unknown comparator mark:" + this);
}

/**
Expand All @@ -92,15 +104,27 @@ public boolean eval(int v1, int v2){
* see detail return value on documents of eval(int v1, int v2);
*/
public boolean eval(float v1, float v2){
switch(this){
case GreatEqual: return (v1 >= v2);
case SmallEqual: return (v1 <= v2 );
case Great: return (v1 > v2);
case Small: return (v1 < v2);
case Equal: return (v1 == v2);
case NotEqual: return (v1 != v2);
switch (this) {
case GreatEqual -> {
return (v1 >= v2);
}
case SmallEqual -> {
return (v1 <= v2);
}
case Great -> {
return (v1 > v2);
}
case Small -> {
return (v1 < v2);
}
case Equal -> {
return (v1 == v2);
}
case NotEqual -> {
return (v1 != v2);
}
}
throw new AssertionError("Unknow comparator mark:" + this);
throw new AssertionError("Unknown comparator mark:" + this);
}

/**
Expand All @@ -111,30 +135,34 @@ public boolean eval(float v1, float v2){
* Throw Exception for another type of Comparator;
*/
public boolean eval(boolean v1, boolean v2){
switch(this){
case Equal: return (v1 == v2);
case NotEqual: return (v1 != v2 );
switch (this) {
case Equal -> {
return (v1 == v2);
}
case NotEqual -> {
return (v1 != v2);
}
}
throw new AssertionError("Unknow op:" + this);
throw new AssertionError("Unknown op:" + this);
}

/**
*
* @param comp: valid string parameter must belong to [">=", ">", "<=", "<", "==", "!="]
* @return one of the six Comparators based onthe parameter string comp
* @throws Exception if the parameter comp is not valid.
* @return one of the six Comparators based on the parameter string comp
*/
public static final Comparator GetComparator(String comp, String value) {

if(comp.equals(">=")){ return GreatEqual;}
else if( comp.equals("<=")){return SmallEqual; }
else if( comp.equals(">")){return Great; }
else if( comp.equals("<")){return Small; }
else if( comp.equals("==")){return Equal; }
else if( comp.equals("!=")){return NotEqual;}
else if( comp.equals("=~") || comp.equals("!~")){
return GetWildCaseComparator(comp, value);}
else return null;
public static Comparator GetComparator(String comp, String value) {

return switch (comp) {
case ">=" -> GreatEqual;
case "<=" -> SmallEqual;
case ">" -> Great;
case "<" -> Small;
case "==" -> Equal;
case "!=" -> NotEqual;
case "=~", "!~" -> getWildCaseComparator(comp, value);
default -> null;
};

}

Expand All @@ -143,53 +171,62 @@ else if( comp.equals("=~") || comp.equals("!~")){
* @param comp must be '=~' or '!~'
* @param value: String contain single or non '*'
* @return
* @throws Exception unless the single '*' appear at the begin or end of value string
*/
public static Comparator GetWildCaseComparator(String comp, String value) {
String subStr = GetWildCaseValue(value);
public static Comparator getWildCaseComparator(String comp, String value) {
String subStr = getWildCaseValue(value);

if( !comp.equals("=~") && !comp.equals("!~") )
return null;
if ( ! comp.equals("=~") && ! comp.equals("!~")) {
return null;
}

// System.out.println( String.format("GetWildCaseComparator( String %s, String %s )", comp, value) );

//only allow single or none '*'
if( value.contains("*") && subStr.length() != (value.length() - 1) )
return null;
//only allow single or none '*'
if ( value.contains("*") && subStr.length() != (value.length() - 1)) {
return null;
}

if(value.startsWith("*"))
return comp.equals("=~")? EndWith: NotEndWith;
else if(value.endsWith("*")){
if (value.startsWith("*")) {
return comp.equals("=~") ? EndWith : NotEndWith;
} else if (value.endsWith("*")) {
return comp.equals("=~")? StartWith: NotStartWith;
}else if( ! value.contains("*")){
} else if ( ! value.contains("*")) {
return comp.equals("=~")? Contain: NotContain;
}

return null;
}


public static String GetWildCaseValue(String value) {
public static String getWildCaseValue(String value) {
//remove all '*'
return value.replace("*", "");


}
}

/**
* @return comparator string. eg.
* return ">=" for Comparator.GreatEqual.GetString().
* return "==" for Comparator.Equal.GetString().
*/
public String GetString(){
switch(this){
case GreatEqual: return ">=";
case SmallEqual: return "<=";
case Great: return ">";
case Small: return "<";
case Equal: return "==";
case NotEqual: return "!=";
public String getString() {
switch (this) {
case GreatEqual -> {
return ">=";
}
case SmallEqual -> {
return "<=";
}
case Great -> {
return ">";
}
case Small -> {
return "<";
}
case Equal -> {
return "==";
}
case NotEqual -> {
return "!=";
}
}
throw new AssertionError("Unknow comparator mark:" + this);
throw new AssertionError("Unknown comparator mark:" + this);
}
}
Loading

0 comments on commit 35a1f9e

Please sign in to comment.