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

Method cutHairPinLoop

src/rnabloom/util/SeqUtils.java:1154–1238  ·  view source on GitHub ↗
(final String seq, final int seedSize, final float minPercentIdentity)

Source from the content-addressed store, hash-verified

1152 }
1153
1154 public static final String cutHairPinLoop(final String seq, final int seedSize, final float minPercentIdentity) {
1155 int seqLen = seq.length();
1156 int halfLen = seqLen/2;
1157
1158 final int maxSeedSearchDepth = Math.min(halfLen, 200);
1159 final int maxLoopLength = Math.max(200, halfLen);
1160 final int maxLoopDiameter = maxLoopLength/2;
1161
1162 int lastSeedIndex = maxSeedSearchDepth - seedSize;
1163
1164 for (int i=0; i<lastSeedIndex; i+=seedSize) {
1165 String seed = seq.substring(i, i+seedSize);
1166 int seedRevCompIndex = seq.indexOf(reverseComplement(seed), i+seedSize);
1167
1168 if (seedRevCompIndex >= 0) {
1169 int endIndex = seedRevCompIndex + seedSize;
1170 int halfIndex = (i + endIndex)/2;
1171
1172 if (i+seedSize >= seedRevCompIndex-maxLoopLength) {
1173 if (halfIndex < halfLen) {
1174 return seq.substring(halfIndex);
1175 }
1176 else {
1177 return seq.substring(0, halfIndex);
1178 }
1179 }
1180 else {
1181 String left = seq.substring(i, halfIndex-maxLoopDiameter);
1182 String right = seq.substring(halfIndex+maxLoopDiameter, endIndex);
1183
1184 float pid = getPercentIdentity(left, reverseComplement(right));
1185
1186 if (pid >= minPercentIdentity) {
1187 if (halfIndex < halfLen) {
1188 return seq.substring(halfIndex);
1189 }
1190 else {
1191 return seq.substring(0, halfIndex);
1192 }
1193 }
1194 }
1195
1196 break;
1197 }
1198 }
1199
1200 lastSeedIndex = seqLen-maxSeedSearchDepth;
1201
1202 for (int i=seqLen-seedSize; i>=lastSeedIndex; i-=seedSize) {
1203 String seed = seq.substring(i, i+seedSize);
1204 int seedRevCompIndex = seq.lastIndexOf(reverseComplement(seed));
1205
1206 if (seedRevCompIndex >= 0 && seedRevCompIndex < i-seedSize) {
1207 int halfIndex = (seedRevCompIndex + i + seedSize)/2;
1208
1209 if (seedRevCompIndex+seedSize >= i-maxLoopLength) {
1210 if (halfIndex < halfLen) {
1211 return seq.substring(halfIndex);

Callers

nothing calls this directly

Calls 2

reverseComplementMethod · 0.95
getPercentIdentityMethod · 0.95

Tested by

no test coverage detected