MCPcopy Create free account
hub / github.com/BirolLab/RNA-Bloom / trimLowComplexityRegions

Method trimLowComplexityRegions

src/rnabloom/util/SeqUtils.java:773–837  ·  view source on GitHub ↗
(String seq, int windowSize)

Source from the content-addressed store, hash-verified

771 }
772
773 public static ArrayList<String> trimLowComplexityRegions(String seq, int windowSize) {
774 ArrayList<String> segments = new ArrayList<>();
775
776 int seqLen = seq.length();
777
778 if (seqLen >= windowSize) {
779 int numWindows = seqLen/windowSize;
780 boolean[] complexityStatus = new boolean[numWindows];
781
782 int offset = (seqLen % windowSize) / 2;
783 int numLowComplexityWindows = 0;
784
785 for (int i=0; i<numWindows; ++i) {
786 int start = i*windowSize + offset;
787 int end = start + windowSize;
788 String window = seq.substring(start, end);
789 if (isLowComplexityLong(window)) {
790 ++numLowComplexityWindows;
791 complexityStatus[i] = false;
792 }
793 else {
794 complexityStatus[i] = true;
795 }
796 }
797
798 if (numLowComplexityWindows >= 1) {
799 int start = -1;
800 int end = -1;
801 for (int i=0; i<numWindows; ++i) {
802 if (complexityStatus[i]) {
803 if (start < 0) {
804 start = i;
805 }
806 end = i;
807 }
808 else if (start >= 0) {
809 if (start == 0) {
810 segments.add(seq.substring(0, offset + (end+1) * windowSize));
811 }
812 else {
813 segments.add(seq.substring(offset + start * windowSize, offset + (end+1) * windowSize));
814 }
815
816 start = -1;
817 end = -1;
818 }
819 }
820
821 if (start == 0) {
822 segments.add(seq.substring(0, seqLen));
823 }
824 else if (start > 0) {
825 segments.add(seq.substring(offset + start * windowSize, seqLen));
826 }
827 }
828 else {
829 segments.add(seq);
830 }

Callers 1

runMethod · 0.80

Calls 3

isLowComplexityLongMethod · 0.95
addMethod · 0.65

Tested by

no test coverage detected