my program works in such a way that it will ouput to a notepad. i did both printing in command prompt and and printWriter.. output the file to notepad.. yes the program can run in command prompt, but my output.txt appears to be 0kb. im not sure why. this is the file where i write the codes to output to notepad. anybody can tell me the mistake?
import java.io.*; public class dotplot { private controller control; private String xStr = ""; // Test sequence1 private String yStr = ""; // Test sequence2 private int winSize; // The sliding windows size private int stringency; // The stringency of the sliding window final static int SIZE = 100; // The maximum length of the sequence
static int [][] match = new int [SIZE][SIZE]; static char [][] overlay = new char [SIZE][SIZE]; // May use int[][] array static char x[] = new char [SIZE]; static char y[] = new char [SIZE]; static final int CMATCH = 1; int winMatch = 0;
public dotplot() { control = new controller(); xStr = control.getseq1(); yStr = control.getseq2(); winSize = control.getwinsize(); stringency = control.getstringency(); }
// Initialization of array public void init() throws IOException { try //print to notepad { file = new File("C:\\Documents and Settings\\JiHaN\\My Documents\\My eBooks\\JavaPrograms\\dotplot(Jihan)\\output.txt"); if (file != null) { fileWriter = new FileWriter(file); printWriter = new PrintWriter(fileWriter); }
for (int i=0; i < SIZE; i++) { for (int j=0; j < SIZE; j++) {
public void print() throws IOException { System.out.println("Starting DotPlot..."); System.out.println(""); init();
// Place the sequences in two char arrays // Using char array is much simple and more efficient xStr.getChars(0, xStr.length(), x, 0); yStr.getChars(0, yStr.length(), y, 0);
// This is the easier part. Find matching character pair for (int i=0; i < xStr.length(); i++) { for (int j=0; j < yStr.length(); j++) { // This is the part that determine which location in the graph if (x == y[j]) match[j] = CMATCH; }
} } // This is the sliding Window TECHNIQUE code portion public void slidingWindow() throws IOException {
for (int i=0; i < xStr.length()-winSize+1; i++) { for(int j=0; j < yStr.length()-winSize+1; j++) { for(int k=0,l=0; (k<winSize)||(l<winSize); k++,l++){
// Output Printing public void printOutput() throws IOException { print();
System.out.println("The length of xStr is " + xStr.length()); printWriter.println("The length of xStr is " + xStr.length()); System.out.println("The length of yStr is " + yStr.length()); printWriter.println("The length of yStr is " + yStr.length()); System.out.println(""); printWriter.println("");
//print out the sequence n plot it. System.out.print(" "); // Two spaces for the xStr printWriter.println(" "); for (int j=0; j < yStr.length(); j++) System.out.print(y[j] + " "); for (int j=0; j < yStr.length(); j++) printWriter.print(y[j] + " "); System.out.println("\n"); printWriter.println("\n");
for (int i=0; i < xStr.length(); i++) { System.out.print(x); printWriter.print(x); for (int j=0; j < yStr.length(); j++) { if (match[j] == CMATCH){ System.out.print(" x"); printWriter.print(" x"); } else { System.out.print(" "); printWriter.print(" "); }