Results 1 to 17 of 17
  1. #1
    batista11b5 is offline Member
    Join Date
    Oct 2010
    Posts
    23
    Rep Power
    0

    Default anyone help me solve my assignment ?

    Hi everyone , i'm newbie of JAVA so , i have a lot of thing wanna ask , please help me . this is my assignment :

    [size=large]Question 2—Nucleotides[/size]

    DNA can be considered the source code of life1. It contains the instructions for (most of the) life on
    Earth. Unlike digital computers that use binary to encode information and instructions in 1s and 0s, DNA
    has four possible nucleotides: Adenine, Cytosine, Guanine, and Thymine, represented by A, C, G and T,
    respectively.
    Bioinformatics is field of study that applies concepts from computer science and statistics to study
    molecular biology using computer software and hardware.
    Biologists and bioinformaticians typically store genetic databases of DNA in a text‐based file format
    called FASTA2. The FASTA file format is relatively simple:
    • Each FASTA‐formatted file starts with a header line. The first character on a header line is
    always the greater‐than character (‘>’),
    • The header line is followed by lines of sequence data (As, Cs, Gs, and Ts), with 80 (or fewer)
    characters per line.

    Example3:

    Java Code:
    >gi|21071042|ref|NM_000193.2| Homo sapiens sonic hedgehog (SHH), mRNA
    GCGAGGCAGCCAGCGAGGGAGAGAGCGAGCGGGCGAGCCGGAGCGAGGAAGGGAAAGCGCAAGAGAGAGC
    GCACACGCACACACCCGCCGCGCGCACTCGCGCACGGACCCGCACGGGGACAGCTCGGAAGTCATCAGTT
    CCATGGGCGAGATGCTGCTGCTGGCGAGATGTCTGCTGCTAGTCCTCGTCTCCTCGCTGCTGGTATGCTC
    GGGACTGGCGTGCGGACCGGGCAGGTTCGGGAAGAGGAGGCACCCCAAGCTGACCCCTTTAGCC
    TACAAGCAGTTTATCCCCAATGTGGCCGAGAAGACCCTAGGCGCCAGCGGAAGGTATGAAGGGAAGATCT
    CCAGAAACTCCGAGCGATTTAAGGAACTCACCAATTACAACCCCGACATCATATTTAAG
    Write a program that will

    read a file containing one FASTA formatted sequence record,
    • count the number of each of the four nucleotides (A,C,G and T) per sequence in the record, and
    • print a histogram displaying the genetic make‐up of the sequence record.

    Input: Use JFileChooser to prompt the user to select a FASTA formatted file, and use Scanner to read
    the file selected by the user. The FASTA formatted file selected by the user will contain at least one
    sequence record, but may contain more than one. Assume that the file chosen by the user will meet the
    standard FASTA file format described above, and that the sequence data will be all upper case
    characters.

    Java Code:
    [b]File input with JFileChooser and Scanner[/b]
    
    So far in the course you’ve used Scanner to get input from the user with the keyboard. In some
    situations, getting input from the keyboard is cumbersome (entering 1000 bases, for example).
    To use [b]JFileChooser[/b] your program must add a couple of import statements to the regular import
    statements:
    Java Code:
    import java.io.File;
    import java.io.FileNotFoundException;
    import javax.swing.JFileChooser;
    You’ll also need to insert and use the following static method:
    /**
    * Prompt the user to select a file using JFileChooser and return
    * the File object that the user selected.
    *
    * @return the file selected by the user
    */
    public static File getFile() {
    JFileChooser chooser = new JFileChooser();
    File fastaFile = null;
    int returnValue;
    // show the open file dialog
    returnValue = chooser.showOpenDialog(null);
    // check to see that the user clicked the OK button
    if (returnValue == JFileChooser.APPROVE_OPTION) {
    // get the selected file
    fastaFile = chooser.getSelectedFile();
    }
    return fastaFile;
    }
    So far we’ve been using Scanner by passing System.in to get input from the keyboard:
    Scanner keyboard = new Scanner(System.in);
    Scanner can also be used to read the contents of a file. Simply replace System.in with an
    instance of a File variable (like the one returned by getFile()):
    Scanner fileReader = new Scanner(aFile);
    Finally, you must surround any code using a fileReader instance of Scanner using a try/catch
    block. Try/catch blocks are used in Java to deal with possible runtime exceptions. In the case of
    reading files using Scanner, we have to deal with a possible FileNotFoundException – an
    exception that may occur if the user typed in a file name that did not exist.
    Example:
    try {
    Scanner fileReader = new Scanner(aFile);
    // your code working with fileReader goes here
    } catch (FileNotFoundException e) {
    e.printStackTrace();
    }
    Methods: In addition to the getFile() method, your program must implement and use the following
    static methods:

    Java Code:
    public static void main(String[] args)
    Your main method should prompt the user to select a FASTA file using the getFile() method.
    Then, the main method should pass the file to getHeader() and getSequence() to get the header and
    sequence from the FASTA file. Next, the main method should call countBase() for each of the four
    different types of bases and determine the percentage of the entire sequence that each base

    represents. The percentage should be rounded to the nearest whole number. Finally, the main method
    should call printDNAHistogram() to print out the histogram representing the statistics of the file.

    Java Code:
    public static String getHeader(File fastaFile)
    Using Scanner, the getHeader method should read the first line contained in fastaFile
    (which is the header line of the record). This method should remove the leading ‘>’ character before
    returning the header line.

    Java Code:
    public static String getSequence(File fastaFile)
    Using Scanner, the getSequence method should skip the first line contained in fastaFile
    (which is the header line of the record) and store any subsequent lines (the sequence data) until the
    Scanner has no more lines left. The getSequence method should use the hasNextLine() and
    nextLine() methods from the Scanner class to read the sequence from the file. Once the Scanner
    has no more lines remaining, the getSequence method should return all of the data that it stored.

    Java Code:
    public static int countBase(String sequence, char base)
    The countBase method accepts sequence data (a String containing only As, Cs, Gs, and Ts),
    and a specific base character to count. The countBase method should return the number of times
    that base occurred in sequence.

    Java Code:
    public static void printDNAHistogram(String header, int aPct, int
    cPct, int gPct, int tPct)
    The printDNAHistogram method should print out the histogram for the result calculated by
    other methods. The printDNAHistogram method should first print out header, and then it should
    call the printBar method (described below) for each of aPct, cPct, gPct, and tPct.

    Java Code:
    public static void printBar(String label, int percent, char barSymbol)
    The printBar method should print out a single bar for a histogram. The printBar method
    should first print out label. Then, the method should print out percent copies of the symbol
    barSymbol. Finally, the method should print out the actual percentage that the bar displays. All of
    this information should be on the same line
    .

    For example, the call

    Java Code:
    printBar("A",25,'=');
    would print out the following line:
    Java Code:
    A: ========================= (25%)
    Output: Use System.out for all output. For the sequence record in the file, print:

    1. The header line (without the leading ‘>’), and
    2. A histogram showing the percentage of As, the percentage of Cs, the percentage of Gs, and the
    percentage of Ts.

    Using the example sequence from above, an execution of your program would look like this:

    Java Code:
    gi|21071042|ref|NM_000193.2| Homo sapiens sonic hedgehog (SHH), mRNA
    A: ========================= (25%)
    G: ================================= (33%)
    C: ============================= (29%)
    T: ============== (14%)
    Programmed by [your name here].
    End of processing.
    Hand‐in: Save your file using the naming conventions described in the beginning of the assignment.
    Upload your file using the web‐based hand‐in tool. Also, submit the output for the two FASTA files
    provided on the course web page.

    PDF file :
    Java Code:
    http://www.mediafire.com/?trgt46rb81n1g8h

    I get stuck at this point when filling out at (while loop) ,any one help me

    Java Code:
    import java.io.File;
    import java.io.FileNotFoundException;
    import javax.swing.JFileChooser;
    import java.util.Scanner;
    
    // name of class.
    public class QuangNguyenA3Q2 {
    	public static void main (String[]args) {
    
    
    		try {
    		Scanner fileReader = new Scanner(getFile());
    
    		// code working with fileReader goes here
    
    		int A;
    		int C;
    		int G;
    		int T;
    		char x;
    
    		while () {
    
    			if( x == 'A') A++;
    			if( x == 'C') C++;
    			if( x == 'G') G++;
    			if( x == 'T') T++;
    	}
    
    		} catch (FileNotFoundException e) {
    		e.printStackTrace();
    }
    
    	}
    
    	public static File getFile() {
    		JFileChooser chooser = new JFileChooser();
    		File fastaFile = null;
    		int returnValue;
    
    	// show the open file dialog
    		returnValue = chooser.showOpenDialog(null);
    
    	// check to see that the user clicked the OK button
    		if (returnValue == JFileChooser.APPROVE_OPTION) {
    	// get the selected file
    		fastaFile = chooser.getSelectedFile();
    		}
    		return fastaFile;
    	}
    }
    Last edited by batista11b5; 11-14-2010 at 07:06 AM.

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,585
    Rep Power
    12

    Default

    Your main method should prompt the user to select a FASTA file using the getFile() method.
    Then, the main method should pass the file to getHeader() and getSequence()...

    Why are you not doing what the assignment told you to do?

    The instructions were quite clear about what should go in the main() method and that while loop wasn't mentioned.

    The order given in the instructions is a pretty decent way to attack this problem. So start by

    (1) Using getFile() to obtain the file to use

    (2) Then calling getHeader() - which you will have to write - to obtain the header line.

    (3) Then print that header line.

    (The last step is not actually in the instructions but it's clear from the example at the end)

    ---------------------

    Some techniques that I find useful:

    * have a clear plan. The assignment instructions provide this. Don't ignore them.

    * compile. compile. compile. Compile after every line or block of code if need be. If you can't understand a compiler message post it here and someone will explain. But do not let them accumulate.

    * Test as often as you can. Once you get to the third step above you can test what you have so far by running the program with your test data and checking the header. (You can also add other stuff that you print just to check what's going on, then remove it before you hand the assignment in) If your tests fail - the header line isn't right, or doesn't print or the program throws an exception - then again you can post here if you don't understand what is going on.

  3. #3
    batista11b5 is offline Member
    Join Date
    Oct 2010
    Posts
    23
    Rep Power
    0

    Default

    thnka for replying and like i said before , i'm just a newbie so my knowledge about JAVA not much and i'm not a smart guy , so please help me step by step to learn .First thank pbrockway2 , second thank everyone who will help me out .

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by batista11b5 View Post
    so please help me step by step to learn .
    Forums are great for answering straightforward questions, but unfortunately, there are some things that a forum is just not good for, and this is one of them since what you really need to learn step by step is to study. The forum can't really substitute for this. So don't give up, keep at it, and then if you run into any roadblocks and have any specific questions, please come on here and ask them.

    Best of luck!

  5. #5
    batista11b5 is offline Member
    Join Date
    Oct 2010
    Posts
    23
    Rep Power
    0

    Default

    Thank Fubarable for replying me , but i really dont know what to go at this line ,I'm not a smart guy so please give me a couple line for example ,Thanks Fubarable so much

    Java Code:
    import java.io.File;
    import java.io.FileNotFoundException;
    import javax.swing.JFileChooser;
    import java.util.Scanner;
    
    // name of class.
    public class QuangNguyenA3Q2 {
    	public static void main (String[]args) {
    
    
    		try {
    		Scanner fileReader = new Scanner(getFile());
    
    		// code working with fileReader goes here
    
    		
    	[COLOR="Red"][B]What to go there [/B][/COLOR]
    
    		} catch (FileNotFoundException e) {
    		e.printStackTrace();
    }
    
    	}
    
    	public static File getFile() {
    		JFileChooser chooser = new JFileChooser();
    		File fastaFile = null;
    		int returnValue;
    
    	// show the open file dialog
    		returnValue = chooser.showOpenDialog(null);
    
    	// check to see that the user clicked the OK button
    		if (returnValue == JFileChooser.APPROVE_OPTION) {
    	// get the selected file
    		fastaFile = chooser.getSelectedFile();
    		}
    		return fastaFile;
    	}
    }

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    One small step at a time. If this were my program, I'd first work on creating this method:

    Java Code:
    public static String getHeader(File fastaFile) {
      // TODO: add code
    }
    Read your instructions above and try to create this method and then try to test it out. Worry about the rest of the program after you've solved this problem.

  7. #7
    batista11b5 is offline Member
    Join Date
    Oct 2010
    Posts
    23
    Rep Power
    0

    Default

    thank for your replying , but i got a problem here :when I change String to void it compile completely but when i keep String statement , It can't ,look at the RED one ,please help tell me why ,Thanks
    +And how to remove this symbol " > " like the assignment said , Many thanks

    Java Code:
    import java.io.File;
    import java.io.FileNotFoundException;
    import javax.swing.JFileChooser;
    import java.util.Scanner;
    
    // name of class.
    public class QuangNguyenA3Q2 {
    	public static void main (String[]args) {
    		File fastaFile;
    		String x;
    		fastaFile = getFile();
    
    
    		try {
    		Scanner fileReader = new Scanner(getFile());
    
    		// code working with fileReader goes here
    
    
    			x = fileReader.nextLine();
    			System.out.println(x);
    
    		} catch (FileNotFoundException e) {
    		e.printStackTrace();
    }
    
    	}
    
    	public static File getFile() {
    		JFileChooser chooser = new JFileChooser();
    		File fastaFile = null;
    		int returnValue;
    
    	// show the open file dialog
    		returnValue = chooser.showOpenDialog(null);
    
    	// check to see that the user clicked the OK button
    		if (returnValue == JFileChooser.APPROVE_OPTION) {
    	// get the selected file
    		fastaFile = chooser.getSelectedFile();
    		}
    		return fastaFile;
    	}
    	public static [COLOR="Red"][SIZE="5"]void[/SIZE][/COLOR] getHeader(File fastaFile) {
    		int lineNumber = 1;
    				String currLine;
    				try {
    					Scanner fileReader = new Scanner(fastaFile);
    					// your code working with fileReader goes here
    
    					while (fileReader.hasNextLine()) {
    						currLine = fileReader.nextLine();
    						System.out.println(lineNumber + " " + currLine);
    						lineNumber++;
    					}
    
    				} catch (FileNotFoundException e) {
    					e.printStackTrace();
    		}
    
    	}
    
    }
    Last edited by batista11b5; 11-14-2010 at 07:28 PM.

  8. #8
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    void means that the method returns nothing, but when you make the method's return type String, then it must return a String, and your method body doesn't do that. For instance, check out the good and bad method below:

    Java Code:
    public static String goodMethod() {
       return "foo"; // this returns a String
    }
    
    public static String badMethod() {
       // this one doesn't but should
    }

    So your getHeader method needs to extract the header String from the file, and then return that String. Make sense?

  9. #9
    batista11b5 is offline Member
    Join Date
    Oct 2010
    Posts
    23
    Rep Power
    0

    Default

    Thank you , i got it and compile completely ,but i dont know how to how to remove this symbol " > " like the assignment said , Many thanks

  10. #10
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Since you know that it is the first character of the String, you could do this pretty easily using String's subString method. Have a look at it in the String API: subString method

  11. #11
    batista11b5 is offline Member
    Join Date
    Oct 2010
    Posts
    23
    Rep Power
    0

    Default

    HI Fubarable ,I can't execute it , WHat can i do now ?

    Java Code:
    import java.io.File;
    import java.io.FileNotFoundException;
    import javax.swing.JFileChooser;
    import java.util.Scanner;
    
    // name of class.
    public class QuangNguyenA3Q2 {
    	public static void main (String[]args) {
    		File fastaFile;
    		String x;
    		fastaFile = getFile();
    
    
    		try {
    		Scanner fileReader = new Scanner(getFile());
    
    		// code working with fileReader goes here
    
    
    			x = fileReader.nextLine();
    			System.out.println(x);
    
    		} catch (FileNotFoundException e) {
    		e.printStackTrace();
    }
    
    	}
    
    	public static File getFile() {
    		JFileChooser chooser = new JFileChooser();
    		File fastaFile = null;
    		int returnValue;
    
    	// show the open file dialog
    		returnValue = chooser.showOpenDialog(null);
    
    	// check to see that the user clicked the OK button
    		if (returnValue == JFileChooser.APPROVE_OPTION) {
    	// get the selected file
    		fastaFile = chooser.getSelectedFile();
    		}
    		return fastaFile;
    	}
    
    
    	public static String getHeader(File fastaFile) {
    		int lineNumber = 1;
    		[COLOR="Red"][B]String substring = lineNumber.substring(1);[/B][/COLOR]
    				String currLine;
    
    				try {
    					Scanner fileReader = new Scanner(fastaFile);
    					// your code working with fileReader goes here
    
    					while (fileReader.hasNextLine()) {
    						currLine = fileReader.nextLine();
    						System.out.println([COLOR="Red"][B]substring[/B][/COLOR] + " " + currLine);
    						lineNumber++;
    					}
    
    				} catch (FileNotFoundException e) {
    					e.printStackTrace();
    		}
    
    			return "foo";
    	}
    
    }
    Last edited by batista11b5; 11-14-2010 at 08:39 PM.

  12. #12
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by batista11b5 View Post
    HI Fubarable ,I can't execute it , WHat can i do now ?
    I don't know. If you are having any errors, you're keeping them secret from us, and so you might want to tell us what they are and in fact post the error messages.

    Also, here:
    Java Code:
    	public static String getHeader(File fastaFile) {
    		int lineNumber = 1;
    		[COLOR="Red"][B]String substring = lineNumber.substring(1);[/B][/COLOR]
    				String currLine;
    
    				try {
    					Scanner fileReader = new Scanner(fastaFile);
    					// your code working with fileReader goes here
    
    					while (fileReader.hasNextLine()) {
    						currLine = fileReader.nextLine();
    						System.out.println([COLOR="Red"][B]substring[/B][/COLOR] + " " + currLine);
    						lineNumber++;
    					}
    
    				} catch (FileNotFoundException e) {
    					e.printStackTrace();
    		}
    
    			return "foo";
    	}
    
    }
    In this method you've got to get out of thinking in terms of println and instead return the actual String of interest. "foo" is not the string of interest, but the String you call substring is. So return it.

  13. #13
    batista11b5 is offline Member
    Join Date
    Oct 2010
    Posts
    23
    Rep Power
    0

    Default

    Hi Fubarable ,it's still not working and prompt this error

    Java Code:
    public static String getHeader(File fastaFile) {
    		int lineNumber = 1;
    		[COLOR="Red"]String substring = lineNumber.substring(1);[/COLOR]
    
    				String currLine;
    
    				try {
    					Scanner fileReader = new Scanner(fastaFile);
    					// your code working with fileReader goes here
    
    					while (fileReader.hasNextLine()) {
    						currLine = fileReader.nextLine();
    						System.out.println([COLOR="Red"]substring[/COLOR] + " " + currLine);
    						lineNumber++;
    					}
    
    				} catch (FileNotFoundException e) {
    					e.printStackTrace();
    		}
    
    			[COLOR="Red"]return substring;[/COLOR]
    	}
    
    }

    error:

    Java Code:
    C:\Users\k3107q\Desktop\assignment\QuangNguyenA3Q2.java:48: int cannot be dereferenced
    		String substring = lineNumber.substring(1);
    		                             ^
    1 error
    
    Tool completed with exit code 1

  14. #14
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Your error message is telling you exactly what is wrong. The lineNumber variable is an int variable, and you can't call String methods on an int -- makes no sense. In fact you can't call any methods on primitive variables such as ints.

    And this suggests that your logic is broken and needs to be fixed. One key to being successful as a programmer is that you should think through your logic and write it down before commiting code to your program. So what are the steps that you need to take for this method to be successful?

    In pseudocode

    Java Code:
    Pass a file into the method
    Create a Scanner object with this file
    While the Scanner has a next line, loop 
       Get the scanner's next line.
       if the first character of this line == '>'  then   // use the String method charAt(0) to get the first char
          close the Scanner object // don't forget to do this!
          get the line's subString(1) and return it! // once we've found our String we can call return since there's no need to keep looping through the file.
       end if
    end while the scanner...

  15. #15
    batista11b5 is offline Member
    Join Date
    Oct 2010
    Posts
    23
    Rep Power
    0

    Default

    +Thank Fubarable for helping me a lot, i have to say that i'm not talent at programming and the programmer title not for me ,I have no ability to get that title , and I just tried this course for 2 months . And I recognized that it not appropriate for me But i have to try to pass this course ,so that's why I asked you a lot , please understand .

    +following your explaining for me , I still not get it ,please give me an example code for easier ,many thanks

  16. #16
    batista11b5 is offline Member
    Join Date
    Oct 2010
    Posts
    23
    Rep Power
    0

    Default

    Anyone help me , i got stuck at this point

    Java Code:
    public static void printDNAHistogram(String header, int aPct, int
    cPct, int gPct, int tPct)
    The printDNAHistogram method should print out the histogram for the result calculated by
    other methods. The printDNAHistogram method should first print out header, and then it should
    call the printBar method (described below) for each of aPct, cPct, gPct, and tPct.

    Java Code:
    public static void printBar(String label, int percent, char barSymbol)
    The printBar method should print out a single bar for a histogram. The printBar method
    should first print out label. Then, the method should print out percent copies of the symbol
    barSymbol. Finally, the method should print out the actual percentage that the bar displays. All of
    this information should be on the same line.

    For example, the call

    Code:

    printBar("A",25,'=');

    would print out the following line:
    Code:

    A: ========================= (25%)

    This is my work .

    Java Code:
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.util.Scanner;
    
    import javax.swing.JFileChooser;
    
    // name of class.
    
    public class QuangNguyenA3Q2 {
    
        private static Scanner scanner;
        private static File fastaFile;
        private static JFileChooser chooser;
        private static StringBuilder sb;
        private static int count;
    
        public static void main(String[] args) {
            getFile();
            if (fastaFile != null) {
    			// print message and get next input
                System.out.printf("%1$s\r\n", getHeader(fastaFile));
                System.out.printf("%1$s\r\n", getSequence(fastaFile));
            } else {
                System.out.println("Invalid FASTA file.");
            }
        }
    
        public static File getFile() {
    		// show the open file dialog
            chooser = new JFileChooser();
    	// check to see that the user clicked the OK button
            if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
    		// get the selected file
                fastaFile = chooser.getSelectedFile();
                return fastaFile;
            }
    
            return null;
        }
    
        public static String getHeader(File file) {
            if (file != null) {
                try {
                    scanner = new Scanner(file);
                    // your code working with fileReader goes here
                    return scanner.nextLine().substring(1,
                            scanner.nextLine().length() - 1);
                } catch (FileNotFoundException fnf) {
                    fnf.printStackTrace();
                } finally {
                    if (scanner != null) {
                        scanner.close();
                    }
                }
            }
    
            return null;
        }
    	//the getSequence method should skip the first line contained in fastaFile.
        public static String getSequence(File file) {
            if (file != null) {
                try {
                    sb = new StringBuilder();
                    scanner = new Scanner(file);
    			// your code working with fileReader goes here.
                    while (scanner.hasNextLine()) {
                        if (!scanner.nextLine().contains(">")) {
                            sb.append(scanner.nextLine());
                        }
                    }
    
                    return sb.toString();
                } catch (FileNotFoundException fnf) {
                    fnf.printStackTrace();
                } finally {
                    if (scanner != null) {
                        scanner.close();
                    }
                }
            }
    
            return null;
        }
    	//accepts sequence data (a String containing only As, Cs, Gs, and Ts),
        public static int countBase(String sequence, char base) {
            for (int i = 0; i < sequence.length(); i++) {
                if (sequence.charAt(i) == base) {
                    count++;
                }
            }
    
            return count;
        }
    
    }
    Last edited by batista11b5; 11-15-2010 at 04:12 AM.

  17. #17
    mine0926 is offline Senior Member
    Join Date
    Apr 2010
    Location
    Philippines
    Posts
    580
    Rep Power
    5

    Default

    Quote Originally Posted by batista11b5 View Post
    Anyone help me , i got stuck at this point
    What happen? What error did you get? Is it compile or runtime error?


    Quote Originally Posted by batista11b5 View Post
    Anyone help me , i got stuck at this point

    public static File getFile() {
    // show the open file dialog
    chooser = new JFileChooser();
    // check to see that the user clicked the OK button
    if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
    // get the selected file
    fastaFile = chooser.getSelectedFile();
    return fastaFile;
    }

    return null;
    }
    [/CODE]
    I think fubarable already told you this. Your getFile() method should return a File if user input a valid file, you only return null if the file is invalid or and error occured such as FileNotFound. Same as your getHeader(File file) and getSequence(File file) they always return null.
    Last edited by mine0926; 11-15-2010 at 04:41 AM.

Similar Threads

  1. assignment help
    By esallender in forum New To Java
    Replies: 4
    Last Post: 10-25-2010, 01:10 PM
  2. Assignment
    By shinkymar in forum New To Java
    Replies: 2
    Last Post: 03-06-2010, 02:17 PM
  3. need help! assignment due by tmr!
    By keycoffee in forum New To Java
    Replies: 3
    Last Post: 02-10-2010, 06:45 PM
  4. First GUI Assignment
    By ljk8950 in forum New To Java
    Replies: 1
    Last Post: 07-31-2008, 08:29 AM
  5. Cannot solve the coding problem of my assignment
    By elimmom in forum New To Java
    Replies: 3
    Last Post: 08-13-2007, 12:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •