【发布时间】:2015-04-13 15:44:38
【问题描述】:
我试图将在最后一组括号“genesym”之间出现的字符串命名。到目前为止,我正在用制表符替换每个括号的最后一次出现。在这些函数之间,我想命名现有的字符串基因符号。
我知道这是一个 Scanner 功能,但这是我知道的唯一方式。
import java.lang.*;
import java.io.*;
public class TESTING
{
public static void main(String[] args)
{
try {
BufferedReader br = new BufferedReader(new FileReader("human.rna.fna"));
BufferedWriter bw = new BufferedWriter(new FileWriter("FormattedHumanRNA"));
String line
String genesym;
while ((line = br.readLine()) != null) {
if (line.startsWith(">")) {
// Replaces the last set of parenthesis with a tab character
int openbracket = line.lastIndexOf("(");
line = new StringBuilder(line)
.replace(openbracket, openbracket + 1, "\t")
.toString();
**genesym = br.nextString();**
// Replaces the last close parenthesis with a tab character
int closebracket = line.lastIndexOf(")");
line = new StringBuilder(line)
.replace(closebracket, closebracket + 1, "\t")
.toString();
} else {
line = line.replaceAll ("\n", "");
}
bw.write(genesym + " : " + line);
}
br.close();
bw.close();
} catch(IOException e) {
e.printStackTrace(System.err);
}
}
}
示例:(我的数据比这大得多,大约 100 万行)
输入文件:
>365 (LOC1), long non-coding RNA AGCGTCT
>22 (1*split3**) (FLJ), long RNA AAAATC
>13 (RTV), RNA ATGCG
想要的输出:
LOC1 : >365 LOC1 , long non-coding RNA AGCGTCT
FLJ : >22 (1*split3**) FLJ , long RNA AAAATC
RTV : >13 RTV ,RNA ATGCG
【问题讨论】:
-
你的问题不清楚。您能否包含您正在阅读的输入文件以及您希望输出的内容?