Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training  
 

DNA sequence

Ads

 
 

Share on Google+Share on Google+

Jothiboss
DNA sequence
3 Answer(s)      6 years and 11 months ago
Posted in : Java Beginners
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...
Ads
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

Ads









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
Processing Sequence of DispatcherServlet
In this section, you will get to know about the processing sequence of DispatcherServlet
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
HIbernate call for sequence - Hibernate
HIbernate call for sequence  I have created a sequence in oracle table. Now how to access this in java class through hibernate from dual table i am... the sequence using dual table. Thanks in advance
Sequence generator problem - JDBC
Sequence generator problem  Dear sir, I have created one table by name massemailsendingdetails. CREATE TABLE MASSEMAILDETAILS( ID...) ); Then i created a sequence generator for an id as follows CREATE SEQUENCE
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-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 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-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
Wraps a character sequence into a buffer.
Wraps a character sequence into a buffer. In this tutorial you will see how to wraps a character sequence into a buffer. Here in this example a string variable is having a sequence of character which is further wrapped into a buffer
Define sequence generated primary key in hibernate
Define sequence generated primary key in hibernate  How to define sequence generated primary key in hibernate?   Use value "sequence...="java.lang.Long"> <generator class="sequence"> <param name