Here is the method that i wish to enable recursion
private static Map<Integer, String> GetPalindrome(String DNAString,Map<Integer, String> PalindromesMap) {
int key = 1;
for (int i = 1; i < DNAString.length() - 1; i++) {
for (int start = i - 1, end = i + 1; start >= 0 && end < DNAString.length(); start--, end++) {
if (DNAString.charAt(start) == DNAString.charAt(end)) {
if (end - start + 1 >= 4 && end - start + 1 <= 12) {
if (!PalindromesMap.containsValue(DNAString.substring(start, end + 1))) {
System.out.println("key: "+key+" Index: "+start+" Length: "+DNAString.substring(start, end + 1).length());
PalindromesMap.put(key,DNAString.substring(start, end + 1));
key++;
}
}
} else
break;
}
}
for (int i = 1; i < DNAString.length() - 1; i++) {
for (int start = i, end = i + 1; start >= 0 && end < DNAString.length(); start--, end++) {
if (DNAString.charAt(start) == DNAString.charAt(end)) {
if (end - start + 1 >= 4 && end - start + 1 <= 12) {
if (!PalindromesMap.containsValue(DNAString.substring(start, end + 1))) {
System.out.println("key: "+key+" Index: "+start+" Length: "+DNAString.substring(start, end + 1).length());
PalindromesMap.put(key,DNAString.substring(start, end + 1));
key++;
}
}
} else
break;
}
}
key=key-1;
System.out.println("# of Palindromes: "+key);
return PalindromesMap;
}
This code gets RNA string from a file and searches for palindromes within that file and returns the index and length of the palindrome

New Topic/Question
Reply


MultiQuote







|