首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在jtable中显示fasta文件中的数据

如何在jtable中显示fasta文件中的数据
EN

Stack Overflow用户
提问于 2011-06-20 14:57:30
回答 2查看 462关注 0票数 0

我的代码是:

代码语言:javascript
复制
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);
        }
    }
}

它的输出为:

代码语言:javascript
复制
contig00001   586   52.38%
contig00002   554   62.45%

我的问题是如何在jtable pls help中以三列准确地显示上述输出?

EN

回答 2

Stack Overflow用户

发布于 2011-06-20 15:08:57

请阅读有关JTable、JTable examples和您必须添加到Object [][]Vector>的文件输出的教程

票数 1
EN

Stack Overflow用户

发布于 2011-06-20 22:53:43

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6407786

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档