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




Have Programming Question? Ask it here!
 
 
 


Jothiboss
DNA sequence
3 Answer(s)      4 years and a month 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
Exercise - Count Words
Java: Exercise - Count Words Problem Write a method which counts the number of words in a string. Assume that a word is defined as a sequence of letters. Signature public static int countWords(String s) Note
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
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 - 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
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
History of Bioinformatics
. In 1972, Paul berg made the first recombinant DNA molecule using ligase... recombinant DNA organism. In 1973, two important things happened in the field... and Martha Chase proved that the DNA alone carries genetic information
Java - Java Beginners
Java  1.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
Bioinformatics
storage, data warehousing and analyzing the DNA sequences. In Bioinfomatics... software packages. Learn to use sequence analysis and molecular... housing and analysis or DNA sequences and structure of proteins etc
DNALinux Server 0.592 has been released
to be searched. You can insert your own DNA or Protein sequence database into the CD... to public sequence databases (like NCBI). In fact, some countries don't give permission to researchers for public release of sequence data. Among these countries
Bioinformatics
Bioinformatics  **How to read big DNA files of size 1G line by line using java? I have tried using bufferedReader but the whole file which consists of 95000 lines is not being read. Thanks
java error - Java Beginners
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
java - Java Beginners
java  6. 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
java - Java Beginners
java  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
Java applet
Java applet  What is the sequence for calling the methods by AWT for applets
java lab programs - Java Beginners
the implementations. 6. 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
Definition of Bioinformatics
in reading the chain of more than 3 billion base pairs that constitute the DNA molecule... Project that has been determining the sequence of the entire human genome (about 3
Question on reversing word of a sentnce
: ?jack and jill went up a hill? Return Value: ?kcaj dna llij tnew pu a llih
Excel Column change
Excel Column change  How to change sequence of columns in Excel sheet through Java
Algorithm - Java Beginners
Algorithm  (a) Describe the manual procedure, if one has to use the above algorithm and the first element as the pivot to sort the sequence... the algorithm you want to use to sort the sequence. Thanks
hibernate
hibernate  how to execute a sequence(in database) from Hibernate program or java program   Please visit the following link: Hibernate Tutorials
What is workflow
What is workflow  hello, What is workflow in RUP?   hi, A workflow is a sequence of activities that produces a result observable value
Iteration
Iteration  hii, What is an iteration?   hello, The act or an instance of iterating; repetition. time-boxed sequence of activities that results in a release of an executable product
Advertisements
 

 

 

DMCA.com