}
ProbeAcceptor acceptor = (ProbeAcceptor) Class.forName(accClassName).newInstance();
//Check if acceptor requires parameters
if (acceptor instanceof ParameterPlugIn) {
ParameterPlugIn paAcceptor = (ParameterPlugIn) acceptor;
DataDescriptor[] dds = paAcceptor.getDataDescriptors();
if (dds != null) {
for (int d = 0;d<dds.length;d++) {
DataDescriptor dd = dds[d];
String string = props.getProperty("probemaker.acceptor." + dd.getKey());
paAcceptor.setData(dd.getKey(), string);
}
}
}
System.out.println(" Acceptor is: " + acceptor.getClass().getName()); //$NON-NLS-1$
ProbeSelector selector = (ProbeSelector) Class.forName(selClassName).newInstance();
if (selector instanceof ParameterPlugIn) {
ParameterPlugIn paSelector = (ParameterPlugIn) selector;
DataDescriptor[] dds = paSelector.getDataDescriptors();
if (dds != null) {
for (int d = 0;d<dds.length;d++) {
DataDescriptor dd = dds[d];
String string = props.getProperty("probemaker.selector." + dd.getKey());
paSelector.setData(dd.getKey(), string);
}
}
}
System.out.println(" Selector is: " + selector.getClass().getName()); //$NON-NLS-1$
SequenceDBDataReader format = (SequenceDBDataReader) Class.forName(formatClassName).newInstance();
if (format instanceof ParameterPlugIn) {
ParameterPlugIn paFormat = (ParameterPlugIn) selector;
DataDescriptor[] dds = paFormat.getDataDescriptors();
if (dds != null) {
for (int d = 0;d<dds.length;d++) {
DataDescriptor dd = dds[d];
String string = props.getProperty("probemaker.targetInputFormat." + dd.getKey());
paFormat.setData(dd.getKey(), string);
}
}
}
if (outputClassName == null) {
outputClassName = DefaultTextTableFormatter.class.getName();
}
Class<?> outputClass = Class.forName(outputClassName);
TextTableFormatter<Probe> outputformatter = (TextTableFormatter<Probe>) outputClass.newInstance();
if (targetClassName == null) {
System.err.println("ERROR: Must specify a probemaker.targetType"); //$NON-NLS-1$
return;
}
Class<?> targetClass = Class.forName(targetClassName);
SequenceBuilder<? extends ProbeMakerTarget> seqBuilder = (SequenceBuilder<? extends ProbeMakerTarget>) targetClass.getMethod("getSequenceBuilder",(Class[])null).invoke(null,(Object[]) null); //$NON-NLS-1$
System.out.println(" Format is: " + format.getClass().getName()); //$NON-NLS-1$
System.out.println(" Target type is: " + targetClass.getName()); //$NON-NLS-1$
System.out.println(" Output format is: " + outputClass.getName()); //$NON-NLS-1$
TargetInputFormat<? extends ProbeMakerTarget> tif = new DefaultTargetInputFormat("Input format",format,null,seqBuilder,ListSequenceDB.getDefaultBuilder()); //$NON-NLS-1$
System.out.println(" Loading tag libs"); //$NON-NLS-1$
int ti = 0;
List<TagLibrary> libs = new ArrayList<TagLibrary>();
while (props.containsKey("probemaker.taglibrary."+ti)) {
String taglibString = props.getProperty("probemaker.taglibrary."+ti);
String[] split = taglibString.split(":");
byte mode = Byte.parseByte(split[0]);
String libFileName = split[1];
File libFile = new File(libFileName);
if (!libFile.getAbsolutePath().equals(libFile.getPath())) {
libFile = new File(settingsFile.getAbsoluteFile().getParentFile(),libFile.getPath());
}
DefiniteSequenceDB<NucleotideSequence> tagseqs = SequenceIO.readSequenceDB(new FileReader(libFile), new FastaDBFormat<NucleotideSequence>(), null, ListSequenceDB.getDefaultBuilder(),new SimpleDNASequenceBuilder());
TagLibrary lib = new DefaultTagLibrary(tagseqs,"taglib"+ti); //$NON-NLS-1$
lib.setMode(mode);
libs.add(lib);
ti++;
}
TagLibrary[] libraries = libs.toArray(new TagLibrary[libs.size()]);
int[] order = new int[libraries.length];
for (int i = 0;i<order.length;i++) order[i] = i;
TagSettings tagSettings = new DefaultTagSettings(libraries,order);
p.setTagSettings(tagSettings);
System.out.println(" Loading targets"); //$NON-NLS-1$
new TargetIOTask(p,callback,new Reader[] { new FileReader(targetFile) },tif).run();
System.out.println("Done"); //$NON-NLS-1$
File logPath = new File(""); //$NON-NLS-1$
System.out.println("Writing log to: " + logPath); //$NON-NLS-1$
//Probe design settings
boolean append = false;
//Create and start the ProbeDesignerRunner
TagAllocator ta = (TagAllocator) ProbeMakerPlugIn.defaultTagAllocatorClass.newInstance();
TSSConstructor tsc = (TSSConstructor) ProbeMakerPlugIn.defaultTSSConstructorClass.newInstance();
ta.addParameters(s.getDesignParameters());
tsc.addParameters(s.getDesignParameters());
ProbeDesigner pd = new DefaultProbeDesigner(ta);
TSSPairDesigner td = new DefaultTSSPairDesigner(tsc);
NamingScheme namer = new DefaultNamingScheme();
DesignLogWriter log = new TextDesignLogWriter(new FileWriter(new File(logPath, p.getName() + ".designlog")));
ProbeDesignTask runner = pm.getProbeDesignTask(append,false,log,namer,acceptor,selector,pd, td, callback);
runner.timing = true;
runner.verbose = true;
System.out.println("Starting design of " + runner.getMaxProgress() + " probe groups"); //$NON-NLS-1$ //$NON-NLS-2$
runner.run();
//Print result data
System.out.println("Design completed in " + runner.getTotalTime()/1000 + " seconds"); //$NON-NLS-1$ //$NON-NLS-2$
System.out.println("Generated " + runner.getCandidatesGenerated() + " candidates"); //$NON-NLS-1$ //$NON-NLS-2$
DefiniteSequenceDB<Probe> db = pm.project.getProbes();
for (byte b = ProbeMakerConstants.GOOD_QUALITY;b>=ProbeMakerConstants.BAD_QUALITY;b--) {
System.out.println(ProbeSummarizer.getQualityCount(db,b) + " probes of " + //$NON-NLS-1$
ProbeMakerConstants.qualityStrings[b] + " quality"); //$NON-NLS-1$
}
SequenceIO.writeSequenceDB(new FileWriter(outputFile),pm.project.getProbes(),new TextTableDBFormat<Probe>(outputformatter),null);
}
catch (Exception e) {
System.err.println("An exception was caught:\n" + e.getMessage()); //$NON-NLS-1$
e.printStackTrace();
}
catch (Error er) {
System.err.println("An error was caught:\n" + er.getMessage()); //$NON-NLS-1$
er.printStackTrace();
}
}
else if (args[0].equals("-p")) { //$NON-NLS-1$
System.out.println("Running ProbeMaker with project file"); //$NON-NLS-1$
if (args.length < 2) {
System.out.println("Error: No project file specified"); //$NON-NLS-1$
return;
}
try {
ProbeMakerPlugIn pm = new ProbeMakerPlugIn();
ErrorHandler callback = new CommandLineErrorCallback();
//Check for and load the project file
File projectFile = new File(args[1]);
if (!projectFile.exists()) {
System.out.println("Error: Could not find project file: " + args[1]); //$NON-NLS-1$
return;
}
System.out.println("Loading project"); //$NON-NLS-1$
new ProjectXMLIOTask(pm,callback,new FileReader(projectFile)).run();
System.out.println("Done"); //$NON-NLS-1$
//Check for acceptor and selector flags
ProbeAcceptor acceptor = (ProbeAcceptor) ProbeMakerPlugIn.defaultProbeSelectorClass.newInstance();
ProbeSelector selector = (ProbeSelector) ProbeMakerPlugIn.defaultProbeSelectorClass.newInstance();
for (int i = 2;i<args.length;i++) {
if (args[i].equals("-a") || args[i].equals("-A")) { //$NON-NLS-1$ //$NON-NLS-2$
i++;
if (i<args.length) {
acceptor = (ProbeAcceptor) Class.forName(args[i]).newInstance();
//Check if acceptor requires parameters
if (acceptor instanceof ParameterPlugIn) {
ParameterPlugIn paAcceptor = (ParameterPlugIn) acceptor;
DataDescriptor[] params = paAcceptor.getDataDescriptors();
i++;
if (params != null) {
Object[] values = new Object[params.length];
try {
for (int j = 0;j<params.length;i++,j++) {
values[j] = args[i];
}
DataHolderUtils.putOrderedData(values,paAcceptor);
}
catch (ArrayIndexOutOfBoundsException ax) {
System.out.println("Error: Wrong number of acceptor parameters"); //$NON-NLS-1$
return;
}
catch (NumberFormatException ax) {
System.out.println("Error: Wrong number of acceptor parameters"); //$NON-NLS-1$
return;
}
}
}
}
else {
System.out.println("Error: No acceptor argument"); //$NON-NLS-1$
return;
}
}
if (i >= args.length) break;
if (args[i].equals("-s") || args[i].equals("-S")) { //$NON-NLS-1$ //$NON-NLS-2$
i++;
if (i<args.length) {
selector = (ProbeSelector) Class.forName(args[i]).newInstance();
if (selector instanceof ParameterPlugIn) {
ParameterPlugIn paSelector = (ParameterPlugIn) selector;
DataDescriptor[] params = paSelector.getDataDescriptors();
i++;
if (params != null) {
Object[] values = new Object[params.length];
try {
for (int j = 0;j<params.length;i++,j++) {