Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Jothiboss
DNA sequence
3 Answer(s)      4 years and 5 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...

Advertisement
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
Processing Sequence of DispatcherServlet
In this section, you will get to know about the processing sequence of DispatcherServlet
Advertisements
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
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
Sequence number to generate daily starting with 1
Sequence number to generate daily starting with 1  Sir, I am creating a bill report Application..I want to generate a sequence number for bill that is starting from 1.and if date changes the sequence number again starts with 1
Counting the highest sequence of zeros and one's - Java Beginners
Counting the highest sequence of zeros and one's  Count the highest sequence value of '0's and '1's. for a given string with zeroes and ones. Input: You should ask user to enter any bit string with zeros and ones sequence
MX Sequence Effect in Flex4
MX Sequence Effect in Flex4: The Sequence effect is used to play multiple effects one after the other according they are added. The tag of Sequence Effect is <mx:Sequence>. In this example you can see how we can use Sequence
Tab sequence problem with Radio buttons - JSP-Servlet
Tab sequence problem with Radio buttons  Hi, I have membership... button) courier delivery courier(radio button) currently tab sequence going from 1 year radiobutton to courier button but tab sequence has to go as from 1
how to use sequence as a generator class in hibernate for ms sql
how to use sequence as a generator class in hibernate for ms sql  Hi deepak, I have following requirement, I have to use sequence as a generator class for ms sql database. Do we need to create an sequence in mssql prior
Biological Databases Links
. Biological Database contains the sequence data of DNA, RNA etc.. These database... sequence files, many of them with annotation and results of our analysis
Bioinformatics Resources on the Web
/EMBL and NCBI/GenBank.  DNA sequence records organismic evolution more... databases    General Nucleotide Sequence Databases Some general nucleotide sequence databases   Specific Human
Read a string and reverse it and then print in alphabetical order.
is a contiguous sequence of symbols or values, such as a character string (a sequence of characters) or a binary digit string (a sequence of binary values). In the example
Java Escape Sequences
Description: In java any character that is preceded by a backslash (\) is known as escape sequence, which has special meaning for the compiler. Following are list of Java escape sequences Escape Sequence Meaning \t
Application of Bioinformatics in various Fields
Application of Bioinformatics in various Fields       Bioinformatics is the use of IT in biotechnology for the data storage, data warehousing and analyzing the DNA
String Length
String Length          In java, Strings are objects that belong to class java.lang.String. A string is a sequence of simple characters. We can do many
String in Action Script3
.style1 { font-size: medium; } String in Action Script3:- String is a sequence of letters, numbers and other characters binding together in a single value. String Class is a data type, we have created a variable that have
String Functions In Java
of every characters. It compares the sequence of characters of Strings... value of every characters. It compares the sequence of characters of Strings...(CharSequence s) : This method is used to check whether the given sequence
List In Java
in proper sequence. Syntax : Iterator iterator()   int lastIndexOf(Object... that contains all the elements in proper sequence. Syntax : Object[] toArray... to an array that contains all the elements in proper sequence. Syntax : T
Mysql Date Literal
Mysql Date Literal       A string is a sequence collection of bytes or characters, enclosed between a single quote (?'?) or double quote (?"?) characters.  Examples: 
Write a method which will remove any given character from a string?
. In this tutorial we have used StringBuilder is a mutable sequence of character. It is used... argument. It checks the character you want to remove in the string in a sequence...(char)). Now the character in this string is appended to the character sequence
JavaScript method fromCharCode()
sequence of Unicode character values.  Its Syntax... example, we have used this method which translate the specified sequence of Unicode
Character Cases Ignoring case sensitiveness in java
that ignores cases, it only compare the character's  sequence... these cases but it compares  the sequence of characters in the given string
JAVA - Java Beginners
JAVA  how to compile the DNA Sequence Question and what are the the files should be created while compiling becoz it is not compiling its makes the following line to be appeared while compiling D:\JAVA>javac
Linear search in java
Linear search in java In this section we will  know, what is linear search and how linear works. Linear search is also known as "sequential search",  by sequential it means it searches the element in sequence
Java Compilation - Java Beginners
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
BioInformatics Tools
is a general purpose multiple sequence alignment program for DNA or proteins... Structural Analysis Sequence Analysis Homology and Similarity Tools... -whether they are DNA sequences or bristle patterns on a fly's nose
Overview of Bioinformatics
advances in DNA sequence analysis, the attention of many researchers is now... of genetic and protein sequence data. Bioinformatics has been defined... of DNA structure and function, gene and protein expression, protein production
Advertisements
 

 

 

DMCA.com