Share on Google+Share on Google+

DNA sequence
3 Answer(s)      6 years and 8 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...


View Answers

August 10, 2010 at 3:25 PM

Hi Friend,

Try the following code:

import java.util.*;

class ShowData implements Comparable {
int id;
String name;
int marks;
String grade;
String address;
public void setId(int id) { = id;
public int getId(){
return id;
public void setName(String 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){
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 - ide;

August 10, 2010 at 3:26 PM


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) {
Iterator itr;
for (itr = list.iterator(); itr.hasNext();) {
String str =;
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];
data[j] = new ShowData();
List l=Arrays.asList(data);
Comparator comparator = Collections.reverseOrder();
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()) {
} catch (Exception e) {
public static void main(String[] args) {
SortFileData data = new SortFileData();

Hope that it will be helpful for you.

August 21, 2012 at 2:46 PM

I found the following Errors .. incompatible types found : java.util.List<ShowData> required: List List l=Arrays.asList(data); ^ cannot find symbol symbol : method sort(List,java.util.Comparator) location: class java.util.Collections Collections.sort(l,comparator); ^ Note: 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
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
Java Spring Hibernate Struts Training What does core Java include? java What are some way to learn Java quickly? Is it required to learn Java before learning Java Script? Is it necessary to learn java script before learning PHP? Are HTML5 and Java Script boosts Java career? Is Java object oriented? Fingerprint application with Java Uninstall Oracle Virtual Box JSON to HashMap Free Java online Training I want example of Control Statement in Java ANSI Color Codes with Python Create a Program that Calculates Input What is difference between JDK,JRE and JVM? How to see ubuntu version on server? How to get Page Source in Selenium (WebDriver) using Java? The path to the driver executable must be set by the webdriver.gecko.driver system property parse data from a link in java Java Program Qns using BlueJ How to fix HAX Kernel Module Is Not Installed error? Installing Audacity Looking for code Logic to check track changes & Coments in MSWord, MSWordx, MSExcel, MSExcelx is ON/OFF Installing JDK on Mac SAX Parser exception ERROR 601 (42P00): Syntax error. Encountered Thread java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory How to install Ubuntu 16.04 LTS? HttpServletRequest cannot be resolved to a type in eclipse - Solved Unhandled event loop exception GC overhead limit exceeded Spring Data jpa with apache phoenix Caused by: java.lang.IllegalArgumentException: Not a host:port pair: PBUF o.a.h.h.z.RecoverableZooKeeper - Possibly transient ZooKeeper, quorum= com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager class not found com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager not found How to download and install Java 8 on Windows? How to uninstall JDK 7? How to install gtk-doc-tools package in Ubuntu? How to install Oracle JDK 8 on Ubuntu? ejabberd_ctl.beam not found - Solved How to convert date to UTC format in Java? How to install autoconf, automake and libtool in Ubuntu 15.10? How to convert current date to mm dd yyyy format in Java? How to convert current date to dd mm yyyy format in Java? How to stop window closing in "internalFrameClosing" event. How to find list of all index in Neo4j? file location SASLError using PLAIN: not-authorized how to convert war file into .exe file using java code


Advertisement null