I figured it out. I wasn't spelling the things right in the command prompt (because of the hard coding)
and for those of you who helped me with the original model of this code i fixed that version as well. These codes do the same thing but written differently
import java.util.*;
import java.io.*;
public class Parser
{
public static void main(String[] args) throws IOException
{
PrintWriter out = new PrintWriter("fastaFile");
String[][] extractedInfo = extract_info();
int n = count_entries();
for(int i = 0; i < n; i++)
{
out.write("<"+extractedInfo[i][1]+"\n"+extractedInfo[i][0]+"\n");
}
out.close();
}
public static String[][] extract_info() throws IOException
{
String[][] extractedData = new String[count_entries()][2];
File uniprot = new File ("uniprotFile");
Scanner uniprotScanner = new Scanner (uniprot);
int i = 0;
boolean foundAC = false;
boolean SQMode = false;
String sequence = "";
while (uniprotScanner.hasNextLine())
{
String currentLine = uniprotScanner.nextLine();
String[] tokens = currentLine.split(" ");
if ( tokens [0].equals("AC") && !foundAC )
{
extractedData[i][1] = tokens[3];
foundAC = true;
}
else if (tokens [0].equals("SQ") && !SQMode)
{
SQMode = true;
}
else if (currentLine.startsWith("//"))
{
SQMode = foundAC = false;
extractedData[i][0] = sequence;
sequence = "";
i++;
}
else if (SQMode)
{
sequence += currentLine.replaceAll(" ", "");
}
}
return extractedData;
}
public static int count_entries() throws IOException
{
int entriesCount = 0;
File uniprot = new File ("uniprotFile");
Scanner uniprotScanner = new Scanner (uniprot);
while (uniprotScanner.hasNextLine())
{
String currentLine = uniprotScanner.nextLine();
String[] tokens = currentLine.split(" ");
if (tokens [0].equals("//"))
{
entriesCount++;
}
}
return entriesCount;
}
}
THanks for all the help. Assignment two is due monday so expect some posts here in a day or so.
Thanks again