Question: Java file help Please use the Sequence class to design a subclass calledProtein, and override the validSeq() to validate a protein sequence instead of DNA
Java file help
Please use the Sequence class to design a subclass calledProtein, and override the validSeq() to validate a protein sequence instead of DNA sequence. Please reply with the implemented class Protein.class file, and write a test class to test the validSeq() method,
(Sequence.java) file import java.util.regex.Pattern; public class Sequence { //define properties of the sequence class //id -- sequence identifier //type -- type of sequence, DNA, RNA, or Protein //seq -- the sequence private String id; private String type; private String seq; public Sequence(){} public Sequence(String id, String seq){ this.id = id; this.seq = seq; } public Sequence(String id, String type, String seq){ this.id = id; this.type = type; this.seq = seq; } public void setID(String id){ this.id = id; } public String getID(){ return id; } public void setType(String type){ this.type = type; } public String getType(){ return type; } public void setSeq(String seq){ this.seq = seq; } public String getSeq(){ return seq; } public int getSize(){ return seq.length(); } // break a long sequence into chunks public String formatSeq(int len){ String formatedSeq = ""; while (seq.length()> len){ formatedSeq += seq.substring(0, len) + " "; seq = seq.substring(len); } // add the remaining part if (seq.length()>0){ formatedSeq += seq; } return formatedSeq; } public int baseCount(char b) { int count = 0; for (int i= 0; i%s|%s %s ", id, type, seq); } // method for DNA sequence validation public boolean validSeq(){ return Pattern.matches("[ATCG]+", seq); } } Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
