Examples of NucleotideSequence


Examples of org.moltools.lib.seq.NucleotideSequence

  /**Assemble the parts (subsequences) of the Probe*/
  protected String composeSequence() {
    StringBuffer sequencestring = new StringBuffer();
    for (int i = 1; i <= getSequenceCount(); i++) {
      NucleotideSequence si = getSequence(i);
      sequencestring.append(si == null ? "" : si.seqString()); //$NON-NLS-1$
    }
    return sequencestring.toString();
  }
View Full Code Here

Examples of org.moltools.lib.seq.NucleotideSequence

    //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) {
        for (int l = 0; l < libraries.length; l++) {
          try {
            NucleotideSequence s = libraries[l].getSequenceByID(tagID);
            lib_no = l;
            tag_no = libraries[l].indexOfSequence(s);
          }
          catch (IDNotFoundException inx) {
            //do nothing
          }
        }
      }
      p.println(tio.getOutString(new String[] { String.valueOf(tg_no),String.valueOf(lib_no),String.valueOf(tag_no) }));
    }
    p.println(TITLE_DESCRIPTOR + LISTEND);

    //Print the probes - description;ID;type;upStream;downStream;target;group number;quality;messageCountArms;messageCountProbe;;5'seq;Tm;3'seq;Tm;tag 1 lib;tag 1 pos;...;...;tag n lib;tag n pos;
    p.println(TITLE_DESCRIPTOR + PROBES);
    DefiniteSequenceDB<Probe> probes = proj.getProbes();
    for (Iterator<Probe> i = probes.iterator(); i.hasNext(); ) {
      Probe pr = i.next();
      PropertyAcceptorNucleotideSequence fivePrime;
      PropertyAcceptorNucleotideSequence threePrime;
      try {
        fivePrime = (PropertyAcceptorNucleotideSequence) pr.getTSSPair().getSequence(TSSPair.KEY_FIVE_PRIME);
      }
      catch (ClusterException e) {
        fivePrime = null;
      }
      try {
        threePrime = (PropertyAcceptorNucleotideSequence) pr.getTSSPair().getSequence(TSSPair.KEY_THREE_PRIME);
      }
      catch (ClusterException e) {
        threePrime = null;
      }

      int targetNo = -1;
      try {
        targetNo = pr.getTarget() == null ? -1 : proj.getTargets().indexOfSequence(proj.getTargets().getSequenceByID(pr.getTarget().getID()));
      }
      catch (IDNotFoundException ix) {
        //let targetNo be -1
      }
      Group<?> pg = DesignUtils.getGroupWithType(pr,ProbeGroup.GROUP_TYPE);

      String outStr = tio.getOutString(new String[] {
          pr.getName().replace(VALUE_SEPARATOR, VALUE_SEPARATOR_REPLACEMENT),
          pr.getID() != null ? pr.getID().replace(VALUE_SEPARATOR, VALUE_SEPARATOR_REPLACEMENT) : "No ID",                            //$NON-NLS-1$
              String.valueOf(pr.getType()),
              String.valueOf(pr.getUpstreamBlockCount()),
              String.valueOf(pr.getDownstreamBlockCount()),
              String.valueOf(targetNo),
              String.valueOf(pg == null ? -1 : p_groups.indexOf(pg)),
              String.valueOf(ProbeMakerPropertyUtils.getRank(pr)),
              String.valueOf(fivePrime == null ? 0 : ProbeMakerPropertyUtils.getAllMessages(fivePrime).size()),
              String.valueOf(threePrime == null ? 0 : ProbeMakerPropertyUtils.getAllMessages(threePrime).size()),
              String.valueOf(ProbeMakerPropertyUtils.getOwnMessages(pr.getTSSPair()).size()),
              String.valueOf(ProbeMakerPropertyUtils.getOwnMessages(pr).size()),
              fivePrime == null ? "" : fivePrime.seqString(), //$NON-NLS-1$
                  String.valueOf(fivePrime == null ? 0 : ProbeMakerPropertyUtils.getHybridizationTemp(fivePrime)),
                  threePrime == null ? "" : threePrime.seqString(), //$NON-NLS-1$
                      String.valueOf(threePrime == null ? 0 : ProbeMakerPropertyUtils.getHybridizationTemp(threePrime))
      });
      for (int t = 0; t < pr.getTags().size(); t++) {
        outStr += VALUE_SEPARATOR;
        NucleotideSequence tag = pr.getTagAt(t);
        //This isn't perfect but will work (if noone calls their tags 'Spacer')
        if (tag.getID().startsWith("Spacer")) { //$NON-NLS-1$
          outStr += "Spacer"; //$NON-NLS-1$
          outStr += VALUE_SEPARATOR;
          outStr += tag.seqString();
        }
        else {
          int lib_no = -1;
          int tag_no = -1;
          for (int l = 0; l < libraries.length; l++) {
            try {
              NucleotideSequence s = libraries[l].getSequenceByID(tag.getID());
              if (s!=null) {
                lib_no = l;
                tag_no = libraries[l].indexOfSequence(s);
              }
            }
            catch (IDNotFoundException inx) {
              //do nothing
            }
          }
          outStr += String.valueOf(lib_no);
          outStr += VALUE_SEPARATOR;
          outStr += String.valueOf(tag_no);
        }
      }
      p.println(outStr);

      if (fivePrime != null) {
        for (Iterator<Message> mi = ProbeMakerPropertyUtils.getAllMessages(fivePrime).iterator();mi.hasNext();) {
          Message m = mi.next();
          MessageType mt = m.getType();
          p.println(tio.getOutString(new String[] {mt.getType(),mt.getDescription(),m.getMessage(),String.valueOf(m.getSeverity())}));
        }
      }
      if (threePrime != null) {
        for (Iterator<Message> mi = ProbeMakerPropertyUtils.getAllMessages(threePrime).iterator();mi.hasNext();) {
          Message m = mi.next();
          MessageType mt = m.getType();
          p.println(tio.getOutString(new String[] {mt.getType(),mt.getDescription(),m.getMessage(),String.valueOf(m.getSeverity())}));
        }
      }
      for (Iterator<Message> mi = ProbeMakerPropertyUtils.getOwnMessages(pr.getTSSPair()).iterator();mi.hasNext();) {
        Message m = mi.next();
        MessageType mt = m.getType();
        p.println(tio.getOutString(new String[] {mt.getType(),mt.getDescription(),m.getMessage(),String.valueOf(m.getSeverity())}));
      }
      for (Iterator<Message> mi = ProbeMakerPropertyUtils.getOwnMessages(pr).iterator();mi.hasNext();) {
        Message m = mi.next();
        MessageType mt = m.getType();
        p.println(tio.getOutString(new String[] {mt.getType(),mt.getDescription(),m.getMessage(),String.valueOf(m.getSeverity())}));
      }
    }
    p.println(TITLE_DESCRIPTOR + LISTEND);

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

    //Print the settings of the project
    Settings s = proj.getSettings();

    List<CandidateAnalysisModule> modules1 = s.getArmModules();
    List<CandidateAnalysisModule> modules2 = s.getCandidateModulesStage1();
    List<CandidateAnalysisModule> modules3 = s.getCandidateModulesStage2();
    Properties props = new Properties();
    props.putAll(s.getDesignParameters());

    p.println(TITLE_DESCRIPTOR + MODULES1);
    for (Iterator<CandidateAnalysisModule> i = modules1.iterator();i.hasNext();)
      p.println(getModuleString(i.next(),tio));
    p.println(TITLE_DESCRIPTOR + LISTEND);
View Full Code Here

Examples of org.moltools.lib.seq.NucleotideSequence

        String[] substrings = tio.getInStrings(tagString);
        if (substrings.length != 3)
          throw new UnsupportedOperationException("Error parsing tag line: " + tagString); //$NON-NLS-1$

        NucleotideSequence t = new SimpleNucleotideSequence(
            substrings[0],
            substrings[1],
            Byte.parseByte(substrings[2]));
        libraries[l].addSequence(t);
      }
    }

    //Set the project tag libraries
    int[] order = new int[libraries.length];
    for (int i = 0;i<order.length;i++) order[i] = i;
    proj.setTagSettings(new DefaultTagSettings(libraries,order));

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

    //Read and create all probe groups
    searchTitle(r, PROBE_GROUPS);
    List<ProbeGroup> p_groups = new ArrayList<ProbeGroup>();
    String groupString;
    int tgIndex = 0;
    while (! (groupString = r.readLine()).startsWith(String.valueOf(
        TITLE_DESCRIPTOR))) {
      String[] substrings = tio.getInStrings(groupString);
      if (substrings.length != 3)
        throw new UnsupportedOperationException("Error parsing probe group line: " + groupString); //$NON-NLS-1$

      tgIndex++;
      int pgindex = Integer.parseInt(substrings[0]);
      int libindex = Integer.parseInt(substrings[1]);
      int tagindex = Integer.parseInt(substrings[2]);
      if (pgindex >= 0) {
        ProbeGroup pg = new ProbeGroup(groups.get(pgindex),String.valueOf(pgindex+1));
        if (libindex >= 0)
          proj.getTagAllocationTable().setGroupTagID(pg, libraries[libindex].getSequenceAt(tagindex));
        p_groups.add(pg);
      }
      else {
        ProbeGroup pg = new ProbeGroup(null,"DUMMY"); //$NON-NLS-1$
        p_groups.add(pg);
      }
    }

    //Read and create all probes
    //description;ID;type;upStream;downStream;target;group number;quality;struct;messCount1;messCount2;messCount3;messCount4;5'seq;3'seq;tag 1 lib;tag 1 pos;...;...;tag n lib;tag n pos;
    searchTitle(r, PROBES);
    String probeString;
    while (! (probeString = r.readLine()).startsWith(String.valueOf(
        TITLE_DESCRIPTOR))) {

      String[] substrings = tio.getInStrings(probeString);

      byte type = Byte.parseByte(substrings[2]);

      int target_no = Integer.parseInt(substrings[5]);
      ProbeMakerTarget pt = null;
      if (target_no >= 0) {
        pt = proj.getTargets().getSequenceAt(target_no);
      }

      int gr_no = Integer.parseInt(substrings[6]);

      int messageCount5 = Integer.parseInt(substrings[8]);
      int messageCount3 = Integer.parseInt(substrings[9]);
      int messageCountTSS = Integer.parseInt(substrings[10]);
      int messageCountProbe = Integer.parseInt(substrings[11]);

      PropertyAcceptorNucleotideSequence tss5 = ProbeMakerSequenceFactory.createTSS(new SimpleNucleotideSequence(
          "5' TSS", substrings[12], type),pt == null ? "" : pt.getID()); //$NON-NLS-1$ //$NON-NLS-2$
      ProbeMakerPropertyUtils.setHybridizationTemp(tss5,Float.parseFloat(substrings[13]));

      PropertyAcceptorNucleotideSequence tss3 = ProbeMakerSequenceFactory.createTSS(new SimpleNucleotideSequence(
          "3' TSS", substrings[14], type),pt == null ? "" : pt.getID()); //$NON-NLS-1$ //$NON-NLS-2$
      ProbeMakerPropertyUtils.setHybridizationTemp(tss3,Float.parseFloat(substrings[15]));

      Probe p = new DefaultProbe(ProbeMakerSequenceFactory.createTSSPair(tss5, tss3, pt),Integer.parseInt(substrings[3]),Integer.parseInt(substrings[4]),type);
      p.setName(substrings[0]);
      p.setID(substrings[1]);
      if (gr_no >= 0)
        DesignUtils.addGroup(p, p_groups.get(gr_no));

      ProbeMakerPropertyUtils.setRank(p,Byte.parseByte(substrings[7]));

      //Read tags from substring 16;
      int t = 0;
      for (int i = 16; i < substrings.length; i+=2, t++) {
        String l_str = substrings[i];
        String t_str = substrings[i+1];
        if (l_str.startsWith("Spacer")) { //$NON-NLS-1$
          NucleotideSequence tag = new SimpleNucleotideSequence("Spacer " + t_str, t_str, p.getType()); //$NON-NLS-1$
          p.addTagAt(tag,t);
        }
        else {
          int lib_no = Integer.parseInt(l_str);
          int tag_no = Integer.parseInt(t_str);
          NucleotideSequence tag = libraries[lib_no].getSequenceAt(tag_no);
          p.addTagAt(tag, t);
          proj.getTagAllocationTable().use(tag,p,t);
        }
      }
View Full Code Here

Examples of org.moltools.lib.seq.NucleotideSequence

    /**** Searches are performed as string searches, and thus use string index system.  ******/
    //For a sequence to be a template for a padlock probe, it is
    //necessary for the sequence to be similar to the intended template, and
    //in particular, the sequence near the probes ends must be identical
    try {
      NucleotideSequence tss5 = p.getTSSPair().getSequence(TSSPair.KEY_FIVE_PRIME);
      NucleotideSequence tss3 = p.getTSSPair().getSequence(TSSPair.KEY_THREE_PRIME);

      //    The sequence of the probe arms (full arms)
      String tssSeq = tss3.seqString() + tss5.seqString();
      NucleotideSequence fullTSS = new SimpleNucleotideSequence("TSS",tssSeq,p.getType()); //$NON-NLS-1$


      //Get the sequence to search for in other probes  
      String threeseq = p.subsequence(p.length() - min3Length + 1, p.length());
      String fiveseq = p.subsequence(1, min5Length);
      String query = NucleotideSequenceHandler.getRevComp(threeseq + fiveseq, p.getType(),s.getType());
     
      //Length of 5' TSS
      int TSSlen5 = tss5.length();
      //Length of 3' TSS
      int TSSlen3 = tss3.length();

      //Get the string to search in, extend it if it is to be interpreted as circular,
      //and change any Us to Ts to allow correct interpretation       
      String sequence = s.seqString().replace('U', 'T');

      if (circular) {
        sequence += sequence.substring(0, min3Length + min5Length - 1);
      }

      //To store the results in
      Stack<Integer> results = new Stack<Integer>();

      //Search for occurrences of the query in the sequence
      int index = -1;
      while ((index = sequence.indexOf(query, index + 1)) > -1) {    
        //If stipulated, check Tm to be above limit
        if (doTm) {               
          float maxTm = -Float.MAX_VALUE;     

          //Extract a template to check the whole TSS pair against
          int start = Math.max(0,index+min5Length-TSSlen5);
          int end = Math.min(index+min5Length+TSSlen3,sequence.length());

          //Get the template to compare to
          String template = sequence.substring(start,end);
          //Get all possible sequences to match the probe to
          String[] sequences = NucleotideSequenceHandler.getPossibleSequences(template,s.getType());

          for (int sc = 0;sc<sequences.length;sc++) {

            NucleotideSequence s2 = new SimpleNucleotideSequence("S2",sequences[sc],s.getType());                       //$NON-NLS-1$
            NAHybridStructure hs = ((FractionalMeltingPointCalculator) fmpc).calculateHybridStructure(fullTSS,s2);       

            if (hs != null) {
              float Tm;
              try {
View Full Code Here

Examples of org.moltools.lib.seq.NucleotideSequence

  /**Checks whether the arms of this probe may template ligation of the probe.
   * The arms are linked at the ligation site, open at the linker ends.*/
  public boolean checkTemplatingByArms(Probe p) {
    boolean found = false;
    //Check self-templating
    NucleotideSequence fp;
    try {
      fp = p.getTSSPair().getSequence(TSSPair.KEY_FIVE_PRIME);
    }
    catch (ClusterException e) {
      fp = null;
    }
    NucleotideSequence tp;
    try {
      tp = p.getTSSPair().getSequence(TSSPair.KEY_THREE_PRIME);
    }
    catch (ClusterException e) {
      tp = null;
    }

    if (tp == null || fp == null) throw new UnsupportedOperationException("Can't perform ligation calculations with missing TSSs"); //$NON-NLS-1$

    int[] results = isLigationTemplate(
        new SimpleChangeableNucleotideSequence(
            "TSS|"+p.getName(), //$NON-NLS-1$
            tp.seqString() + fp.seqString(),
            p.getType()
            ), p, false, false);
    if (results != null) {
      for (int i = 0; i < results.length; i++) {
        ProbeMakerPropertyUtils.addMessage(p.getTSSPair(),new Message(
View Full Code Here

Examples of org.moltools.lib.seq.NucleotideSequence

    for (Iterator<? extends Probe> pi = probes.iterator(); pi.hasNext(); ) {
      Probe other = pi.next();
      //Check for templating and add messages accordingly
      if (other != p) {
        //Does the arms of this probe template other probe?
        NucleotideSequence fp;
        try {
          fp = p.getTSSPair().getSequence(TSSPair.KEY_FIVE_PRIME);
        }
        catch (ClusterException e) {
          fp = null;
        }
        NucleotideSequence tp;
        try {
          tp = p.getTSSPair().getSequence(TSSPair.KEY_THREE_PRIME);
        }
        catch (ClusterException e) {
          tp = null;
        }

        if (tp == null || fp == null) throw new UnsupportedOperationException("Can't perform ligation calculations with missing TSSs"); //$NON-NLS-1$

        if (isLigationTemplate(new SimpleNucleotideSequence(tp.
            seqString() + fp.seqString(),
            "Arms of " + p.getName(), //$NON-NLS-1$
            p.getType()), other, false, false) != null) {
          ProbeMakerPropertyUtils.addMessage(p.getTSSPair(),new Message("May act as template for " + //$NON-NLS-1$
              other.getName(),
View Full Code Here

Examples of org.moltools.lib.seq.NucleotideSequence

    }

    StringBuffer html = new StringBuffer();

    for (Iterator<NucleotideSequence> i = library.iterator(); i.hasNext(); ) {
      NucleotideSequence t = i.next();
      HTMLWriter.appendEnclosed(html,t.getID(),HTMLWriter.B);
      html.append("<br>\n"); //$NON-NLS-1$
      html.append("<tt>" + SequenceHTMLRenderer.getHardWrappedString(t.seqString(),60) + "</tt><br>\n"); //$NON-NLS-1$ //$NON-NLS-2$
    }
    return html.toString();
  }
View Full Code Here

Examples of org.moltools.lib.seq.NucleotideSequence

  /**Assemble the parts (subsequences) of the Probe*/
  protected String composeSequence() {
    StringBuffer sequencestring = new StringBuffer();
    for (int i = 1; i <= getSequenceCount(); i++) {
      NucleotideSequence si = getSequence(i);
      sequencestring.append(si == null ? "" : si.seqString()); //$NON-NLS-1$
    }
    return sequencestring.toString();
  }
View Full Code Here

Examples of org.moltools.lib.seq.NucleotideSequence

    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());
View Full Code Here

Examples of org.moltools.lib.seq.NucleotideSequence

    return messageList;
 

  /**Get a key-value pair, <tag, library> for a tag id*/
  protected KeyValue getLibraryTag(TagLibrary[] libraries, String tagID) {   
    NucleotideSequence theTag = null;
    TagLibrary theLib = null;
    for (int lib = 0;lib<libraries.length;lib++) {
      try {
        NucleotideSequence tag = libraries[lib].getSequenceByID(tagID);
        if (tag != null) {
          theTag = tag;
          theLib = libraries[lib];
          break;
        }
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.