Esempio n. 1
0
  @Override
  public NucSeq generateCompositeSequence(
      ArrayList<Part> composition, Object additionalRequirements) {
    StringBuffer sb = new StringBuffer();
    for (Part p : composition) {
      sb.append(p.getSeq().getSeq());
    }
    NucSeq outnuc = new NucSeq(sb.toString());
    outnuc.setTransient();

    int offset = 0;
    for (Part p : composition) {
      String parseq = p.getSeq().getSeq();
      for (Annotation ann : p.getSeq().getAnnotations()) {
        Feature afeature = ann.getFeature();
        String name = ann.getName();
        Color forColor = ann.getForwardColor();
        Color revColor = ann.getReverseColor();
        int Start = offset + ann.getStart();
        int End = offset + ann.getEnd();
        Person user = ann.getAuthor();
        boolean plusstrandtrue = ann.isForwardStrand();
        String symbol = ann.getSymbol();

        Annotation newann;
        if (afeature == null) {
          newann =
              new Annotation(
                  name, outnuc, forColor, forColor, Start, End, user, plusstrandtrue, symbol);
          newann.setTransient();
        } else {
          newann =
              new Annotation(
                  afeature, outnuc, forColor, forColor, Start, End, user, plusstrandtrue, symbol);
          newann.setTransient();
        }
        System.out.println("Generated annotation: " + newann.getName());
      }
      offset += parseq.length();
    }

    return outnuc;
  }
 private void saveButtonActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_saveButtonActionPerformed
   String desc = _sv.getSequenceView().getOutputTextArea().getText();
   if (desc == null) {
     desc = "";
   }
   String name = nameTextField.getText();
   String seq = null;
   System.out.println("saving: " + name);
   if (intervalRadioButton.isSelected()) {
     try {
       if (dataTextPane.getText() != null) {
         seq =
             dataTextPane
                 .getText()
                 .substring(
                     Integer.parseInt(fromTextField.getText()),
                     Integer.parseInt(toTextField.getText()));
       }
     } catch (NumberFormatException e) {
       System.out.println("tried to use invalid sequence interval to generate Clotho object");
       return;
     }
   } else {
     seq = dataTextPane.getText();
   }
   Format form = null;
   Collection coll = null;
   if (objectTypeComboBox.getSelectedIndex() != 1 && objectTypeComboBox.getSelectedIndex() != 0) {
     if (formatComboBox.getSelectedIndex() == -1) {
       statusLabel.setText("Warning: format not set");
       return;
     }
     form = Collector.getFormat(((ObjLink) formatComboBox.getSelectedItem()).uuid);
   }
   if (collectionComboBox.getSelectedIndex() != -1) {
     coll = Collector.getCollection(((ObjLink) collectionComboBox.getSelectedItem()).uuid);
   } else {
     statusLabel.setText("Warning: collection not selected");
     return;
   }
   if (objectTypeComboBox.getSelectedIndex() == -1) {
     statusLabel.setText("Warning: object Type not set");
     return;
   }
   Boolean saved = false;
   ObjBase newObject = null;
   if (coll != null) {
     if (objectTypeComboBox.getSelectedIndex() == 0) {
       // feature
       if (seq.toUpperCase().indexOf("ATG") != -1) {
         newObject = Feature.generateFeature(name, seq, Collector.getCurrentUser(), true);
       } else {
         newObject = Feature.generateFeature(name, seq, Collector.getCurrentUser(), false);
       }
     } else if (objectTypeComboBox.getSelectedIndex() == 1) {
       newObject = new Oligo(name, desc, Collector.getCurrentUser(), seq);
     } else if (form != null && objectTypeComboBox.getSelectedIndex() == 2) {
       // part
       newObject = Part.generateBasic(name, desc, seq, form, Collector.getCurrentUser());
     } else if (form != null && objectTypeComboBox.getSelectedIndex() == 3) {
       Vector.generateVector(name, desc, seq, form, Collector.getCurrentUser());
     } else {
       statusLabel.setText("error saving new Clotho object, check selected fields");
       return;
     }
   } else {
     statusLabel.setText("Not all fields are filled");
     return;
   }
   if (newObject != null) {
     statusLabel.setText("saving: " + newObject.getName());
   }
   saved = newObject.saveDefault();
   coll.addObject(newObject);
   coll.saveDefault();
   Collector.add(newObject);
   if (saved) {
     statusLabel.setText("Successful save!");
     NucSeq.refreshFeatureTable();
     this.dispose();
   }
 } // GEN-LAST:event_saveButtonActionPerformed
Esempio n. 3
0
  @Override
  public NucSeq generatePlasmidSequence(Plasmid p) {
    String out = "";
    out += p.getPart().getSeq().getSeq();
    out += p.getVector().getSeq().getSeq();
    NucSeq outnuc = new NucSeq(out);
    outnuc.setTransient();

    for (Annotation ann : p.getPart().getSeq().getAnnotations()) {
      Feature afeature = ann.getFeature();
      String name = ann.getName();
      Color forColor = ann.getForwardColor();
      Color revColor = ann.getReverseColor();
      int Start = ann.getStart();
      int End = ann.getEnd();
      Person user = ann.getAuthor();
      boolean plusstrandtrue = ann.isForwardStrand();
      String symbol = ann.getSymbol();

      Annotation newann;
      if (afeature == null) {
        newann =
            new Annotation(
                name, outnuc, forColor, forColor, Start, End, user, plusstrandtrue, symbol);
        newann.setTransient();
      } else {
        newann =
            new Annotation(
                afeature, outnuc, forColor, revColor, Start, End, user, plusstrandtrue, symbol);
        newann.setTransient();
      }
      System.out.println("Generated annotation: " + newann.getName());
    }

    String parseq = p.getPart().getSeq().getSeq();
    int offset = parseq.length();

    for (Annotation ann : p.getVector().getSeq().getAnnotations()) {
      Feature afeature = ann.getFeature();
      String name = ann.getName();
      Color forColor = ann.getForwardColor();
      Color revColor = ann.getReverseColor();
      int Start = offset + ann.getStart();
      int End = offset + ann.getEnd();
      Person user = ann.getAuthor();
      boolean plusstrandtrue = ann.isForwardStrand();
      String symbol = ann.getSymbol();

      Annotation newann;
      if (afeature == null) {
        newann =
            new Annotation(
                name, outnuc, forColor, forColor, Start, End, user, plusstrandtrue, symbol);
        newann.setTransient();
      } else {
        newann =
            new Annotation(
                afeature, outnuc, forColor, revColor, Start, End, user, plusstrandtrue, symbol);
        newann.setTransient();
      }
      System.out.println("Generated annotation: " + newann.getName());
    }
    return outnuc;
  }