-
Notifications
You must be signed in to change notification settings - Fork 0
/
__deprecatedVMF.java
83 lines (77 loc) · 2.66 KB
/
__deprecatedVMF.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import java.io.*;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
/**
* This class consists exclusively a single static method that operate on string.
* It contains an algorithm that operates on a string input, to print repeats of
* homologous substrings present inside the input string.
*
* <p>The method of this class throws an <tt>IOException</tt>
* if the file or the file path provided to them are null.
*
*
* @author Rajdeep Ghosh
* @author Ayushman Kumar Banerjee
*/
public class ViralRepeatFinder
{
public static void main(String[] args)throws IOException
{
String filePath="";
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter path of the FASTA containing file.");
filePath = br.readLine();
try {
List<String> allLines = Files.readAllLines(Paths.get(filePath));
allLines.stream().map((line) -> {
System.out.println("Repeats found for: " + line.substring(line.indexOf(" "), line.indexOf("OS")) + "==>");
return line;
}).forEachOrdered((line) -> {
getViralRepeats(line);
});
} catch (IOException e) {
e.printStackTrace();
}
}
private static void getViralRepeats(String str){
int count=0,info=0;
try
{
for(char a='A';a<='Z';a++)
{
if(a=='B'||a=='J'||a=='O'||a=='U'||a=='X'||a=='Z')
continue;
for(int b=0;b<str.length()-2;b++)
{
if(str.charAt(b)==a)
{
for(int c=b;c<str.length();c++)
{
if(str.charAt(c)==a)
count++;
else
break;
}
}
if(count>=3)
{
System.out.print("A protein repeat:");
for(int i=0;i<count;i++)
System.out.print(" "+a);
System.out.println(" was found from position "+(b+1)+" to "+(b+count));
b=b+count;
info++;
}
count=0;
}
}
}
catch(ArrayIndexOutOfBoundsException e)
{
System.out.println("Exception caught!");
}
if(info==0)
System.out.println("No protein repeats found in the given sequence.");
}
}