Package org.moltools.apps.probemaker.design

Examples of org.moltools.apps.probemaker.design.DefaultNamingScheme


        0,
        proj.getTargets().size(),
        2,
        ecb);
   
    namer = new DefaultNamingScheme();
    project = proj;
    targets = project.getTargets();
    probes = project.getProbes();

    //Create a new log file
View Full Code Here


        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

        ProbeDesignTask runner = pm.getProbeDesignTask(append,false,log,namer,acceptor,selector,new DefaultProbeDesigner(ta), td, callback);
        runner.timing = true;
View Full Code Here

  }
   
  public void testProjectIO() throws IOException, SequenceFormatException, DuplicateIDException {
    File f1 = new File("IOTest.prx"); //$NON-NLS-1$
    File f2 = new File("IOTest2.prx"); //$NON-NLS-1$
    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();   
   
View Full Code Here

   
    pm.getProject().setTagSettings(new DefaultTagSettings(new TagLibrary[] {tl}));
   
    //Design
    ProbeDesigner pd = new DefaultProbeDesigner(new PairwiseTagAllocator());
    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);
   
//  Design
    pd = new DefaultProbeDesigner(new PairwiseTagAllocator());
    pm.getProbeDesignTask(false, false, null, new DefaultNamingScheme(), new AllAcceptor(), new NoSelector(), pd, new DefaultTSSPairDesigner(new DefaultTSSConstructor()), eh).run();           
   
    new ProbeAnalysisTask(pm.getProject(),null).run();
  }
View Full Code Here

            0,
            proj.getTargets().size(),
            2,
            ecb);

    namer = new DefaultNamingScheme();
    project = proj;
    targets = project.getTargets();
    probes = project.getProbes();
    this.acc = acc;
    this.sel = sel;
View Full Code Here

           
    proj.getTargets().addSequence(t1);
    proj.setTagSettings(new DefaultTagSettings(new TagLibrary[] { tags }));
   
//  Design without test
    pm.getProbeDesignTask(false, true, null, new DefaultNamingScheme(), new AllAcceptor(),new NoSelector(), new DefaultProbeDesigner(new PairwiseTagAllocator()), new DefaultTSSPairDesigner(new DefaultTSSConstructor()), new StreamErrorHandler(System.out,true)).run();   
    Probe p = proj.getProbes().getSequenceAt(0);   
    assertTrue("Hyb. interference, 0 messages expected, " + ProbeMakerPropertyUtils.getAllMessages(p).size() + " generated.",ProbeMakerPropertyUtils.getAllMessages(p).size() == 0); //$NON-NLS-1$ //$NON-NLS-2$
   
   
//  Design again with test
    proj.getSettings().addCandidateModuleStage1(new DefaultHybInterferenceModule());   
   
    pm.getProbeDesignTask(false, true, null, new DefaultNamingScheme(), new AllAcceptor(),new NoSelector(), new DefaultProbeDesigner(new PairwiseTagAllocator()), new DefaultTSSPairDesigner(new DefaultTSSConstructor()), new StreamErrorHandler(System.out,true)).run();   
    p = proj.getProbes().getSequenceAt(0);   
    assertTrue("Hyb. interference, 2 messages expected, " + ProbeMakerPropertyUtils.getAllMessages(p).size() + " generated.",ProbeMakerPropertyUtils.getAllMessages(p).size() == 2);     //$NON-NLS-1$ //$NON-NLS-2$
   
  }
View Full Code Here

  }
  
 
  protected void doTest(TSSConstructor tsc, String expect5, String expect3) throws ClusterException {
    ProbeDesigner pd = new DefaultProbeDesigner(new GreedyTagAllocator());
    ProbeDesignTask task = pm.getProbeDesignTask(false, true, null, new DefaultNamingScheme(), new GoodAcceptor(), new NoSelector(), pd, new DefaultTSSPairDesigner(tsc), new StreamErrorHandler(System.out,true));
    task.run();
   
    Probe p = proj.getProbes().getSequenceAt(0);
    TSSPair pair = p.getTSSPair();
   
View Full Code Here

    lib1.addSequence(new SimpleNucleotideSequence("TAG_A","AAAAAAAAAAAAA")); //$NON-NLS-1$ //$NON-NLS-2$
    lib1.addSequence(new SimpleNucleotideSequence("TAG_T","TTTTTTTTTTTTT")); //$NON-NLS-1$ //$NON-NLS-2$
    lib1.setMode(TagLibrary.USE_UNIQUE_TAG);
    pm.getProject().setTagSettings(new DefaultTagSettings(new TagLibrary[] {lib1}));

    pm.getProbeDesignTask(false,true, null, new DefaultNamingScheme(), new GoodFairAcceptor(),new NoSelector(),pd,new DefaultTSSPairDesigner(new DefaultTSSConstructor()),null).run();

    Probe p1 = pm.getProject().getProbes().getSequenceAt(0);
    Probe p2 = pm.getProject().getProbes().getSequenceAt(1);

    assertEquals(ProbeMakerPropertyUtils.getRank(p1),ProbeMakerConstants.GOOD_QUALITY);
    assertEquals(ProbeMakerPropertyUtils.getRank(p2),ProbeMakerConstants.GOOD_QUALITY);

    //Test with forbidden tags
    tom.setData(DefaultTagOccurrenceModule.KEY_SEQUENCE_POSITIONS,"1"); //$NON-NLS-1$
    tom.setData(DefaultTagOccurrenceModule.KEY_COMPLEMENT_POSITIONS,"1"); //$NON-NLS-1$

    pm.getProbeDesignTask(false,true, null, new DefaultNamingScheme(), new GoodFairAcceptor(),new NoSelector(),pd,new DefaultTSSPairDesigner(new DefaultTSSConstructor()),null).run();

    p1 = pm.getProject().getProbes().getSequenceAt(0);
    p2 = pm.getProject().getProbes().getSequenceAt(1);

    assertEquals(ProbeMakerPropertyUtils.getRank(p1),ProbeMakerConstants.BAD_QUALITY);
    assertEquals(ProbeMakerPropertyUtils.getRank(p2),ProbeMakerConstants.BAD_QUALITY);

    //Test with forbidden complement only tags
    tom.setData(DefaultTagOccurrenceModule.KEY_SEQUENCE_POSITIONS,""); //$NON-NLS-1$

    pm.getProbeDesignTask(false,true, null, new DefaultNamingScheme(), new GoodFairAcceptor(),new NoSelector(),pd,new DefaultTSSPairDesigner(new DefaultTSSConstructor()),null).run();

    p1 = pm.getProject().getProbes().getSequenceAt(0);
    p2 = pm.getProject().getProbes().getSequenceAt(1);

    assertEquals(ProbeMakerPropertyUtils.getRank(p1),ProbeMakerConstants.GOOD_QUALITY);
View Full Code Here

    proj.getTargets().addSequence(t1);
    pm.setProject(proj);

    //First design, expected to result in a tag being allocated,
    //and the tag allocation table marking the tag as used
    pm.getProbeDesignTask(false, true, null, new DefaultNamingScheme(), new GoodAcceptor(), new NoSelector(), new DefaultProbeDesigner(new GreedyTagAllocator()), new DefaultTSSPairDesigner(new DefaultTSSConstructor()), new StreamErrorHandler(System.out,true)).run();
    Probe p = proj.getProbes().getSequenceAt(0);
   
    assertTrue("Tag allocation failed", p.getTags().size()==1);    //$NON-NLS-1$

    //New design, without tag reset, expected to fail because tag is already used
    pm.getProbeDesignTask(false, false, null, new DefaultNamingScheme(), new GoodAcceptor(), new NoSelector(), new DefaultProbeDesigner(new GreedyTagAllocator()), new DefaultTSSPairDesigner(new DefaultTSSConstructor()), new StreamErrorHandler(System.out,true)).run();  
    p = proj.getProbes().getSequenceAt(0);
   
    assertTrue("Tag allocation should have failed due to no tags left, but seems to have succeeded",p.getTags().size() == 0); //$NON-NLS-1$
   
    //New design, with reset. Expected to succeed because no tags should be used now
    pm.getProbeDesignTask(false, true, null, new DefaultNamingScheme(), new GoodAcceptor(), new NoSelector(), new DefaultProbeDesigner(new GreedyTagAllocator()), new DefaultTSSPairDesigner(new DefaultTSSConstructor()), new StreamErrorHandler(System.out,true)).run();          
    p = proj.getProbes().getSequenceAt(0);   
   
    assertTrue("Tag allocation failed after reset",p.getTags().size() == 1);     //$NON-NLS-1$

  }
View Full Code Here

    });
      proj.getSettings().getDesignParameters().put(Analyzer.PROP_ACCEPT_OK_ARMS,"false");
      proj.getSettings().getDesignParameters().put(Analyzer.PROP_ACCEPT_OK_CANDIDATES,"false");
     
      //First design, expected to result in failure.
      pm.getProbeDesignTask(false, true, null, new DefaultNamingScheme(), new GoodFairAcceptor(), new BestQualitySelector(), new DefaultProbeDesigner(new GreedyTagAllocator()), new DefaultTSSPairDesigner(new DefaultTSSConstructor()), new StreamErrorHandler(System.out,true)).run();
      Probe p = proj.getProbes().getSequenceAt(0);
              
      assertEquals("Tag allocation should have failed", 0, p.getTags().size());    //$NON-NLS-1$
      assertEquals("Quality expected to be bad", ProbeMakerConstants.BAD_QUALITY, ProbeMakerPropertyUtils.getRank(p));     
     
     
    //New design, with accept OK pairs. Expected to generate candidates, but fail.     
      proj.getSettings().getDesignParameters().put(Analyzer.PROP_ACCEPT_OK_ARMS,"true");
      proj.getSettings().getDesignParameters().put(Analyzer.PROP_ACCEPT_OK_CANDIDATES,"false");
      ProbeDesignTask task = pm.getProbeDesignTask(false, true, null, new DefaultNamingScheme(), new GoodFairAcceptor(), new BestQualitySelector(), new DefaultProbeDesigner(new GreedyTagAllocator()), new DefaultTSSPairDesigner(new DefaultTSSConstructor()), new StreamErrorHandler(System.out,true));
      task.run();
      long candCount = task.getCandidatesGenerated();
      p = proj.getProbes().getSequenceAt(0);
     
      assertEquals("Tag allocation should have failed", 0, p.getTags().size());    //$NON-NLS-1$
      assertEquals("Candidates expected", libraries1_1[0].size() , candCount);
      assertEquals("Quality expected to be bad", ProbeMakerConstants.BAD_QUALITY, ProbeMakerPropertyUtils.getRank(p));     
     
    //New design, with accept OK pairs AND candidates. Expected to generate candidates, and find candidate with warning.     
      proj.getSettings().getDesignParameters().put(Analyzer.PROP_ACCEPT_OK_ARMS,"true");
      proj.getSettings().getDesignParameters().put(Analyzer.PROP_ACCEPT_OK_CANDIDATES,"true");
      task = pm.getProbeDesignTask(false, true, null, new DefaultNamingScheme(), new GoodFairAcceptor(), new BestQualitySelector(), new DefaultProbeDesigner(new GreedyTagAllocator()), new DefaultTSSPairDesigner(new DefaultTSSConstructor()), new StreamErrorHandler(System.out,true));
      task.run();
      candCount = task.getCandidatesGenerated();
      p = proj.getProbes().getSequenceAt(0);
      System.out.println("Probe");
      for (Iterator<KeyValue> i = p.getPropertySet().getKeyValueIterator();i.hasNext();) {
View Full Code Here

TOP

Related Classes of org.moltools.apps.probemaker.design.DefaultNamingScheme

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.