Added a method to reverse-complement a String object, preserving 'N' and '.' bases.
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@776 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
1a3ca97d29
commit
1a9d5cea29
|
|
@ -112,7 +112,8 @@ public class BaseUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reverse complement a byte array of bases
|
* Reverse complement a byte array of bases (that is, chars casted to bytes, *not* base indices in byte form)
|
||||||
|
*
|
||||||
* @param bases the byte array of bases
|
* @param bases the byte array of bases
|
||||||
* @return the reverse complement of the base byte array
|
* @return the reverse complement of the base byte array
|
||||||
*/
|
*/
|
||||||
|
|
@ -126,6 +127,25 @@ public class BaseUtils {
|
||||||
return rcbases;
|
return rcbases;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse complement a String of bases. Preserves ambiguous bases.
|
||||||
|
*
|
||||||
|
* @param bases the String of bases
|
||||||
|
* @return the reverse complement of the String
|
||||||
|
*/
|
||||||
|
static public String simpleReverseComplement(String bases) {
|
||||||
|
char[] rcbases = new char[bases.length()];
|
||||||
|
|
||||||
|
for (int i = 0; i < bases.length(); i++) {
|
||||||
|
char base = bases.charAt(bases.length() - 1);
|
||||||
|
char rcbase = (base == 'N' || base == '.') ? base : (char) simpleComplement(base);
|
||||||
|
|
||||||
|
rcbases[i] = rcbase;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new String(rcbases);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reverse a byte array of bases
|
* Reverse a byte array of bases
|
||||||
* @param bases the byte array of bases
|
* @param bases the byte array of bases
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue