Examples of TargetGroup


Examples of org.moltools.design.data.impl.TargetGroup

  public void testGroup() {
   
    Probe p1 = new DefaultProbe(NucleotideSequence.DNA);
    p1.setID("P1");
   
    TargetGroup tg = new TargetGroup("tg");
    ProbeGroup pg = new ProbeGroup(tg, "PG");
    assertEquals(0, pg.getMembers().size());
    pg.addMember(p1);
    assertEquals(1, pg.getMembers().size());
    p1.setName("Probe 1");   
View Full Code Here

Examples of org.moltools.design.data.impl.TargetGroup

    //Count the number of target groups
    List<TargetGroup> groups = new ArrayList<TargetGroup>();
    for (Iterator<ProbeMakerTarget> i = proj.getTargets().iterator(); i.hasNext(); ) {
      ProbeMakerTarget t = i.next();
      TargetGroup tg = (TargetGroup) DesignUtils.getGroupWithType(t,TargetGroup.GROUP_TYPE);
      if (tg != null) {
        if (!groups.contains(tg)) {
          groups.add(tg);
        }
      }
    }

    //Create a PrintStream
    PrintWriter p = new PrintWriter(out);

    increaseProgress();
    setStatus("Writing header",0); //$NON-NLS-1$

    //Print a header line
    Date d = new Date();
    p.println("Project exported " + DateFormat.getDateTimeInstance().format(d)); //$NON-NLS-1$
    p.println(TITLE_DESCRIPTOR + VERSION);
    p.println(version);
    p.println(TITLE_DESCRIPTOR + NAME);
    p.println(proj.getName());

    increaseProgress();
    setStatus("Writing targets",0); //$NON-NLS-1$

    //Print the number of target groups
    p.println(TITLE_DESCRIPTOR + TARGET_GROUPS);
    p.println(groups.size());

    //Print the target type
    p.println(TITLE_DESCRIPTOR + TARGET_TYPE);
    if (proj.getTargets().size() > 0) {
      Sequence target = proj.getTargets().getSequenceAt(0);
      p.println(target.getClass().getName());
    }
    else {
      p.println(""); //$NON-NLS-1$
    }

    //Print the targets - description;sequence;type;variant;group;
    p.println(TITLE_DESCRIPTOR + TARGETS);
    for (Iterator<ProbeMakerTarget> i = proj.getTargets().iterator(); i.hasNext(); ) {
      ProbeMakerTarget t = i.next();
      setStatus(t.getID(),1);
      String descStr = t.getID();
      String seqStr = t instanceof SequenceView ? ((SequenceView) t).getViewSequence() : t.seqString();
      String typeStr = String.valueOf(t.getType());
      String varStr = ""; //$NON-NLS-1$
      if (t instanceof VariantTarget) {
        VariantTarget vt = (VariantTarget) t;
        if (vt.getVariant() != null) {
          String str = vt.getVariant().toString();
          for (int v = 0; v < vt.getVariants().length; v++) {
            if (vt.getVariants()[v].toString().equals(str)) {
              varStr = String.valueOf(v);
              //Break the loop
              break;
            }
          }
        }
      }
      TargetGroup tg = (TargetGroup) DesignUtils.getGroupWithType(t,TargetGroup.GROUP_TYPE);
      String groupStr = String.valueOf(tg == null ? -1 : groups.indexOf(tg));
      p.println(tio.getOutString(new String[] {descStr,seqStr,typeStr,varStr,groupStr}));
    }
    p.println(TITLE_DESCRIPTOR + LISTEND);

    increaseProgress();
    setStatus("Writing tags",0);    //$NON-NLS-1$

    //Print the tag libraries - name;mode;allowSequence;allowcomplement;
    p.println(TITLE_DESCRIPTOR + LIBRARIES);

    //Check for a spacer
    TagLibrary[] libraries = proj.getTagSettings().getTagLibraries();
    for (int i = 0, t = 0; i < libraries.length; i++, t++) {
      TagLibrary l = libraries[t];
      p.println(tio.getOutString(new String[] {l.getName(),
          String.valueOf(l.getMode()),
          String.valueOf(true),
          String.valueOf(true)}));
    }

    p.println(TITLE_DESCRIPTOR + LISTEND);

    //Print the tags of each library - id;sequence;type
    for (int i = 0; i < libraries.length; i++) {
      TagLibrary l = libraries[i];
      p.println(TITLE_DESCRIPTOR + LIBRARY);
      for (Iterator<NucleotideSequence> ti = l.iterator(); ti.hasNext(); ) {
        NucleotideSequence t = ti.next();
        p.println(tio.getOutString(new String[] {t.getID(),t.seqString(),String.valueOf(t.getType())}));
      }
      p.println(TITLE_DESCRIPTOR + LISTEND);
    }

    increaseProgress();
    setStatus("Writing probes",0);       //$NON-NLS-1$

    //Make a list of probe groups
    List<ProbeGroup> p_groups = new ArrayList<ProbeGroup>();
    for (Iterator<Probe> i = proj.getProbes().iterator(); i.hasNext(); ) {
      Probe pr = i.next();
      ProbeGroup pg = (ProbeGroup) DesignUtils.getGroupWithType(pr,ProbeGroup.GROUP_TYPE);
      if (pg != null) {
        if (!p_groups.contains(pg)) {
          p_groups.add(pg);
        }
      }
    }

    //Print the probe groups - targetGroup;groupTagLibrary;groupTagNumber;
    p.println(TITLE_DESCRIPTOR + PROBE_GROUPS);
    for (Iterator<ProbeGroup> i = p_groups.iterator(); i.hasNext(); ) {
      ProbeGroup pg = i.next();
      TargetGroup tg = pg.getTargetGroup();
      int tg_no = tg == null ? -1 : groups.indexOf(tg);
      int lib_no = -1;
      int tag_no = -1;
      String tagID = proj.getTagAllocationTable().getGroupTagID(pg);
      if (tagID != null) {
View Full Code Here

Examples of org.moltools.design.data.impl.TargetGroup

    else {
      throw new IOException("No target groups found"); //$NON-NLS-1$
    }
    List<TargetGroup> groups = new ArrayList<TargetGroup>();
    for (int i = 0; i < no_groups; i++) {
      groups.add(new TargetGroup(String.valueOf(i+1)));
    }

    //Find the target type line and read the type string
    String typeString = ""; //$NON-NLS-1$
    if (current_version > 1) {
View Full Code Here

Examples of org.moltools.design.data.impl.TargetGroup

    String str = MessageFormat.format(CoreMessages.getString("ProbeMakerHTMLRenderer.TEXT_QUALITY"),args); //$NON-NLS-1$
    addParagraphText(root,str);
  }
 
  protected void addTargetGroupData(Element root, ProbeMakerTarget t) {
    TargetGroup targetGroup = (TargetGroup) DesignUtils.getGroupWithType(t, TargetGroup.GROUP_TYPE);
    if (targetGroup == null) {
      addParagraphText(root, CoreMessages.getString("ProbeMakerHTMLRenderer.TEXT_NO_GROUP")); //$NON-NLS-1$
    }
    else {
      Element h4 = new Element(HTMLWriter.H4.getTag());
      h4.addContent(CoreMessages.getString("ProbeMakerHTMLRenderer.TEXT_GROUPED_WITH")); //$NON-NLS-1$
     
      Element list = new Element(HTMLWriter.UL.getTag());
     
      for (Iterator<? extends Target> i = targetGroup.getMembers().iterator(); i.hasNext(); ) {
        ProbeMakerTarget other = (ProbeMakerTarget) i.next();
        if (t != other) {
          Element li = new Element(HTMLWriter.LI.getTag());
          li.addContent(other.getID());
          list.addContent(li);
View Full Code Here

Examples of org.moltools.design.data.impl.TargetGroup

    Probe p = new DefaultProbe(pair, upstreamBlocks, downstreamBlocks, probeAcidType);
    //If the target belongs to a TargetGroup, this probe should be placed in the
    //corresponding ProbeGroup. This is accomplished by checking the earlier made
    //probes for having a target from the same group and if so adding this probe
    //to that probegroup.
    TargetGroup tg = (TargetGroup) DesignUtils.getGroupWithType((PropertyHolder) p.getTarget(),TargetGroup.GROUP_TYPE);
    if (tg != null) {
      boolean groupfound = false;
      for (Iterator<Probe> i = probeset.iterator(); i.hasNext() && !groupfound; ) {
        Probe other = i.next();    
        ProbeGroup og = (ProbeGroup) DesignUtils.getGroupWithType(other,ProbeGroup.GROUP_TYPE);       
        if (og != null) {
          if (og.getTargetGroup() == tg) {
            og.addMember(p);
            groupfound = true;
          }
        }
      }
      //If no group found, create a new group
      if (!groupfound) {       
        ProbeGroup pg = new ProbeGroup(tg,tg.getID());
        pg.addMember(p);
      }
    }
    return p;
  }
View Full Code Here

Examples of org.moltools.design.data.impl.TargetGroup

    p.setID(id);
    //If the target belongs to a TargetGroup, this probe should be placed in the
    //corresponding ProbeGroup. This is accomplished by checking the earlier made
    //probes for having a target from the same group and if so adding this probe
    //to that probegroup.
    TargetGroup tg = (TargetGroup) DesignUtils.getGroupWithType((PropertyHolder) p.getTarget(),TargetGroup.GROUP_TYPE);
    if (tg != null) {
      boolean groupfound = false;
      for (Iterator<Probe> i = probeset.iterator(); i.hasNext() && !groupfound; ) {
        Probe other = i.next();    
        ProbeGroup og = (ProbeGroup) DesignUtils.getGroupWithType(other,ProbeGroup.GROUP_TYPE);       
        if (og != null) {
          if (og.getTargetGroup() == tg) {
            og.addMember(p);
            groupfound = true;
          }
        }
      }
      //If no group found, create a new group
      if (!groupfound) {       
        ProbeGroup pg = new ProbeGroup(tg,tg.getID());
        pg.addMember(p);
      }
    }
    return p;
  }
View Full Code Here

Examples of org.moltools.design.data.impl.TargetGroup

        }
      }

      //Set the target group
      if (groupStr.length() > 0) {
        TargetGroup tg;
        if (targetGroups.containsKey(groupStr)) {
          tg = targetGroups.get(groupStr);
        }
        else {
          tg = new TargetGroup(groupStr);
          targetGroups.put(groupStr,tg);
        }
        tg.addMember(t);
      }      
      project.getTargets().addSequence(t);
    }

    increaseProgress();
    setStatus("Reading settings",0);          //$NON-NLS-1$

    project.setSettings(SettingsXMLHandler.getSettings(projE.getChild(SettingsXMLHandler.SETTINGS,ns)));

    increaseProgress();  
    setStatus("Reading tag libraries",0);           //$NON-NLS-1$

    TagSettings tagSettings = getTagSettings(projE.getChild(LIBRARIES,ns));
    project.setTagSettings(tagSettings);
    project.getTagAllocationTable().setTagLibraries(tagSettings.getTagLibraries(),project.getSettings().getDesignParameters());

    increaseProgress();
    setStatus("Reading probes",0);          //$NON-NLS-1$

    //Read and create all probe groups
    Element probeList = projE.getChild(PROBE_LIST,ns);   
    Map<String, ProbeGroup> probeGroups = new HashMap<String, ProbeGroup>();   
    for (Iterator<?> i = probeList.getChildren().iterator();i.hasNext();) {

      Element probeE = (Element) i.next();
      String id = probeE.getAttributeValue(ID,ns);
      setStatus(id,1);

      String probeName = probeE.getChildText(NAME,ns);
      String typeStr = probeE.getChildText(TYPE,ns);
      String rankStr = probeE.getChildText(RANK,ns);

      byte type = Byte.parseByte(typeStr);
      byte rank = Byte.parseByte(rankStr);

      //Set the probe group, if any
      ProbeGroup pg = null;     
      Element groupE = probeE.getChild(PROBE_GROUP,ns);
      if (groupE != null) {
        String groupID = groupE.getAttributeValue(ID,ns);
        Attribute att = groupE.getAttribute(TARGET_GROUP,ns);
        TargetGroup tg = null;
        if (att!=null) {
          String tGroupID = att.getValue();
          tg = targetGroups.get(tGroupID);
        }
        pg = probeGroups.get(groupID);
View Full Code Here

Examples of org.moltools.design.data.impl.TargetGroup

      ProbeMakerTarget target = ti.next();
      //Check if target is expandable
      if (target instanceof VariantTarget) {
        VariantTarget vt = (VariantTarget) target;
        //If target is not in a group, expand it and add the new targets to temp
        TargetGroup tg = (TargetGroup) DesignUtils.getGroupWithType(vt,TargetGroup.GROUP_TYPE);
        if (tg == null) {
          tg = new TargetGroup(vt.getID());
          List<? extends ProbeMakerTarget> nts = vt.expand();
          if (nts.size() <= 1) {
            try {
              temp.addSequence(vt);
            }
            catch (DuplicateIDException e) {
              throw new RuntimeException(e);
            }
          }
          else {
            for (Iterator<? extends ProbeMakerTarget> ni = nts.iterator(); ni.hasNext(); ) {
              ProbeMakerTarget nt = ni.next();
              tg.addMember(nt);
              try {
                temp.addSequence(nt);
              }
              catch (DuplicateIDException e) {
                throw new RuntimeException(e);
View Full Code Here

Examples of org.moltools.design.data.impl.TargetGroup

      ProbeMakerTarget t = (ProbeMakerTarget) seq;
      //Create group names on first word (before " ") of target name
      String groupName = t.getID().split(" ")[0]; //$NON-NLS-1$
             
      if (targetGroups.containsKey(groupName)) {
        TargetGroup tg = targetGroups.get(groupName);
        tg.addMember(t);
      }
      else {
        TargetGroup tg = new TargetGroup(t.getID());
        tg.addMember(t);
        targetGroups.put(groupName,tg);
      }
    }
   
    //Create a TargetGroup[] and sort it
View Full Code Here

Examples of org.moltools.design.data.impl.TargetGroup

      ProbeMakerTarget t = (ProbeMakerTarget) targets.getSequenceAt(i);
      //Create group names on first word (before " ") of target name
      String groupName = t.getID().split(" ")[0]; //$NON-NLS-1$
             
      if (targetGroups.containsKey(groupName)) {
        TargetGroup tg = targetGroups.get(groupName);
        tg.addMember(t);
      }
      else {
        TargetGroup tg = new TargetGroup(t.getID());
        tg.addMember(t);
        targetGroups.put(groupName,tg);
      }
    }
   
    //Create a TargetGroup[] and sort it
    Collection<TargetGroup> values = targetGroups.values();
    TargetGroup[] groups = values.toArray(new TargetGroup[values.size()]);
     
    //Bubble sort
    boolean changed = true;
    while (changed) {
      changed = false;
      for (int i = 1;i<groups.length;i++) {
        if (groups[i-1].getMembers().size() > groups[i].getMembers().size()) {
          TargetGroup temp = groups[i-1];
          groups[i-1] = groups[i];
          groups[i] = temp;
          changed = true;
        }
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.