Here are the instructions for this part of the project:
Worth 5 points
- Download the file called hs_chr1.dna from:
http://users.cis.fiu...amples/1200.dna
- open the previous file.
- load it into a one dimension array or a String, your choice
this file contains nueclotides/bases/letters in it such as a, c, g, and t, others.
- Find out the total amount of neuclotides a, how many c, how many g, how many t and how many all others are in this file.
Make sure to test for upper and lower cases of each a,c,g,t base.
- Print the first and the last neuclodide in the file, and using the ceil() method print the one exactly in the middle of the file
- Print all total in an aligned column the numeric format 1,234,567
Here is my code
package knight_glen_project5;
import java.io.*;
import java.util.ArrayList;
public class Main {
public static void main(String[] args) throws IOException
{
int[] nameList = null;
DNA(nameList);
}
public static void DNA(int[] nameList) throws IOException
{
int index=0;
FileReader freader = new FileReader("C:\\1200.dna");
BufferedReader inputfile = new BufferedReader(freader);
String str;
str=inputfile.readLine();
while(str != null)
{
nameList[index] = Integer.parseInt(str);
index++;
str = inputfile.readLine();
}
inputfile.close();
int occurence=0;
int occurence1=0;
int occurence2=0;
int occurence3=0;
int occurence4=0;
for (int i = 0; i < nameList.length; i++)
{
char letter = (char) nameList[i];
String s1= Character.toString(letter);
if (s1.equalsIgnoreCase("a"))
{
occurence++;
}
else if (s1.equalsIgnoreCase("c"))
{
occurence1++;
}
else if (s1.equalsIgnoreCase("g"))
{
occurence2++;
}
else if(s1.equalsIgnoreCase("t"))
{
occurence3++;
}
else
{
occurence4++;
}
}
System.out.println("There are " +occurence +" occurences of a");
System.out.println("There are " +occurence1 +" occurences of c");
System.out.println("There are " +occurence2 +" occurences of g");
System.out.println("There are " +occurence3 +" occurences of t");
System.out.println("There are " +occurence4 +" occurences of other letters");
}
}
And here is the error I'm receiving when I try to run the program:
run:
Exception in thread "main" java.lang.NumberFormatException: For input string: "Tttaaagagaccggcgattctagtgaaatcgaacgggcaggtcaatttccaaccagcgan"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Integer.parseInt(Integer.java:449)
at java.lang.Integer.parseInt(Integer.java:499)
at knight_glen_project5.Main.DNA(Main.java:51)
at knight_glen_project5.Main.main(Main.java:36)
Java Result: 1
BUILD SUCCESSFUL (total time: 5 seconds)
Can anyone help me out with this, I'm a bit lost

New Topic/Question
Reply



MultiQuote





|