1
MAFファイルの突然変異の数を数えようとしています。私はもともとPythonでこのコードを書いていましたが、それは完璧に機能しましたが、Javaに変換すると機能が停止しました。出力ファイルでは、突然変異の数は常に1です。私はここで間違って何をしていますか?ここで .mafファイルで突然変異が起こる回数をカウントする
package dev.suns.bioinformatics;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.PrintWriter;
public class Main {
static String filePath = "C:/Users/Matthew/Bioinformatics/Data Files/DLBC.maf";
static String fileName = "DLBC_Info.txt";
public static void main(String[] args){
createFile(filePath, fileName);
}
public static void createFile(String filePath, String fileName){
BufferedReader br = null;
String line = "";
String delimiter = "\t";
String geneSymbol = "";
String newGene = "";
int count;
try {
PrintWriter writer = new PrintWriter(fileName);
br = new BufferedReader(new FileReader(filePath));
writer.println("Gene" + "\t" + "Mutations" + "\n");
br.readLine();
while ((line = br.readLine()) != null){
String[] splitFile = line.split(delimiter);
newGene = splitFile[0];
if(geneSymbol == ""){
geneSymbol = newGene;
}
else if(newGene == geneSymbol){
#This is here I am having trouble. I have this if-statement to check if the gene appears more than once in the .maf file, but nothing is ever entering this.
count++;
}
else{
count++;
writer.println(geneSymbol + "\t" + count + "\n");
geneSymbol = newGene;
count=0;
}
}
writer.close();
}catch(Exception e){
e.printStackTrace();
}
}
}
は、ファイルの最初の数行が
遺伝子変異のように見えるものです
A1CF 1
A2M 1
A2M 1
A2ML1 1
A4GALT 1
AADAC 1
AADACL3 1
AAED1 1
AAGAB 1
AAGAB 1
AARD 1
AARS2 1
JavaでAARS2 1
AARS2 1
ありがとうございました!それはうまくいった! –
答えがあれば受け入れてください。下の矢印をクリックしてください。だから、この質問が答えられたことは人々には明らかです。 – denis
申し訳ありません、私は新しいstackoverflowです –