-
Notifications
You must be signed in to change notification settings - Fork 0
/
DeleteRepeat.java
45 lines (41 loc) · 1.26 KB
/
DeleteRepeat.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package fionaApp;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.HashSet;
public class DeleteRepeat {
public static void main(String[] args) throws IOException {
String folderPath = "D:/PeakAnno/annoSum";
File folder = new File(folderPath);
File[] fileArray = folder.listFiles();
for (int i = 0; i < fileArray.length; i++) {
if (fileArray[i].getAbsolutePath().contains(".bed")) {
File f = fileArray[i];
String IDFile= f.getAbsolutePath().replace(".bed", "SumGeneIDset.bed");
FileWriter fw = new FileWriter(IDFile);
BufferedWriter fbw = new BufferedWriter(fw);
FileReader fr = new FileReader(f);
BufferedReader br = new BufferedReader(fr);
HashSet<String> astr = new HashSet<String>();
String data = br.readLine();
String[] dataArr = null;
while (data != null) {
dataArr = data.split("\t");
astr.add(dataArr[12]);
data = br.readLine();
}
br.close();
Object[] ID = astr.toArray();
for (int j = 0; j < ID.length; j++) {
String IDstr =ID[j].toString();
fbw.write(IDstr);
fbw.newLine();
}
fbw.close();
}
}
}
}