/** * File written by Raphael Champeimont * UMR 7238 Genomique des Microorganismes */ package fr.orsay.lri.varna.models.templates; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.util.ArrayList; import java.util.List; import fr.orsay.lri.varna.factories.RNAFactory; public class BatchBenchmarkPrepare { /** * We assume given directory contains a alignemnt.fasta file, * of which the first sequence is the consensus structure, * and the other sequences are aligned nucleotides. * The principle is to convert it to a set of secondary structure, * using the following rule: * - keep the same nucleotides as in original sequence * - keep base pairs where both bases of the pair are non-gaps in our sequence */ public void benchmarkAllDir(File rootdir) throws Exception { File seqdir = new File(rootdir, "sequences"); if (!seqdir.exists()) { seqdir.mkdir(); } File templateFile = new File(rootdir, "template.xml"); ArrayList seqnames = new ArrayList(); ArrayList sequences = new ArrayList(); BatchBenchmark.readFASTA(new File(rootdir, "alignment.fasta"), seqnames, sequences); BufferedWriter outbufASS = new BufferedWriter(new FileWriter(new File(rootdir, "all_secondary_structures.fasta"))); String consensusSecStr = sequences.get(0); int[] consensusSecStrInt = RNAFactory.parseSecStr(consensusSecStr); List templates = new ArrayList(); for (int i=1; i" + seqname + "\n"); outbuf.write(nt + "\n"); outbuf.write(ss + "\n"); outbuf.close(); outbufASS.write(">" + seqname + "\n"); outbufASS.write(ss + "\n"); templates.add(templateFile); } outbufASS.close(); } public static void main(String[] args) throws Exception { new BatchBenchmarkPrepare().benchmarkAllDir(new File(new File("templates"), "RNaseP_bact_a")); } }