Package org.moltools.apps.probemaker.seq

Examples of org.moltools.apps.probemaker.seq.Probe


  /**Return a TableCellRenderer for the current cell. This cell renderer
   * will be a QualityRenderer that renders the fields as textFields with
   * background color depending on the quality of the probe in that row.*/
  @Override
  public TableCellRenderer getCellRenderer(int row, int col) {
    Probe p = (Probe) dataModel.getSequenceAt(row);
    if (col > 0) {
      return new QualityProbeTableCellRenderer(ProbeMakerPropertyUtils.getRank(p));
    }
    return new QualityRenderer(ProbeMakerPropertyUtils.getRank(p));
  }
View Full Code Here


        logger.info("Creating probe for " + target.getID()); //$NON-NLS-1$
        byte probeAcidType = Byte.parseByte(parameters.get(PROP_PROBE_ACID_TYPE));
        int up = Integer.parseInt(parameters.get(PROP_UPSTREAM_BLOCKS));
        int down = Integer.parseInt(parameters.get(PROP_DOWNSTREAM_BLOCKS));
        String id = namer.getProbeID(project, target);
        Probe p = ProbeMakerSequenceFactory.createProbeSkeleton(id, pairs[tindex],probeAcidType,up,down,probes);                
        p.setName(namer.getProbeName(project, target));
       
        //and add it to the probe db and newProbe list
        probes.addSequence(p);
        newProbes.addSequence(p);
      }
      catch (Exception ex) {
        log.printLine("A problem occurred"); //$NON-NLS-1$
        log.printError(ex.getMessage());
        handler.handleError(ex.toString(),ex);
      }
      tindex++;
    }
   
    //The newProbe method has set the group fields of each probe, so we make a
    //list of all groups that are new (when appending, it is necessary to
    //separate new and old groups).
    List<Identifiable> newGroupsAndProbes = new ArrayList<Identifiable>();
    for (Iterator<Probe> pi = newProbes.iterator(); pi.hasNext(); ) {
      Probe pr = pi.next();     
      ProbeGroup pg = (ProbeGroup) DesignUtils.getGroupWithType(pr, ProbeGroup.GROUP_TYPE);
      if (pg == null) {
        //If no group, add the probe instead
        newGroupsAndProbes.add(pr);
      }
      else if (!newGroupsAndProbes.contains(pg)) {
        newGroupsAndProbes.add(pg);
      }
    }
   
    //Screen the tags through the modules
    /*if (screentags) {
     setStatus(UITexts.getString("ProbeDesignTask.MESSAGE_SCREENING_TAGS")); //$NON-NLS-1$
    
    
     List allModules = new ArrayList();
    
     allModules.addAll(project.getSettings().getArmModules());
     allModules.addAll(project.getSettings().getCandidateModulesStage1());
     allModules.addAll(project.getSettings().getCandidateModulesStage2());        
    
     pd.screenTags(allModules);
     */
   
    fireStatusChange(0,CoreMessages.getString("ProbeDesignTask.MESSAGE_ALLOCATING_TAGS")); //$NON-NLS-1$
   
    //The probes db now contains all probes with TSSs only.
    //Now go through each new probegroup and allocate tags to the probes.
    int groupindex = 0; //status marker
    for (Iterator<Identifiable> gi = newGroupsAndProbes.iterator(); gi.hasNext(); ) {
      if (aborted()) return false;
      groupindex++;
      logger.info("Designing probes for group " + (groupindex)); //$NON-NLS-1$*/
      try {
        Object o = gi.next();
        if (o instanceof ProbeGroup) {
          ProbeGroup pg = (ProbeGroup) o;
          fireStatusChange(0,"Group " + (groupindex)); //$NON-NLS-1$
          allocator.allocateTagsToGroup(pg);
       
          //When the probes are finished confirm them and increment the progress value
          for (Iterator<Probe> pi = pg.getMembers().iterator(); pi.hasNext(); ) {
            allocator.confirm(pi.next());
            progress++;
            fireProgressChange(progress);
          }
        }
        else {
          Probe p = (Probe) o;
          ProbeGroup pg = new ProbeGroup(null,"DUMMY"); //$NON-NLS-1$
          pg.addMember(p);
          fireStatusChange(0,"Group " + (groupindex)); //$NON-NLS-1$
          allocator.allocateTagsToGroup(pg);
       
          //When the probes are finished confirm them and increment the progress value
          for (Iterator<Probe> pi = pg.getMembers().iterator(); pi.hasNext(); ) {
            allocator.confirm(pi.next());
            progress++;
            fireProgressChange(progress);
          }
          pg.removeMember(p);
        }
      }
      catch (Exception ex) {
        log.printLine("A problem occurred"); //$NON-NLS-1$
        log.printError(ex.getMessage());
        handler.handleError(ex.toString(),ex);
      }
    }
   
    //Recalculate the probe qualities and finish up the work
    for (Iterator<Probe> i = probes.iterator(); i.hasNext(); ) {
      if (aborted()) return false;
      Probe p = i.next();
      Analyzer.calculateAndSetQuality(p);
    }
   
    elapsedTime = System.currentTimeMillis() - startTime;
   
View Full Code Here

      super.abort();
      designer.abort();     

      //Recalculate the probe qualities and finish up the work
      for (Iterator<Probe> i = probes.iterator(); i.hasNext(); ) {
        Probe p = i.next();
        Analyzer.calculateAndSetQuality(p);
      }
    }
    log.endJob();
View Full Code Here

  }
 
  public static int getQualityCount(DefiniteSequenceDB<? extends Probe> probes, byte quality) {
    int count = 0;
    for (Iterator<? extends Probe> i = probes.iterator(); i.hasNext(); ) {
      Probe p = i.next();
      if (ProbeMakerPropertyUtils.getRank(p) == quality) {
        count++;
      }
    }
    return count;
View Full Code Here

 
  public static List<MessageSummaryEntry> getMessageSummary(DefiniteSequenceDB<? extends Probe> probes) {
    List<MessageSummaryEntry> l = new ArrayList<MessageSummaryEntry>();
   
    for (Iterator<? extends Probe> i = probes.iterator();i.hasNext();) {
      Probe p = i.next();
      for (Iterator<Message> mi = ProbeMakerPropertyUtils.getAllMessages(p).iterator();mi.hasNext();) {
        Message m = mi.next();
        MessageType t = m.getType();
        int s = m.getSeverity();
        boolean found = false;
View Full Code Here

    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();) {
        System.out.println(i.next());
      }
      System.out.println("TSS Pair");
      for (Iterator<KeyValue> i = p.getTSSPair().getPropertySet().getKeyValueIterator();i.hasNext();) {
        System.out.println(i.next());
      }
      System.out.println("5'");
      for (Iterator<KeyValue> i = p.getTSSPair().getFivePrime().getPropertySet().getKeyValueIterator();i.hasNext();) {
        System.out.println(i.next());
      }
      System.out.println("3'");
      for (Iterator<KeyValue> i = p.getTSSPair().getThreePrime().getPropertySet().getKeyValueIterator();i.hasNext();) {
        System.out.println(i.next());
      }
     
      assertEquals("Tag allocation should have succeeded", 1, p.getTags().size());    //$NON-NLS-1$
      assertEquals("Candidates expected", libraries1_1[0].size(), candCount);
      assertEquals("Quality expected to be OK", ProbeMakerConstants.OK_QUALITY, ProbeMakerPropertyUtils.getRank(p));     
     
     
    }
View Full Code Here

    pm.setProject(proj);

    //Make a new design after clearing tag usage   
    Task task = pm.getProbeDesignTask(false, true, null, new DefaultNamingScheme(), new GoodAcceptor(), new NoSelector(), new DefaultProbeDesigner(new GreedyTagAllocator()), new DefaultTSSPairDesigner(new DefaultTSSConstructor()), new StreamErrorHandler(System.out,true));
    task.run();
    Probe p = proj.getProbes().getSequenceAt(0);
    assertTrue("Tag allocated despite warning message",p.getTags().size() == 0); //$NON-NLS-1$

    proj.getSettings().getCandidateModulesStage1().clear();
  }
View Full Code Here

    task = pm.getProbeDesignTask(false, true, null, new DefaultNamingScheme(), new GoodAcceptor(),
        new NoSelector(), new DefaultProbeDesigner(new GreedyTagAllocator()), new DefaultTSSPairDesigner(new DefaultTSSConstructor()), new StreamErrorHandler(System.out,true));
    task.run();
    candCount = task.getCandidatesGenerated();
    Probe p1 = pm.getProject().getProbes().getSequenceAt(0);
    Probe p2 = pm.getProject().getProbes().getSequenceAt(1);

    assertTrue("2 candidates expected, " + candCount + " generated.",candCount == 2); //$NON-NLS-1$ //$NON-NLS-2$
    assertTrue("Same tags allocated in unique mode!",p1.getTagAt(0)!=p2.getTagAt(0)); //$NON-NLS-1$

//  Expand target and test use per group, no modules, 2 candidates expected       
    libraries1_10[0].setMode(TagLibrary.USE_PER_GROUP);          

    task = pm.getProbeDesignTask(false, true, null, new DefaultNamingScheme(), new GoodAcceptor(),
        new NoSelector(), new DefaultProbeDesigner(new GreedyTagAllocator()), new DefaultTSSPairDesigner(new DefaultTSSConstructor()), new StreamErrorHandler(System.out,true));
    task.run();
    candCount = task.getCandidatesGenerated();
    p1 = pm.getProject().getProbes().getSequenceAt(0);
    p2 = pm.getProject().getProbes().getSequenceAt(1);

    assertTrue("2 candidates expected, " + candCount + " generated.",candCount == 2); //$NON-NLS-1$ //$NON-NLS-2$
    assertTrue("Different tags allocated in group mode!",p1.getTagAt(0)==p2.getTagAt(0)); //$NON-NLS-1$

//  Still expanded targets, per group mode, greedy allocator, dummy module in stage 1.
    //Expect 20 candidates generated
    libraries1_10[0].setMode(TagLibrary.USE_PER_GROUP);          
    proj.getSettings().getCandidateModulesStage1().add(dummy);   
View Full Code Here

    pm.setProject(proj);
   
    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 p1 = proj.getProbes().getSequenceAt(0);
    Probe p2 = proj.getProbes().getSequenceAt(1);

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

    proj.getTagAllocationTable().clearUsed();
   
    //Two probes single tag unique, with dummy. Expect first ok, second bad
    proj.getSettings().getCandidateModulesStage2().add(dummy);
      
    ProbeDesignTask task = pm.getProbeDesignTask(false, true, null, new DefaultNamingScheme(), new AllAcceptor(),
        new NoSelector(), new DefaultProbeDesigner(new PairwiseTagAllocator()), new DefaultTSSPairDesigner(new DefaultTSSConstructor()), new StreamErrorHandler(System.out,true));
    task.run();
   
    p1 = proj.getProbes().getSequenceAt(0);
    p2 = proj.getProbes().getSequenceAt(1);

    assertEquals(ProbeMakerPropertyUtils.getAllMessages(p1).size(),1);
    assertEquals(ProbeMakerPropertyUtils.getRank(p1),ProbeMakerConstants.OK_QUALITY);
    assertEquals(ProbeMakerPropertyUtils.getRank(p2),ProbeMakerConstants.BAD_QUALITY);
    assertEquals(task.getCandidatesGenerated(),1);
   
    proj.getTagAllocationTable().clearUsed();
   
    //Test single-tag use same
    libraries1_1[0].setMode(TagLibrary.USE_SAME_TAG);
    proj.setTagSettings(new DefaultTagSettings(libraries1_1));
    proj.getSettings().getCandidateModulesStage2().clear();
    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();

    p1 = proj.getProbes().getSequenceAt(0);
    p2 = proj.getProbes().getSequenceAt(1);

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

//  Test single-tag use unique in group with one expanded
    //expect first probe to succeed but be set to bad when second one failed
    //Third probe then set to good
    proj.getTagAllocationTable().clearUsed();
    libraries1_1[0].setMode(TagLibrary.USE_UNIQUE_IN_GROUP);
    proj.setTagSettings(new DefaultTagSettings(libraries1_1));
    proj.getTargets().clear();
    proj.getTargets().addSequence(t1);
    TargetHandler.expandTargets(proj.getTargets());
    proj.getTargets().addSequence(t2);
   
    task = pm.getProbeDesignTask(false, true, null, new DefaultNamingScheme(), new AllAcceptor(),
        new NoSelector(), new DefaultProbeDesigner(new PairwiseTagAllocator()), new DefaultTSSPairDesigner(new DefaultTSSConstructor()), new StreamErrorHandler(System.out,true));
    task.run();

    p1 = proj.getProbes().getSequenceAt(0);
    p2 = proj.getProbes().getSequenceAt(1);
    Probe p3 = proj.getProbes().getSequenceAt(2);

   
    assertEquals(ProbeMakerPropertyUtils.getRank(p1),ProbeMakerConstants.BAD_QUALITY);
    assertEquals(ProbeMakerPropertyUtils.getRank(p2),ProbeMakerConstants.BAD_QUALITY);
   
    assertEquals(ProbeMakerPropertyUtils.getRank(p3),ProbeMakerConstants.GOOD_QUALITY);
    assertEquals(task.getCandidatesGenerated(),2);
   
    libraries1_1[0].setMode(TagLibrary.USE_UNIQUE_TAG);
   
//  Test single-tag use same with one expanded
    libraries2_1_1[0].setMode(TagLibrary.USE_UNIQUE_TAG);
    libraries2_1_1[1].setMode(TagLibrary.USE_UNIQUE_IN_GROUP);
    proj.setTagSettings(new DefaultTagSettings(libraries2_1_1));

    proj.getTargets().clear();
    proj.getTargets().addSequence(t1);
    TargetHandler.expandTargets(proj.getTargets());
    proj.getTargets().addSequence(t2);
   
    task = pm.getProbeDesignTask(false, true, null, new DefaultNamingScheme(), new AllAcceptor(),
        new NoSelector(), new DefaultProbeDesigner(new PairwiseTagAllocator()), new DefaultTSSPairDesigner(new DefaultTSSConstructor()), new StreamErrorHandler(System.out,true));
    task.run();

    p1 = proj.getProbes().getSequenceAt(0);
    p2 = proj.getProbes().getSequenceAt(1);
    p3 = proj.getProbes().getSequenceAt(2);

    NucleotideSequence tag1 = libraries2_1_1[0].getSequenceAt(0);
   
    assertEquals(proj.getTagAllocationTable().getUserIDs(tag1).contains(p1.getID()),false);
    assertEquals(proj.getTagAllocationTable().getUserIDs(tag1).contains(p3.getID()),true);
   
    assertEquals(2, task.getCandidatesGenerated());
    assertEquals(ProbeMakerPropertyUtils.getRank(p1),ProbeMakerConstants.BAD_QUALITY);
    assertEquals(ProbeMakerPropertyUtils.getRank(p2),ProbeMakerConstants.BAD_QUALITY);
    assertEquals(ProbeMakerPropertyUtils.getRank(p3),ProbeMakerConstants.GOOD_QUALITY);
View Full Code Here

TOP

Related Classes of org.moltools.apps.probemaker.seq.Probe

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.