BioInformatics Assignment

Discussion in 'Mac Programming' started by Mac Guy Java, Feb 24, 2014.

  1. Mac Guy Java, Feb 24, 2014
    Last edited by a moderator: Feb 24, 2014

    Mac Guy Java macrumors newbie

    Mac Guy Java

    Joined:
    Dec 6, 2013
    Location:
    Earth
    #1
    I am in grade 11 computer science, and I'm experiencing difficulty with an assignment. My task is:

    Write a program which reads in a file containing a DNA sequence. Stores it as a String, and produces its DNA complement or builds the RNA.

    What I have so far is:

    Code:
       import java.io.*;
       import java.util.Scanner;
       import java.util.ArrayList;
       import java.util.List;
       import java.util.Iterator;  
    	
        class BioInformaticsLevel1 
       { 
           public static void main(String args[]) throws Exception 
          { 
             File file = new File("NC_003197_fna.mht");
             Scanner sc = new Scanner(file);
             String line = "";
          		
             while( sc.hasNextLine() ) 
             { 
                
                line = sc.nextLine();
             		
                System.out.println(line); 
             }
          
          }
       }
    
    After compiling and running, I get this:

    Code:
    Exception in thread "main" java.io.FileNotFoundException: NC_003197_fna.mht (The system cannot find the file specified)
    	at java.io.FileInputStream.open(Native Method)
    	at java.io.FileInputStream.<init>(Unknown Source)
    	at java.util.Scanner.<init>(Unknown Source)
    	at BioInformaticsLevel1.main(BioInformaticsLevel1.java:12)
    
    My specific confusion with this is that I do not know how get it to import my file, which is a txt. I also can't figure out how to convert the DNA letters into RNA letters.

    I would really appreciate it if someone could guide me through this assignment and help me figure out what I am supposed to do. Thanks.
     
  2. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #2
    How are you compiling your code?

    How are you running it after it's compiled?

    Be specific. Name the IDE and its version, or post the exact command-line you're using. If you're using something other than an IDE or command-line, describe exactly what it is.
    http://en.wikipedia.org/wiki/Integrated_development_environment


    The filename you're using is a relative path. It's relative to the working directory. If the working directory is wrong, then the relative path of the file won't work.
    http://en.wikipedia.org/wiki/Path_(computing)
    http://en.wikipedia.org/wiki/Working_directory

    Since you haven't yet told us how you're running the program, we don't know what your working directory is set to. Every IDE has a different way to set the working directory. There is also a command that works in Terminal, but you'd first have to tell us if you're using a Terminal command-line, and exactly where the files are located.


    It would also help us understand your tools if you tell us what your OS version is. The builtin tools vary across different OS versions.


    Finally, is your instructor expecting you to be using Windows to do this assignment? Or was the choice of OS left up to you?
     
  3. mobilehaathi macrumors G3

    mobilehaathi

    Joined:
    Aug 19, 2008
    Location:
    The Anthropocene
    #3
    I can't tell if this is a programming question or a biology question. If I gave you a DNA base can you give me the complement?

    TAGCAA

    Are you able to write down the complement to that sequence?
     
  4. Mac Guy Java, Feb 26, 2014
    Last edited by a moderator: Feb 26, 2014

    Mac Guy Java thread starter macrumors newbie

    Mac Guy Java

    Joined:
    Dec 6, 2013
    Location:
    Earth
    #4
    I am using jGRASP. At school I use Windows XP, but when I take the program home I use Mac OS X Mavericks. The OS does not matter to the teacher. I run the program inside of jGRASP after compiling. I figured out that so long as my file is kept in the same directory as my Java Project Files, I can import it by typing the name of the file into my code. I have made a few changes since making this post, but I am still having difficulties completing the assignment.

    Code:
       import java.io.*;
       import java.util.Scanner;
       import java.util.ArrayList;
       import java.util.List;
       import java.util.Iterator;  
    	
        class BioInformaticsLevel1 
       { 
           public static void main(String args[]) throws Exception 
          { 
             File file = new File("dna.txt");
             Scanner sc = new Scanner(file);
             String line = "";
          		
             while( sc.hasNextLine() ) 
             { 
                
                line = (line + sc.nextLine());
             		
                
             }
           System.out.println(line);
          }
       }
    
    So now it loads my DNA file with no errors :). All that is left to do is to convert it to RNA, which I need assistance with. All help is greatly appreciated.
     
  5. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #5
    Start by answering mobilehaathi's question:
    If you're able to do it, then post the answer as a series of letters. If you're unable to do it, then you need to study how DNA is transcribed to RNA.

    If you post an answer, then think about the exact steps of what you did. Write them down and post them. Someone else who reads your steps should be able to follow them and produce the same answer you did.

    Programming is the process of converting a well-understood series of steps into instructions to the computer. If you don't know what the steps are, you can't write a program for them. Coming up with the steps is called "designing the software" or simply "design", and is frequently the hardest part of programming. That is, coming up with a clear expression of what the steps should do is often harder than writing code from the clear expression.
     
  6. Mac Guy Java thread starter macrumors newbie

    Mac Guy Java

    Joined:
    Dec 6, 2013
    Location:
    Earth
    #6
    I am absolutely horrible at programming, and I know nothing about DNA. I wanted to drop the course, but by the time I realized how horrible I was at it, it was too late to do anything about it. I was hoping for someone to provide me with the code necessary for making this program work, along with an explanation as to how it was done. I want to understand how to do this, but I don't even know where to begin with all of this. Even the code I posted was something supplied by the teacher with a few minor alterations I've made.
     
  7. mobilehaathi macrumors G3

    mobilehaathi

    Joined:
    Aug 19, 2008
    Location:
    The Anthropocene
    #7
    No one is going to do your homework for you. The question of biology here is trivial. In the time you took to write that post you could have discovered the answer.

    Do you even know what DNA is?
     
  8. monokakata macrumors 68000

    monokakata

    Joined:
    May 8, 2008
    Location:
    Hilo, Hawai'i
    #8
    I won't do your DNA homework for you, but you do sound distraught and I hate seeing that in students.

    Look, Google will easily answer your DNA-RNA question. Try a search term such as "dna rna base pairing rules" and you'll get your answer. It's probably also in your course notes.

    The rest, as others have said, is just programming, and it's not as difficult as you seem to fear. Chown33 tells you exactly what to do, and he's right.

    Lay out the bases and figure out what matches what. Then -- one easy way -- write a bunch of 'if . . then' statements.

    You can do this yourself -- really, you can. Calm down.
     
  9. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #9
    You need to discuss your situation with your instructor.

    If you're that far underwater, then you'll need some tutoring outside of class. Instructors usually know of tutors or alternatives for catching up missed material. This is why you need to talk to your instructor.

    Nevertheless, you may have only one alternative: fail the class. Cheating and having others do your work can have far graver consequences than failing a class; it can get you ejected from the school entirely.
     

Share This Page