DNA sequence

DNA sequence

Write a java program to read a file that contains DNA sequences of arbitrary length one per line (note that each DNA sequence is just a String). Your program should sort the sequences in descending order with respect to the number of 'TATA' sub-sequences present. Finally write the sequences in sorted order into another file.




Thanks in ADVANCE...
View Answers

August 10, 2010 at 3:25 PM

Hi Friend,

Try the following code:

import java.io.*;
import java.util.*;

class ShowData implements Comparable {
int id;
String name;
int marks;
String grade;
String address;
public void setId(int id) {
this.id = id;
}
public int getId(){
return id;
}
public void setName(String name){
this.name = name;
}
public String getName() {
return name;
}
public void setMarks(int marks) {
this.marks = marks;
}
public int getMarks() {
return marks;
}
public void setGrade(String grade) {
this.grade = grade;
}
public String getGrade() {
return grade;
}
public void setAddress(String address){
this.address=address;
}
public String getAddress(){
return address;
}
public int compareTo(Object Student) throws ClassCastException {
if (!(Student instanceof ShowData))
throw new ClassCastException("Error");
int ide = ((ShowData) Student).getId();
return this.id - ide;
}
}

August 10, 2010 at 3:26 PM

continue..

public class SortFileData {
SortFileData() {
int j = 0;
ShowData data[] = new ShowData[5];
try {
FileInputStream fstream = new FileInputStream("C:/school.txt");
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
ArrayList list = new ArrayList();
while ((strLine = br.readLine()) != null) {
list.add(strLine);
}
Iterator itr;
for (itr = list.iterator(); itr.hasNext();) {
String str = itr.next().toString();
String[] splitSt = str.split(" ");
String id = "", name = "", marks = "", grade = "",address="";
for (int i = 0; i < splitSt.length; i++) {
id = splitSt[0];
name = splitSt[1];
marks = splitSt[2];
grade = splitSt[3];
address=splitSt[4];
}
data[j] = new ShowData();
data[j].setId(Integer.parseInt(id));
data[j].setName(name);
data[j].setMarks(Integer.parseInt(marks));
data[j].setGrade(grade);
data[j].setAddress(address);
j++;
}
Arrays.sort(data);
List l=Arrays.asList(data);
Comparator comparator = Collections.reverseOrder();
Collections.sort(l,comparator);
File file = new File("C:/new.txt");
FileWriter fw = new FileWriter(file, true);
BufferedWriter out = new BufferedWriter(fw);
System.out.println("********Sorted by id********");
String strVal = "";
for (int i = 0; i < data.length; i++) {
ShowData show = data[i];
int no = show.getId();
String name = show.getName();
int marks = show.getMarks();
String grade = show.getGrade();
String address=show.getAddress();
System.out.println(no + " " + name + " " + marks + " " + grade+" "+address);
String d = no + " " + name + " " + marks + " " + grade+" "+address;
ArrayList al = new ArrayList();
al.add(d + "\n");
Iterator itr1 = al.iterator();
while (itr1.hasNext()) {
out.write(itr1.next().toString());
out.newLine();
}
}
out.close();
} catch (Exception e) {
}
}
public static void main(String[] args) {
SortFileData data = new SortFileData();
}
}

Hope that it will be helpful for you.
Thanks

August 21, 2012 at 2:46 PM

I found the following Errors ..

SortFileData.java:81: incompatible types found : java.util.List<ShowData> required: List List l=Arrays.asList(data); ^ SortFileData.java:83: cannot find symbol symbol : method sort(List,java.util.Comparator) location: class java.util.Collections Collections.sort(l,comparator); ^ Note: SortFileData.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details.

2 errors









Related Tutorials/Questions & Answers:
DNA sequence - Java Beginners
DNA sequence  Write a java program to read a file that contains DNA sequences of arbitrary length one per line (note that each DNA sequence is just a String). Your program should sort the sequences in descending order
Version of dna>dna dependency
List of Version of dna>dna dependency
Advertisements
Version of dna>dna-api dependency
List of Version of dna>dna-api dependency
Version of dna>dna-impl dependency
List of Version of dna>dna-impl dependency
Version of dna>dna-tools dependency
List of Version of dna>dna-tools dependency
Artifacts of dna
List of Artifacts of dna maven depenency
Version of dna>dna-tools-plugin dependency
List of Version of dna>dna-tools-plugin dependency
Version of dna>maven-dna-plugin dependency
List of Version of dna>maven-dna-plugin dependency
Maven Repository/Dependency: dna | dna
Maven Repository/Dependency of Group ID dna and Artifact ID dna. Latest version of dna:dna dependencies. # Version Release Date 1 1.1-rc1 10 Aug 2016
Maven Repository/Dependency: dna | dna
Maven Repository/Dependency of Group ID dna and Artifact ID dna. Latest version of dna:dna dependencies. # Version Release Date 1 1.1-rc1 10 Aug 2016
ModuleNotFoundError: No module named 'dna'
ModuleNotFoundError: No module named 'dna'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'dna' How to remove the ModuleNotFoundError: No module named 'dna' error
Maven Dependency dna >> 1.0
You should include the dependency code given in this page to add Maven Dependency of dna >> dna version1.0 in your project
Maven Dependency dna >> 1.1
You should include the dependency code given in this page to add Maven Dependency of dna >> dna version1.1 in your project
Maven Dependency dna >> 1.1-rc1
You should include the dependency code given in this page to add Maven Dependency of dna >> dna version1.1-rc1 in your project
Maven Dependency dna >> 1.1-rc2
You should include the dependency code given in this page to add Maven Dependency of dna >> dna version1.1-rc2 in your project
Maven Repository/Dependency: dna | dna-tools
Maven Repository/Dependency of Group ID dna and Artifact ID dna-tools. Latest version of dna:dna-tools dependencies. # Version Release Date 1 20031016.083103 27 Apr
Maven Repository/Dependency: dna | dna-impl
Maven Repository/Dependency of Group ID dna and Artifact ID dna-impl. Latest version of dna:dna-impl dependencies. # Version Release Date 1 1.1-rc4-dev 10 Aug 2016
Maven Repository/Dependency: dna | dna-api
Maven Repository/Dependency of Group ID dna and Artifact ID dna-api. Latest version of dna:dna-api dependencies. # Version Release Date You can read more at: Maven Tutorials
Maven Repository/Dependency: dna | dna-tools
Maven Repository/Dependency of Group ID dna and Artifact ID dna-tools. Latest version of dna:dna-tools dependencies. # Version Release Date 1 20031016.083103 27 Apr
Maven Repository/Dependency: dna | dna-impl
Maven Repository/Dependency of Group ID dna and Artifact ID dna-impl. Latest version of dna:dna-impl dependencies. # Version Release Date 1 1.1-rc4-dev 10 Aug 2016
Maven Repository/Dependency: dna | dna-api
Maven Repository/Dependency of Group ID dna and Artifact ID dna-api. Latest version of dna:dna-api dependencies. # Version Release Date You can read more at: Maven Tutorials
Maven Dependency dna-api >> 1.0
You should include the dependency code given in this page to add Maven Dependency of dna >> dna-api version1.0 in your project
Maven Dependency dna-api >> 1.1
You should include the dependency code given in this page to add Maven Dependency of dna >> dna-api version1.1 in your project
Maven Dependency dna-api >> 1.1-rc1
You should include the dependency code given in this page to add Maven Dependency of dna >> dna-api version1.1-rc1 in your project
Maven Dependency dna-api >> 1.1-rc2
You should include the dependency code given in this page to add Maven Dependency of dna >> dna-api version1.1-rc2 in your project
Maven Dependency dna-impl >> 1.0
You should include the dependency code given in this page to add Maven Dependency of dna >> dna-impl version1.0 in your project
Maven Dependency dna-impl >> 1.1
You should include the dependency code given in this page to add Maven Dependency of dna >> dna-impl version1.1 in your project
Maven Dependency dna-impl >> 1.1-rc1
You should include the dependency code given in this page to add Maven Dependency of dna >> dna-impl version1.1-rc1 in your project
Maven Dependency dna-impl >> 1.1-rc2
You should include the dependency code given in this page to add Maven Dependency of dna >> dna-impl version1.1-rc2 in your project
Maven Dependency dna-impl >> 20031005.014103
You should include the dependency code given in this page to add Maven Dependency of dna >> dna-impl version20031005.014103 in your project
Maven Dependency dna-tools >> 1.1
You should include the dependency code given in this page to add Maven Dependency of dna >> dna-tools version1.1 in your project
Maven Dependency dna-tools >> 1.1-rc1
You should include the dependency code given in this page to add Maven Dependency of dna >> dna-tools version1.1-rc1 in your project
Maven Dependency dna-tools >> 1.1-rc2
You should include the dependency code given in this page to add Maven Dependency of dna >> dna-tools version1.1-rc2 in your project
Maven Dependency dna-tools >> 20031016.074359
You should include the dependency code given in this page to add Maven Dependency of dna >> dna-tools version20031016.074359 in your project
Maven Dependency dna-tools >> 20031016.083103
You should include the dependency code given in this page to add Maven Dependency of dna >> dna-tools version20031016.083103 in your project
Maven Repository/Dependency: dna | dna-tools-plugin
Maven Repository/Dependency of Group ID dna and Artifact ID dna-tools-plugin. Latest version of dna:dna-tools-plugin dependencies. # Version Release Date 1 1.1-rc2 04
Maven Repository/Dependency: dna | maven-dna-plugin
Maven Repository/Dependency of Group ID dna and Artifact ID maven-dna-plugin. Latest version of dna:maven-dna-plugin dependencies. # Version Release Date 1 1.1 04 Apr
Maven Repository/Dependency: dna | maven-dna-plugin
Maven Repository/Dependency of Group ID dna and Artifact ID maven-dna-plugin. Latest version of dna:maven-dna-plugin dependencies. # Version Release Date 1 1.1 04 Apr
Maven Repository/Dependency: dna | dna-tools-plugin
Maven Repository/Dependency of Group ID dna and Artifact ID dna-tools-plugin. Latest version of dna:dna-tools-plugin dependencies. # Version Release Date 1 1.1-rc2 04
ModuleNotFoundError: No module named 'sequence'
ModuleNotFoundError: No module named 'sequence'  Hi, My Python... 'sequence' How to remove the ModuleNotFoundError: No module named 'sequence... to install padas library. You can install sequence python with following
Processing Sequence of DispatcherServlet
In this section, you will get to know about the processing sequence of DispatcherServlet
ModuleNotFoundError: No module named 'degenerate-dna'
ModuleNotFoundError: No module named 'degenerate-dna'  Hi, My... named 'degenerate-dna' How to remove the ModuleNotFoundError: No module named 'degenerate-dna' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'elio-dna'
ModuleNotFoundError: No module named 'elio-dna'  Hi, My Python... 'elio-dna' How to remove the ModuleNotFoundError: No module named 'elio-dna... to install padas library. You can install elio-dna python with following
ModuleNotFoundError: No module named 'mooda-dna'
ModuleNotFoundError: No module named 'mooda-dna'  Hi, My Python... 'mooda-dna' How to remove the ModuleNotFoundError: No module named 'mooda-dna' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'degenerate-dna'
ModuleNotFoundError: No module named 'degenerate-dna'  Hi, My... named 'degenerate-dna' How to remove the ModuleNotFoundError: No module named 'degenerate-dna' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'dna-designer'
ModuleNotFoundError: No module named 'dna-designer'  Hi, My Python... 'dna-designer' How to remove the ModuleNotFoundError: No module named 'dna-designer' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'easy-dna'
ModuleNotFoundError: No module named 'easy-dna'  Hi, My Python... 'easy-dna' How to remove the ModuleNotFoundError: No module named 'easy-dna... to install padas library. You can install easy-dna python with following
ModuleNotFoundError: No module named 'elio-dna'
ModuleNotFoundError: No module named 'elio-dna'  Hi, My Python... 'elio-dna' How to remove the ModuleNotFoundError: No module named 'elio-dna... to install padas library. You can install elio-dna python with following
Maven Dependency dna-tools-plugin >> 1.1-rc1
You should include the dependency code given in this page to add Maven Dependency of dna >> dna-tools-plugin version1.1-rc1 in your project
Maven Dependency dna-tools-plugin >> 1.1-rc2
You should include the dependency code given in this page to add Maven Dependency of dna >> dna-tools-plugin version1.1-rc2 in your project

Ads