| 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 |
package dr.app.tools; |
| 27 |
|
| 28 |
import java.io.*; |
| 29 |
import java.util.*; |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
public class SpliceBeastFiles { |
| 42 |
|
| 43 |
public SpliceBeastFiles(String templateFileName, String inputFileStem, String outputFileStem) { |
| 44 |
try { |
| 45 |
List<String> template = new ArrayList<String>(); |
| 46 |
|
| 47 |
BufferedReader reader = new BufferedReader(new FileReader(templateFileName)); |
| 48 |
String line = reader.readLine(); |
| 49 |
while (line != null) { |
| 50 |
template.add(line); |
| 51 |
line = reader.readLine(); |
| 52 |
} |
| 53 |
|
| 54 |
reader.close(); |
| 55 |
|
| 56 |
for (int i = 1; i < 201; i++) { |
| 57 |
String number = (i < 10? "00" : (i < 100? "0" : "")) + i; |
| 58 |
reader = new BufferedReader(new FileReader(inputFileStem + number + ".xml")); |
| 59 |
|
| 60 |
PrintWriter writer = new PrintWriter(outputFileStem + number + ".xml"); |
| 61 |
|
| 62 |
line = reader.readLine(); |
| 63 |
while (line != null && !line.equals("\t<patterns id=\"patterns\" from=\"1\">")) { |
| 64 |
writer.println(line); |
| 65 |
line = reader.readLine(); |
| 66 |
} |
| 67 |
|
| 68 |
for (String line1 : template) { |
| 69 |
if (line1.contains("$stem")) { |
| 70 |
line1 = line1.replace("$stem", "sim" + number); |
| 71 |
} |
| 72 |
writer.println(line1); |
| 73 |
} |
| 74 |
|
| 75 |
writer.close(); |
| 76 |
|
| 77 |
reader.close(); |
| 78 |
} |
| 79 |
} catch (FileNotFoundException e) { |
| 80 |
e.printStackTrace(); |
| 81 |
return; |
| 82 |
} catch (IOException e) { |
| 83 |
e.printStackTrace(); |
| 84 |
return; |
| 85 |
} |
| 86 |
} |
| 87 |
|
| 88 |
public static void main(String[] argv) { |
| 89 |
new SpliceBeastFiles(argv[0], argv[1], argv[2]); |
| 90 |
} |
| 91 |
} |