Hi I really need some help with my second problem . I have a large fasta file that contains over 300 sequences. I need to search each sequence in the fasta file that contains the following zinc fingers consensus sequence of C-x2-C-x15-C-x2-C or in other words... C-(then 2 letters of any type)-C-( then 15 letters of any type)-C-(2 letters of any type)-C
In the output file i need to print out the title line, the zinc finger and followed by the sequence itself.
Here is what I have so far
import java.io.*;
import java.util.*;
public class test {
public static void main(String[] args) throws IOException {
String fileName = "";
Scanner input = new ScannerSystem.in);
System.out.print ("Enter the name of the sequence file: ");
fileName = input.nextLine();
int count = 0;
BufferedReader bf = null;
try {
bf = new BufferedReader(new FileReader(fileName));
String line;
while ((line = bf.readLine()) != null){
// if is the title line, count as a record
if (line.matches("^>.*"))count++;
}
} catch (FileNotFoundException e) {
System.out.println("File: " + fileName + " does not exist!");
} finally {
if (bf != null) {
bf.close();
}
After this i get completely confused I know to print out sequences within the file but i have no idea how to print out the type of sequences above. Any help is greatly appreciated
You're a generous person! Maybe I'm too pessimistic, but this question really sounds like a homework problem, and the "what I have so far" really seems like skeleton code from a problem statement.
I would've just given vague pointers to consider using regular expressions, since even that tidbit wasn't present in the question.
But maybe I'm wrong...
You're right. But he provided a source code as if he really tried to solve the problem and ... I was looking for something funny to do before switching off my laptop :-)
Aghhh I see so you use the compile method!. Thank you so much for your help. I will try this out..test it and see what happens. Again thanks, sometimes it just takes an example to get you going!!