A
annascalise
Hi,
I am really stuck with my program that will compare two strings and
assign scores between pairs of letters.
my sequences are read in ok
seq1 = ATCGTCGTA
seq2 = TCGTACTAA
a second file formatted as so...
A A 1
T T 1
C C 1
G G 1
is now in a 2D char array
I just cannot think how on earth to get my values out of my array, i
know if I get past this milestone I will be fine (I do not have much
java experience or knowledge at my disposal - in fact it all i can do
to understand the code I have wrote)
thanks,
Anna
to creat a dot plot import java.io.*;
import java.util.*;
class BlackBox3
{
public static void main(String[] args)
{
int count = 0;
String allChars = "";
int loopcount;
int i1 = 0;
int i2 = 0;
int array1 = 0;
int array2 = 0;
String t, c1 = "", c2 = "", c3 = "";
StringTokenizer st;
boolean flag = false;
char tempChar;
String s;
char anna = 'D';
char[][] triplet;
try
{
InputStreamReader input = new InputStreamReader(System.in);
BufferedReader keyboardInput = new BufferedReader(input);
String File1;
System.out.print("Enter name of file 1: ");
File1 = keyboardInput.readLine();
FileReader file=new FileReader (File1);
BufferedReader buffer=new BufferedReader(file);
String seq1;
seq1 = buffer.readLine();
System.out.println("Sequence 1: " + seq1);
String seq2;
seq2 = buffer.readLine();
System.out.println("Sequence 2: " + seq2);
buffer.close();
String File2;
System.out.print("Enter name of file 2: ");
File2 = keyboardInput.readLine();
FileReader file2=new FileReader (File2);
BufferedReader buffer2=new BufferedReader(file2);
t = buffer2.readLine();
while(t != null)
{
st = new StringTokenizer(t);
for(int stCount = 0; stCount <2; stCount++)
{
s=st.nextToken();
if (stCount == 0)
{
c1 = c1 + s;
}
else
{
c2 = c2 + s;
}
if (count == 0)
{
count++;
allChars = s;
}
else
{
flag = false;
tempChar = s.charAt(0);
for (loopcount = 0; loopcount < allChars.length(); loopcount++)
{
if(tempChar == allChars.charAt(loopcount))
{
flag = true;
}
}
if (flag == false)
{
allChars = allChars + s;
}
}
}
s = st.nextToken();
c3 = c3 + s;
t = buffer2.readLine();
}
System.out.println(c1 + c2 + c3);
System.out.println("allChars :" + allChars);
buffer2.close();
triplet = new char[allChars.length()][allChars.length()];
for(int column1 = 0; column1 < allChars.length(); column1++)
{
for(int column2 = 0; column2 < allChars.length(); column2++)
{
triplet[column1][column2]='0';
}
}
for(int column3 = 0; column3 < allChars.length(); column3++)
{
triplet[column3][column3]=c3.charAt(column3);
}
/////////////////////////////////////////////////////////////////////////////////////
//I am trying to say, when seq1charAt = O i dont know im so stuck
//
// for(int loop0 = 0; loop0 < seq1.length(); loop0++)
// {
// for(int loop1 = 0; loop1 < seq1.length(); loop1++)
// {
// for(int loop2 = 0; loop2 < allChars.length(); loop2++)
// {
// if(seq1.charAt(loop1) == c1.charAt(loop2))
// {
// i1 = loop2;
// }else{}
// }
// }
// for(int loop3 = 0; loop3 < seq1.length(); loop3++)
// {
// for(int loop4 = 0; loop4 < allChars.length(); loop4++)
// {
// if(seq2.charAt(loop3) == c2.charAt(loop4))
// {
// i2 = loop4;
// }else{}
// }
// }
// System.out.print(triplet[i1][i2]);
// }
/////////////////////////////////////////////////////////////////////////////////////
}
catch( IOException e ) {System.out.println(e);}
}
}
I am really stuck with my program that will compare two strings and
assign scores between pairs of letters.
my sequences are read in ok
seq1 = ATCGTCGTA
seq2 = TCGTACTAA
a second file formatted as so...
A A 1
T T 1
C C 1
G G 1
is now in a 2D char array
I just cannot think how on earth to get my values out of my array, i
know if I get past this milestone I will be fine (I do not have much
java experience or knowledge at my disposal - in fact it all i can do
to understand the code I have wrote)
thanks,
Anna
to creat a dot plot import java.io.*;
import java.util.*;
class BlackBox3
{
public static void main(String[] args)
{
int count = 0;
String allChars = "";
int loopcount;
int i1 = 0;
int i2 = 0;
int array1 = 0;
int array2 = 0;
String t, c1 = "", c2 = "", c3 = "";
StringTokenizer st;
boolean flag = false;
char tempChar;
String s;
char anna = 'D';
char[][] triplet;
try
{
InputStreamReader input = new InputStreamReader(System.in);
BufferedReader keyboardInput = new BufferedReader(input);
String File1;
System.out.print("Enter name of file 1: ");
File1 = keyboardInput.readLine();
FileReader file=new FileReader (File1);
BufferedReader buffer=new BufferedReader(file);
String seq1;
seq1 = buffer.readLine();
System.out.println("Sequence 1: " + seq1);
String seq2;
seq2 = buffer.readLine();
System.out.println("Sequence 2: " + seq2);
buffer.close();
String File2;
System.out.print("Enter name of file 2: ");
File2 = keyboardInput.readLine();
FileReader file2=new FileReader (File2);
BufferedReader buffer2=new BufferedReader(file2);
t = buffer2.readLine();
while(t != null)
{
st = new StringTokenizer(t);
for(int stCount = 0; stCount <2; stCount++)
{
s=st.nextToken();
if (stCount == 0)
{
c1 = c1 + s;
}
else
{
c2 = c2 + s;
}
if (count == 0)
{
count++;
allChars = s;
}
else
{
flag = false;
tempChar = s.charAt(0);
for (loopcount = 0; loopcount < allChars.length(); loopcount++)
{
if(tempChar == allChars.charAt(loopcount))
{
flag = true;
}
}
if (flag == false)
{
allChars = allChars + s;
}
}
}
s = st.nextToken();
c3 = c3 + s;
t = buffer2.readLine();
}
System.out.println(c1 + c2 + c3);
System.out.println("allChars :" + allChars);
buffer2.close();
triplet = new char[allChars.length()][allChars.length()];
for(int column1 = 0; column1 < allChars.length(); column1++)
{
for(int column2 = 0; column2 < allChars.length(); column2++)
{
triplet[column1][column2]='0';
}
}
for(int column3 = 0; column3 < allChars.length(); column3++)
{
triplet[column3][column3]=c3.charAt(column3);
}
/////////////////////////////////////////////////////////////////////////////////////
//I am trying to say, when seq1charAt = O i dont know im so stuck
//
// for(int loop0 = 0; loop0 < seq1.length(); loop0++)
// {
// for(int loop1 = 0; loop1 < seq1.length(); loop1++)
// {
// for(int loop2 = 0; loop2 < allChars.length(); loop2++)
// {
// if(seq1.charAt(loop1) == c1.charAt(loop2))
// {
// i1 = loop2;
// }else{}
// }
// }
// for(int loop3 = 0; loop3 < seq1.length(); loop3++)
// {
// for(int loop4 = 0; loop4 < allChars.length(); loop4++)
// {
// if(seq2.charAt(loop3) == c2.charAt(loop4))
// {
// i2 = loop4;
// }else{}
// }
// }
// System.out.print(triplet[i1][i2]);
// }
/////////////////////////////////////////////////////////////////////////////////////
}
catch( IOException e ) {System.out.println(e);}
}
}