//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++) {
values[j] = args[i];
}
DataHolderUtils.putOrderedData(values,paSelector);
}
catch (ArrayIndexOutOfBoundsException ax) {
System.out.println("Error: Wrong number of selector parameters"); //$NON-NLS-1$
return;
}
catch (NumberFormatException ax) {
System.out.println("Error: Wrong number of selector parameters"); //$NON-NLS-1$
return;
}
}}
}
else {
System.out.println("Error: No selector argument"); //$NON-NLS-1$
return;
}
}
}
//Probe design settings
boolean append = false;
System.out.println("Using acceptor: " + acceptor.getClass()); //$NON-NLS-1$
System.out.println("Using selector: " + selector.getClass()); //$NON-NLS-1$
File logPath = new File(""); //$NON-NLS-1$
System.out.println("Writing log to: " + logPath); //$NON-NLS-1$
//Create and start the ProbeDesignerRunner
TagAllocator ta = (TagAllocator) ProbeMakerPlugIn.defaultTagAllocatorClass.newInstance();
TSSConstructor tsc = (TSSConstructor) ProbeMakerPlugIn.defaultTSSConstructorClass.newInstance();
TSSPairDesigner td = new DefaultTSSPairDesigner(tsc);
NamingScheme namer = new DefaultNamingScheme();
DesignLogWriter log = new TextDesignLogWriter(new FileWriter(new File(logPath, pm.getProject().getName() + ".designlog")));
//TODO implement command-line TagAllocator/TSSConstructor selection