Package org.moltools.apps.probemaker.project

Examples of org.moltools.apps.probemaker.project.ProjectXMLIOTask


          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

        ProbeDesignTask runner = pm.getProbeDesignTask(append,false,log,namer,acceptor,selector,new DefaultProbeDesigner(ta), 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$
        }
        new ProjectXMLIOTask(pm,callback,new FileWriter(projectFile.getAbsolutePath() + ".output")).run(); //$NON-NLS-1$

        SequenceIO.writeSequenceDB(new PrintWriter(System.out),pm.project.getProbes(),new TextTableDBFormat<Probe>(new DefaultTextTableFormatter<Probe>()),null);

      }
      catch (Exception e) {
View Full Code Here


    return null;
  }

  /**Get a project export task to use*/
  protected Task getExportProjectTask(final Writer out, final ErrorHandler ecb) {
    return new ProjectXMLIOTask(this, ecb, out);
  }
View Full Code Here

    return new ProjectIOTask(this, ecb, in);
  }

  /**Get a project import task to use*/
  protected Task getLoadProjectTask(final Reader in, final ErrorHandler ecb) {
    return new ProjectXMLIOTask(this, ecb, in);
  }
View Full Code Here

          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();
        //TODO implement command-line TagAllocator/TSSConstructor selection

        ProbeDesignTask runner = pm.getProbeDesignTask(append,false,true,acceptor,selector,new DefaultProbeDesigner(ta), tsc, 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$
        }
        new ProjectXMLIOTask(pm,callback,new FileWriter(projectFile.getAbsolutePath() + ".output")).run(); //$NON-NLS-1$

        SequenceIO.writeSequenceDB(new PrintWriter(System.out),pm.project.getProbes(),new TextTableDBFormat<Probe>(new DefaultTextTableFormatter<Probe>()),null);

      }
      catch (Exception e) {
View Full Code Here

    Task t = pm.getProbeDesignTask(false,true, null, new DefaultNamingScheme(), new GoodFairAcceptor(),new BestQualitySelector(),new DefaultProbeDesigner(new GreedyTagAllocator()),new DefaultTSSPairDesigner(new DefaultTSSConstructor()),new StreamErrorHandler(System.err,true));
    t.run();   
   
    TagAllocationTable tat1 = pm.getProject().getTagAllocationTable();
   
    new ProjectXMLIOTask(pm,null,new FileWriter(f1)).run();
    new ProjectXMLIOTask(pm,null,new FileReader(f1)).run();   
    new ProjectXMLIOTask(pm,null,new FileWriter(f2)).run();
    new ProjectXMLIOTask(pm,null,new FileReader(f2)).run();   
    assertEquals(f1.length(),f2.length());
    TagAllocationTable tat2 = pm.getProject().getTagAllocationTable();
   
    assertTrue(tat1.equals(tat2));
   
    t = pm.getProbeDesignTask(false,true, null, new DefaultNamingScheme(), new GoodFairAcceptor(),new BestQualitySelector(),new DefaultProbeDesigner(new GreedyTagAllocator()),new DefaultTSSPairDesigner(new DefaultTSSConstructor()),null);
    t.run();   

    new ProjectXMLIOTask(pm,null,new FileWriter(f2)).run();
    new ProjectXMLIOTask(pm,null,new FileReader(f2)).run();   
   
    StringReader sr = new StringReader(">PROBE_1 Probe 1\nATCGACGAGCGAC|ACTAGCGAGCGAC|ATCGACGACGGAC|ACTACGAGCGAC\n" + //$NON-NLS-1$
        ">PROBE_2 Probe 2\nATCGACGAGCGAC|ACTAGCGAGCGAC|ATCGACGACGGAC|ACTACGAGCGAC"); //$NON-NLS-1$
   
    pm.importProbes(true,sr,new IDAndNameFastaDBFormat<Probe>());  
   
    new ProjectXMLIOTask(pm,null,new FileWriter(f2)).run();
    new ProjectXMLIOTask(pm,null,new FileReader(f2)).run();   
   
    f1.deleteOnExit();
    f2.deleteOnExit();
   
  }
View Full Code Here

    pm.getProbeDesignTask(false, false, null, new DefaultNamingScheme(), new AllAcceptor(),new NoSelector(), pd, new DefaultTSSPairDesigner(new DefaultTSSConstructor()), new StreamErrorHandler(System.out,true)).run();
       
//  Store to project file
    File f = new File("temp.pmp"); //$NON-NLS-1$
    f.deleteOnExit();
    new ProjectXMLIOTask(pm,null,new FileWriter(f)).run();
   
    //Read project
    new ProjectXMLIOTask(pm,null,new FileReader(f)).run();
   
    //Add new target
    pm.getProject().getTargets().clear();
    pm.getProject().getTargets().addSequence(t2);
   
//  Design with append       
    pm.getProbeDesignTask(true, false, null, new DefaultNamingScheme(), new AllAcceptor(), new NoSelector(), pd, new DefaultTSSPairDesigner(new DefaultTSSConstructor()), new StreamErrorHandler(System.out,true)).run();
   
        
//  Store to project file
    f = new File("temp2.pmp"); //$NON-NLS-1$
    f.deleteOnExit();
    new ProjectXMLIOTask(pm,eh,new FileWriter(f)).run();
   
    //Read project
    new ProjectXMLIOTask(pm,eh,new FileReader(f)).run();
      
    pm.getProject().getTargets().clear();
    pm.getProject().getTargets().addSequence(t1);
    pm.getProject().getTargets().addSequence(t2);
   
    db = new ListSequenceDB<NucleotideSequence>();
    db.addSequence(new SimpleNucleotideSequence("Tag 1","AAAAAAAAAA")); //$NON-NLS-1$ //$NON-NLS-2$
    db.addSequence(new SimpleNucleotideSequence("Tag 2","TTTTTTTTTT")); //$NON-NLS-1$ //$NON-NLS-2$
    db.addSequence(new SimpleNucleotideSequence("Tag 3","AAAAAAAAAA")); //$NON-NLS-1$ //$NON-NLS-2$
    db.addSequence(new SimpleNucleotideSequence("Tag 4","TTTTTTTTTT")); //$NON-NLS-1$ //$NON-NLS-2$
    tl = new DefaultTagLibrary(db,"Unique"); //$NON-NLS-1$
    tl.setMode(TagLibrary.USE_PER_GROUP);
   
    pm.getProject().setTagSettings(new DefaultTagSettings(new TagLibrary[] {tl, tl}));
   
//  Design
    pm.getProbeDesignTask(false, true, null, new DefaultNamingScheme(), new AllAcceptor(), new NoSelector(), pd, new DefaultTSSPairDesigner(new DefaultTSSConstructor()), eh).run();   

    TagAllocationTable tat1 = pm.getProject().getTagAllocationTable();
   
//  Store to project file
    f = new File("temp3.pmp"); //$NON-NLS-1$
    f.deleteOnExit();
    new ProjectXMLIOTask(pm,eh,new FileWriter(f)).run();
   
    //Read project
    new ProjectXMLIOTask(pm,eh,new FileReader(f)).run();
   
    TagAllocationTable tat2 = pm.getProject().getTagAllocationTable();
   
    assertEquals(tat1, tat2);
   
View Full Code Here

    return null;
  }

  /**Get a project export task to use*/
  protected Task getExportProjectTask(final Writer out, final ErrorHandler ecb) {
    return new ProjectXMLIOTask(this, ecb, out);
  }
View Full Code Here

    return new ProjectIOTask(this, ecb, in);
  }

  /**Get a project import task to use*/
  protected Task getLoadProjectTask(final Reader in, final ErrorHandler ecb) {
    return new ProjectXMLIOTask(this, ecb, in);
  }
View Full Code Here

    return null;
  }

  /**Get a project export task to use*/
  protected Task getExportProjectTask(final Writer out, final ErrorHandler ecb) {
    return new ProjectXMLIOTask(this, ecb, out);
  }
View Full Code Here

    return new ProjectIOTask(this, ecb, in);
  }

  /**Get a project import task to use*/
  protected Task getLoadProjectTask(final Reader in, final ErrorHandler ecb) {
    return new ProjectXMLIOTask(this, ecb, in);
  }
View Full Code Here

TOP

Related Classes of org.moltools.apps.probemaker.project.ProjectXMLIOTask

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.