Package org.moltools.lib.seq

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


    /**** 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

  /**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

    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

    }

    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

  /**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

    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

    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

    libE.addContent(new Element(LIB_NAME,ns).addContent(lib.getName()));
    libE.addContent(new Element(LIB_MODE,ns).addContent(String.valueOf(lib.getMode())));

    Element tags = new Element(TAGS,ns);
    for (Iterator<NucleotideSequence> ti = lib.iterator(); ti.hasNext(); ) {
      NucleotideSequence t = ti.next();
      tags.addContent(getTagElement(TAG,t));
    }
    libE.addContent(tags);
    return libE;
  }
View Full Code Here

  protected NucleotideSequence getTag(Element tagE) {
    String id = tagE.getAttributeValue(ID,ns);
    String typeStr = tagE.getChildText(TYPE,ns);
    String seqStr = tagE.getChildText(SEQUENCE,ns);

    NucleotideSequence seq = new SimpleNucleotideSequence(id,seqStr,Byte.parseByte(typeStr));
    return seq;
  }
View Full Code Here

TOP

Related Classes of org.moltools.lib.seq.NucleotideSequence

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.