import edu.duke.*;
import java.io.*;
public class TagFinder{
public String findProtein(String dna){
int start = dna.indexOf("atg");
int stop = dna.indexOf("tag", start +3);
if (start == -1){
return "no starton protein found";
}
if ((stop-start)%3==0){
return dna.substring(start,stop+3);
}
else{
return"not not a protein because of Divisible factor";
}
}
public void testing()
{
String a = "cccatggggtttaaataataataggagagagagagagagttt";
String ap = "atggggtttaaataataatag";
//String a = "sdafsdfsdatgccctagdsfsdfgsffd";
//String ap = "atgccctag";
//String a = "atgcctag";
//String ap = "";
//String a = "ATGCCCTAG";
//String ap = "ATGCCCTAG";
String result = findProtein(a);
if (ap.equals(result)){
System.out.println("sucess for "+ap + "length " + ap.length());
}
else{
System.out.println("mistake for input:"+a);
System.out.println("got:"+result);
System.out.println("not:"+ap);
}
}
public void realTesting(){
DirectoryResource dr = new DirectoryResource();
for (File f : dr.selectedFiles()){
FileResource fr = new FileResource(f);
String s =fr.asString();
System.out.println("read "+s.length()+" character");
String result = findProtein(s);
System.out.println("found "+ result);
}
}
}
import java.io.*;
public class TagFinder{
public String findProtein(String dna){
int start = dna.indexOf("atg");
int stop = dna.indexOf("tag", start +3);
if (start == -1){
return "no starton protein found";
}
if ((stop-start)%3==0){
return dna.substring(start,stop+3);
}
else{
return"not not a protein because of Divisible factor";
}
}
public void testing()
{
String a = "cccatggggtttaaataataataggagagagagagagagttt";
String ap = "atggggtttaaataataatag";
//String a = "sdafsdfsdatgccctagdsfsdfgsffd";
//String ap = "atgccctag";
//String a = "atgcctag";
//String ap = "";
//String a = "ATGCCCTAG";
//String ap = "ATGCCCTAG";
String result = findProtein(a);
if (ap.equals(result)){
System.out.println("sucess for "+ap + "length " + ap.length());
}
else{
System.out.println("mistake for input:"+a);
System.out.println("got:"+result);
System.out.println("not:"+ap);
}
}
public void realTesting(){
DirectoryResource dr = new DirectoryResource();
for (File f : dr.selectedFiles()){
FileResource fr = new FileResource(f);
String s =fr.asString();
System.out.println("read "+s.length()+" character");
String result = findProtein(s);
System.out.println("found "+ result);
}
}
}
No comments:
Post a Comment