예제 #1
0
  /** Make an EntryEdit component from the given Entry. */
  public static EntryEdit makeEntryEdit(final Entry entry) {
    final Bases bases = entry.getBases();
    final EntryGroup entry_group = new SimpleEntryGroup(bases);
    entry_group.add(entry);
    final EntryEdit entry_edit = new EntryEdit(entry_group);

    return entry_edit;
  }
예제 #2
0
  /** Read the entries given in the uk.ac.sanger.artemis.ini file. */
  private void readDefaultEntries() {
    final EntryInformation artemis_entry_information = Options.getArtemisEntryInformation();

    final String default_sequence_file_name = Options.getOptions().getDefaultSequenceFileName();

    final String default_feature_file_name = Options.getOptions().getDefaultFeatureFileName();

    if (default_sequence_file_name != null) {
      final String default_sequence_file_name_embl = default_sequence_file_name + "_embl";

      uk.ac.sanger.artemis.io.Entry new_embl_entry = null;

      // try opening the default sequence file with "_embl" added to the name
      // if that fails try the plain sequence file name

      final Document entry_document = DocumentFactory.makeDocument(default_sequence_file_name_embl);

      final InputStreamProgressListener progress_listener = getInputStreamProgressListener();

      entry_document.addInputStreamProgressListener(progress_listener);

      if (entry_document.readable()) {
        new_embl_entry =
            EntryFileDialog.getEntryFromFile(
                this, entry_document, artemis_entry_information, false);
      }

      if (new_embl_entry == null
          || new_embl_entry.getSequence() == null
          || new_embl_entry.getSequence().length() == 0) {
        final File entry_file = new File(default_sequence_file_name);

        if (entry_file.exists()) {
          new_embl_entry =
              EntryFileDialog.getEntryFromFile(
                  this, entry_document, artemis_entry_information, false);
        } else {
          // read failed
          System.err.println(
              "file does not exist: " + default_sequence_file_name + "(given in options files)");
          return;
        }
      }

      if (new_embl_entry == null
          || new_embl_entry.getSequence() == null
          || new_embl_entry.getSequence().length() == 0) {
        // read failed
        System.err.println(
            "failed to read " + default_sequence_file_name + "(given in options files)");
        return;
      }

      getStatusLabel().setText("");

      try {
        final Entry entry = new Entry(new_embl_entry);

        final EntryEdit new_entry_edit = makeEntryEdit(entry);

        new_entry_edit.setVisible(true);

        if (default_feature_file_name != null) {
          final Document feature_document = DocumentFactory.makeDocument(default_feature_file_name);

          final uk.ac.sanger.artemis.io.Entry new_embl_table_entry =
              EntryFileDialog.getEntryFromFile(
                  this, feature_document, artemis_entry_information, false);

          if (new_embl_table_entry == null) // open failed
          return;

          final EntryGroup entry_group = new_entry_edit.getEntryGroup();

          final Entry new_table_entry = new Entry(entry.getBases(), new_embl_table_entry);

          entry_group.add(new_table_entry);
        }
      } catch (OutOfRangeException e) {
        new MessageDialog(
            this,
            "read failed: one of the features in "
                + default_feature_file_name
                + " has an out of range location: "
                + e.getMessage());
      } catch (NoSequenceException e) {
        new MessageDialog(
            this, "read failed: " + new_embl_entry.getName() + " contains no sequence");
      }
    }
  }