Java 2
One of the key features of Java OOP is to use external class files without knowing much of the implementations. The attached RandomSeq.class file contains the implementation of a RandomSeq class which contain two methods:
String RandomSeq.getRandomSeq(long arg0) -will return a String of randomly generated DNA sequence of any length passed in as a parameter, and
void RandomSeq.formatSeq(int arg0) – will print out a formatted DNA sequence with specified length for each line as shown below:
1 GACTTGCCAGTTTAATAATGTCACATAATCAGATACGTAGATTCGCTTAT
51 ATGCCCGGCCCACTGACGGAGGGGCCCGGGGGTCCAGCCCATGGGGCAGA
101 GGGACACTCTGAACGCTCGCGCAGGTACGTGTGGTAAACCGATATCGCGC
151 TTCTACTGACTCTCCCACTCAACGAAGACAAGACTTTGGCCACTCACCCG
201 GCATTACTATAGCTCGGTGCAGGGAGTCCTCAGCCCCGCGATGGATATTA
251 GGCTGGCCCCTAACCTGCGAGGACATTCAAAGTAGGTTTTGACCGGCATT
301 GCAAGGTCACTGAGGAGAATTTATGATAGCCGCCCATACC
The RandomSeq class also has two properties (id and seq) which has the set/get methods of setSeqID(String arg0), setSeq(String arg0), and getSeqID(), getSeq().
Please note, when a DNA sequence String was generated using the getRandomSeq() method, the sequence need to be assigned to the object using the setSeq(String arg0) method. After that, the formatSeq() method can be used to print out the formatted sequence.
Please create a testing Java program to use this RandomSeq class to create a random DNA sequence and then print it out in a formatted fashion with a specified length for each line.
Note: if you use NotePad to create your project, you can simply copy the RandomSeq.class attached file into the same folder of your testing Java program. If you use Eclipse or NetBeans, you probably need to create an external class folder for your project and then import the RandomSeq.class file into the class folder.
Here is how to add the RandomSeq.class file to your project in NetBeans and Eclipse: (assume the RandomSeq.class file is saved into C:\BIFS618)
NetBeans: Create the project first, and then right click on the Libraries from the Projects window, and select Add JAR/Folder to open the window. Browse to the folder contains the .class file (c:\BIFS618), click open. Now the folder is added to the Libraries, and you can create a RandomSeq object directly in your project.
Eclipse: Create the project first, and then right click on the project to select properties. In the properties window, select Libraries tab, and click on Add External Class Folder to select the folder contains the RandomSeq class file and click OK. Now you can use the RandomSeq class directly in your project.