0

私のコードは次のとおりです。

import java.io.BufferedReader;
import java.io.FileReader;

import org.biojavax.SimpleNamespace;
import org.biojavax.bio.seq.RichSequence;
import org.biojavax.bio.seq.RichSequenceIterator;
import org.biojava.bio.seq.*;
import org.biojava.bio.seq.io.*;
import org.biojava.bio.symbol.*;

public class ReadGES_BJ1_6{
    /* 
     * ReadGES_BJ1_6.java - A pretty simple demo program to read a sequence file
     * with a known format using Biojavax extension found in BJ1.6. 
     * 
     * You only need to provide a file as args[0]
     */
    public static void main(String[] args) {
        BufferedReader br = null;
        SimpleNamespace ns = null;

        try{
            br = new BufferedReader(new FileReader(args[0]));
            ns = new SimpleNamespace("biojava");

            // You can use any of the convenience methods found in the BioJava 1.6 API
            RichSequenceIterator rsi = RichSequence.IOTools.readFastaDNA(br,ns);

            // Since a single file can contain more than a sequence, you need to iterate over
            // rsi to get the information.
            while(rsi.hasNext()){
                RichSequence rs = rsi.nextRichSequence();
                //Sequence seq = stream.nextSequence();
                int gc = 0;
                for (int pos = 1; pos <= rs.length(); ++pos) {
                Symbol sym = rs.symbolAt(pos);
                if (sym == DNATools.g() || sym == DNATools.c())
                ++gc;

                }       

    System.out.println(rs.getName()+"\t"+rs.length()+"\t"+((gc * 100.0) / rs.length())/*+"\t"+rs.seqString()*/);
         //System.out.println(ns);
                /*System.out.println(rs.seqString());
                System.out.println(rs.length());
                System.out.println(((gc * 100.0) / rs.length()));*/

            }
        }
        catch(Exception be){
            be.printStackTrace();
            System.exit(-1);
        }
    }
}

次のように出力されます。

contig00001   586   52.38%
contig00002   554   62.45%

私の質問は、上記の出力を jtable pls help の 3 つの列で正確に表示する方法です。

4

2 に答える 2

1

JTable、JTableの例Object [][]、またはに追加する必要のあるファイル出力に関するチュートリアルをお読みください。Vector<Vector<Object>>

于 2011-06-20T07:08:56.793 に答える
0

TableModel でデータを取得したら、Table Format Renderersを使用して 3 番目の列を % 記号でフォーマットできます。

于 2011-06-20T14:53:42.620 に答える