很多生物信息学工作从读取测序仪的DNA片断开始.常用的是ABI测序仪的输出.Biojava包括了一个ABITrace类能够解析ABITrace文件或URL或者是存储他的byte[]数组.下面的程序由Matthew Pocock贡献.它从ABITrace文件中创建Biojava序列.
Biojava1.3提供了更通用的色谱接口,支持ABI和SCF文件.下面的程序使用了这个接口.
读取ABI
[code lang="java"]
import java.io.*;
import org.biojava.bio.*;
import org.biojava.bio.program.abi.*;
import org.biojava.bio.seq.*;
import org.biojava.bio.seq.impl.*;
import org.biojava.bio.seq.io.*;
import org.biojava.bio.symbol.*;
public class Trace2Seq {
public static void main(String[] args)
throws Exception {
File traceFile = new File(args[0]);
//序列名
String name = traceFile.getName();
//读取trace
ABITrace trace = new ABITrace(traceFile);
//抽取标志
SymbolList symbols = trace.getSequence();
//创建完整的序列
Sequence seq = new SimpleSequence(symbols, name, name, Annotation.EMPTY_ANNOTATION);
//输出到标准输出
SeqIOTools.writeFasta(System.out, seq);
}
}
[/code]
通用方案
[code lang="java"]
import java.io.*;
import org.biojava.bio.*;
import org.biojava.bio.chromatogram.*;
import org.biojava.bio.seq.*;
import org.biojava.bio.seq.impl.*;
import org.biojava.bio.seq.io.*;
import org.biojava.bio.symbol.*;
public class Trace2Seq {
public static void main(String[] args)
throws Exception {
File traceFile = new File(args[0]);
//序列名
String name = traceFile.getName();
//读取trace
Chromatogram trace = ChromatogramFactory.create(traceFile);
//抽取标志
SymbolList symbols = ChromatogramTools.getDNASequence(trace);
//创建完整序列
Sequence seq = new SimpleSequence(symbols, name, name, Annotation.EMPTY_ANNOTATION);
//输出到标准输出
SeqIOTools.writeFasta(System.out, seq);
}
}
[/code]