【问题标题】:how to display data from fasta file in jtable如何在jtable中显示fasta文件中的数据
【发布时间】:2011-06-20 06:57:30
【问题描述】:

我的代码是:

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 的三列中准确显示以上输出 请帮忙?

【问题讨论】:

    标签: java netbeans jtable filereader


    【解决方案1】:

    请阅读有关JTable、JTable examples 的教程以及您必须添加到Object [][]Vector&lt;Vector&lt;Object&gt;&gt; 的文件输出

    【讨论】:

      【解决方案2】:

      一旦您在 TableModel 中获取数据,Table Format Renderers 将帮助您使用 % 符号格式化第三列。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2018-02-04
        • 2020-10-02
        • 1970-01-01
        • 2014-05-06
        • 2013-12-18
        • 2011-07-18
        • 1970-01-01
        相关资源
        最近更新 更多