Exemplo n.º 1
0
DuplicateMerger::DuplicateMerger(QWidget *parent) : QDialog(parent)
{
    setAttribute(Qt::WA_DeleteOnClose);
    resize(800,600);

    QWidget* top = new QWidget(this);
    QVBoxLayout* topLayout = new QVBoxLayout(top);
    setLayout(topLayout);
    topLayout->addWidget(top);

    QString txt = i18n("<p>Below is a list of all images that are duplicate in your database.<br/>"
                       "Select which you want merged, and which of the duplicates should be kept.<br/>"
                       "The tag and description from the deleted images will be transferred to the kept image</p>");
    QLabel* label = new QLabel(txt);
    QFont fnt = font();
    fnt.setPixelSize(18);
    label->setFont(fnt);
    topLayout->addWidget(label);

    m_trash = new QRadioButton(i18n("Move to &trash"));
    m_deleteFromDisk = new QRadioButton(i18n("&Delete from disk"));
    QRadioButton* blockFromDB = new QRadioButton(i18n("&Block from database"));
    m_trash->setChecked(true);

    topLayout->addSpacing(10);
    topLayout->addWidget(m_trash);
    topLayout->addWidget(m_deleteFromDisk);
    topLayout->addWidget(blockFromDB);
    topLayout->addSpacing(10);

    QScrollArea* scrollArea = new QScrollArea;
    topLayout->addWidget(scrollArea);
    scrollArea->setWidgetResizable(true);

    m_container = new QWidget(scrollArea);
    m_scrollLayout = new QVBoxLayout(m_container);
    scrollArea->setWidget(m_container);

    m_selectionCount = new QLabel;
    topLayout->addWidget(m_selectionCount);

    QDialogButtonBox* buttonBox = new QDialogButtonBox();

    m_selectAllButton = buttonBox->addButton(i18n("Select &All"), QDialogButtonBox::YesRole);
    m_selectNoneButton = buttonBox->addButton(i18n("Select &None"), QDialogButtonBox::NoRole);
    m_okButton = buttonBox->addButton(QDialogButtonBox::Ok);
    m_cancelButton = buttonBox->addButton(QDialogButtonBox::Cancel);

    connect(m_selectAllButton, SIGNAL(clicked()), this, SLOT(selectAll()));
    connect(m_selectNoneButton, SIGNAL(clicked()), this, SLOT(selectNone()));
    connect(m_okButton, SIGNAL(clicked()), this, SLOT(go()));
    connect(m_cancelButton, SIGNAL(clicked()), this, SLOT(reject()));

    topLayout->addWidget(buttonBox);

    findDuplicates();
}
Exemplo n.º 2
0
int main(void)
{
	int Input[] = {4,3,2,7,8,2,3,1};
	int InputSize = sizeof(Input)/sizeof(int);

	printf("The input is:\n");
	printArray(Input, InputSize);
	
	int returnSize;
	int *result = findDuplicates(Input, InputSize, &returnSize);

	printf("The duplicated numbers are:\n");
	printArray(result, returnSize);


	return 0;
}
Exemplo n.º 3
0
void ContactWidget::silentSetId(const int pId)
{
  disconnect(_first, SIGNAL(lostFocus()), this, SLOT(findDuplicates()));
  disconnect(_last, SIGNAL(lostFocus()), this, SLOT(findDuplicates()));
  if (pId == -1 || pId == 0)
  {
    _id = -1;
    _valid = false;
    connect(_first, SIGNAL(lostFocus()), this, SLOT(findDuplicates()));
    connect(_last, SIGNAL(lostFocus()), this, SLOT(findDuplicates()));
    clear();
  }
  else if (pId == _id)
    return;
  else
  {   
      XSqlQuery idQ;
      idQ.prepare(_query + " WHERE cntct_id = :id;");
      idQ.bindValue(":id", pId);
      idQ.exec();
      if (idQ.first())
      {
          _ignoreSignals = true;

          _id = pId;
          _valid = true;
          _number->setText(idQ.value("cntct_number").toString());
          _honorific->setEditText(idQ.value("cntct_honorific").toString());
          _first->setText(idQ.value("cntct_first_name").toString());
          _middle->setText(idQ.value("cntct_middle").toString());
          _last->setText(idQ.value("cntct_last_name").toString());
          _suffix->setText(idQ.value("cntct_suffix").toString());
          _initials->setText(idQ.value("cntct_initials").toString());
          _crmAcct->setId(idQ.value("cntct_crmacct_id").toInt());
          _title->setText(idQ.value("cntct_title").toString());
          _phone->setText(idQ.value("cntct_phone").toString());
          _phone2->setText(idQ.value("cntct_phone2").toString());
          _fax->setText(idQ.value("cntct_fax").toString());
          _email->setText(idQ.value("cntct_email").toString());
          _webaddr->setText(idQ.value("cntct_webaddr").toString());
          _address->setId(idQ.value("cntct_addr_id").toInt());
          _active->setChecked(idQ.value("cntct_active").toBool());
          _notes = idQ.value("cntct_notes").toString();
          _owner->setUsername(idQ.value("cntct_owner_username").toString());

          if (_mapper->model())
          { 	 
            _mapper->model()->setData(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(_number)),       _number->text()); 	               _mapper->model()->setData(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(_number)),       _number->text());
            _mapper->model()->setData(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(_honorific)),    _honorific->currentText()); 	 
            _mapper->model()->setData(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(_first)),        _first->text()); 	 
            _mapper->model()->setData(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(_last)),         _last->text()); 	 
            _mapper->model()->setData(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(_initials)),     _initials->text()); 	 
            _mapper->model()->setData(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(this)),          _number->text()); 	 
            _mapper->model()->setData(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(_title)),        _title->text()); 	 
            _mapper->model()->setData(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(_phone)),        _phone->text()); 	 
            _mapper->model()->setData(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(_phone2)),       _phone2->text()); 	 
            _mapper->model()->setData(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(_fax)),          _fax->text()); 	 
            _mapper->model()->setData(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(_email)),        _email->text()); 	 
            _mapper->model()->setData(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(_webaddr)),      _webaddr->text()); 	 
           }

          _ignoreSignals = false;
      }
      else if (idQ.lastError().type() != QSqlError::NoError)
          QMessageBox::critical(this, tr("A System Error Occurred at %1::%2.")
                                        .arg(__FILE__)
                                        .arg(__LINE__),
                                idQ.lastError().databaseText());
    _valid = true;
  }

  _changed=false;
  // _parsed = TRUE;
}
Exemplo n.º 4
0
void ContactWidget::init()
{
    _ignoreSignals = false;

    _titleSingular = tr("Contact");
    _titlePlural = tr("Contacts");
    _query = "SELECT cntct.*, crmacct_name "
	     "FROM cntct LEFT OUTER JOIN crmacct ON (cntct_crmacct_id = crmacct_id) ";

    _layoutDone = false;
    _minimalLayout = false;
    _searchAcctId = -1;

    _list = new QPushButton(tr("..."), this);
    _list->setObjectName("_list");
    _list->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);

  #ifndef Q_WS_MAC
    _list->setMaximumWidth(25);
  #else
    _list->setMinimumWidth(60);
    _list->setMinimumHeight(32);
  #endif

    _grid->removeWidget(_label);	// will be reinserted
    _grid->removeWidget(_description);
    delete _description;
    _description = 0;

    _grid->setMargin(0);
    _grid->setSpacing(2);

    _nameBox		= new QHBoxLayout;
    _nameBox->setSpacing(2);
    _initialsBox	= new QHBoxLayout;
    _initialsBox->setSpacing(2);
    _titleBox		= new QHBoxLayout;
    _titleBox->setSpacing(2);

    _change             = new XLineEdit(this);
    _numberLit		= new QLabel(tr("Number:"), this);
    _numberLit->setObjectName("_numberLit");
    _number		= new XLineEdit(this, "_number");
    
    _change->hide();
    _number->hide();
    _numberLit->hide();
    
    _nameLit		= new QLabel(tr("Name:"), this);
    _nameLit->setObjectName("_nameLit");
    _honorific		= new XComboBox(this, "_honorific");
    _first		= new XLineEdit(this, "_first");
    _middle		= new XLineEdit(this, "_middle");
    _middle->setFixedWidth(20);
    _last		= new XLineEdit(this, "_last");
    _suffix		= new XLineEdit(this, "_suffix");
    _suffix->setFixedWidth(30);
    _initialsLit	= new QLabel(tr("Initials:"), this);
    _initialsLit->setObjectName("_initialsLit");
    _initials		= new XLineEdit(this, "_initials");
    _initials->setFixedWidth(_initials->size().width() / 3);
    _titleLit		= new QLabel(tr("Job Title:"), this);
    _titleLit->setObjectName("_titleLit");
    _title		= new XLineEdit(this, "_title");

    _mapper		= new XDataWidgetMapper(this);

    //_nameBox->addWidget(_nameLit,	0);
    _nameBox->addWidget(_honorific,	0);
    _nameBox->addWidget(_first,		1);
    _nameBox->addWidget(_middle,	0);
    _nameBox->addWidget(_last,		2);
    _nameBox->addWidget(_suffix,	0);
    _nameBox->addWidget(_list,		0, Qt::AlignRight);
    
    //_initialsBox->addWidget(_initialsLit, 0);
    _initialsBox->addWidget(_initials,	  0);
    _initialsBox->addStretch(0);

    //_titleBox->addWidget(_titleLit,	0);
    _titleBox->addWidget(_title,	2);

    _buttonBox 		= new QGridLayout;
    _crmAcct		= new CRMAcctCluster(this, "_crmAcct");
    _active		= new QCheckBox(tr("Active"), this);
    _active->setObjectName("_active");
    _owner              = new UsernameCluster(this, "_owner");

    _buttonBox->addWidget(_crmAcct,	0, 1, Qt::AlignTop);
    _buttonBox->addWidget(_owner, 	0, 2, Qt::AlignTop);


    _phoneLit		= new QLabel(tr("Voice:"), this);
    _phoneLit->setObjectName("_phoneLit");
    _phone		= new XLineEdit(this, "_phone");
    _phone2Lit		= new QLabel(tr("Alternate:"), this);
    _phone2Lit->setObjectName("_phone2Lit");
    _phone2		= new XLineEdit(this, "_phone2");
    _faxLit		= new QLabel(tr("Fax:"), this);
    _faxLit->setObjectName("_faxLit");
    _fax		= new XLineEdit(this, "_fax");
    _emailLit		= new QLabel(tr("E-Mail:"), this);
    _emailLit->setObjectName("_emailLit");
    _email		= new XLineEdit(this, "_email");
    _webaddrLit		= new QLabel(tr("Web:"), this);
    _webaddrLit->setObjectName("_webaddrLit");
    _webaddr		= new XLineEdit(this, "_webaddr");
    _address		= new AddressCluster(this, "_address");

#if defined Q_OS_MAC
    _honorific->setMinimumHeight(26);
    _first->setMinimumHeight(22);
    _middle->setMinimumHeight(22);
    _last->setMinimumHeight(22);
    _suffix->setMinimumHeight(22);
    _phone->setMinimumWidth(140);
    _crmAcct->setMinimumHeight(72);
#endif    

    QPalette p = _email->palette();
    p.setColor(QPalette::Text, Qt::blue);
    _email->setPalette(p);
    _webaddr->setPalette(p);
    
    QFont newFont = _email->font();
    newFont.setUnderline(TRUE);
    _email->setFont(newFont);
    _webaddr->setFont(newFont);

    _numberLit->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    _label->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
    _nameLit->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    _titleLit->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    _phoneLit->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    _phone2Lit->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    _faxLit->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    _emailLit->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    _initialsLit->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    _webaddrLit->setAlignment(Qt::AlignRight | Qt::AlignVCenter);

    _honorific->setEditable(true);
    _honorific->setType(XComboBox::Honorifics);

    _crmAcct->setLabel(tr("CRM Account:"));
    _owner->setLabel(tr("Owner:"));

    layout();

    connect(_list,	SIGNAL(clicked()),	this, SLOT(sEllipses()));

    connect(_honorific,	SIGNAL(newID(int)),		     this, SIGNAL(changed()));
    connect(_first,	SIGNAL(textChanged(const QString&)), this, SIGNAL(changed()));
    connect(_middle,	SIGNAL(textChanged(const QString&)), this, SIGNAL(changed()));
    connect(_last,	SIGNAL(textChanged(const QString&)), this, SIGNAL(changed()));
    connect(_suffix,	SIGNAL(textChanged(const QString&)), this, SIGNAL(changed()));
    connect(_initials,	SIGNAL(textChanged(const QString&)), this, SIGNAL(changed()));
    connect(_crmAcct,	SIGNAL(newId(int)),		     this, SIGNAL(changed()));
    connect(_title,	SIGNAL(textChanged(const QString&)), this, SIGNAL(changed()));
    connect(_phone,	SIGNAL(textChanged(const QString&)), this, SIGNAL(changed()));
    connect(_phone2,	SIGNAL(textChanged(const QString&)), this, SIGNAL(changed()));
    connect(_fax,	SIGNAL(textChanged(const QString&)), this, SIGNAL(changed()));
    connect(_email,	SIGNAL(textChanged(const QString&)), this, SIGNAL(changed()));
    connect(_webaddr,	SIGNAL(textChanged(const QString&)), this, SIGNAL(changed()));
    connect(_address,	SIGNAL(changed()),                   this, SIGNAL(changed()));
    connect(this,       SIGNAL(changed()),                   this, SLOT(setChanged()));

    connect(_honorific,	SIGNAL(newID(int)),  this, SLOT(sCheck()));
    connect(_first,	SIGNAL(lostFocus()), this, SLOT(sCheck()));
    connect(_middle,	SIGNAL(lostFocus()), this, SLOT(sCheck()));
    connect(_last,	SIGNAL(lostFocus()), this, SLOT(sCheck()));
    connect(_suffix,	SIGNAL(lostFocus()), this, SLOT(sCheck()));
    connect(_initials,	SIGNAL(lostFocus()), this, SLOT(sCheck()));
    connect(_crmAcct,	SIGNAL(newId(int)),  this, SLOT(sCheck()));
    connect(_title,	SIGNAL(lostFocus()), this, SLOT(sCheck()));
    connect(_phone,	SIGNAL(lostFocus()), this, SLOT(sCheck()));
    connect(_phone2,	SIGNAL(lostFocus()), this, SLOT(sCheck()));
    connect(_fax,	SIGNAL(lostFocus()), this, SLOT(sCheck()));
    connect(_email,	SIGNAL(lostFocus()), this, SLOT(sCheck()));
    connect(_webaddr,	SIGNAL(lostFocus()), this, SLOT(sCheck()));
    connect(_address,	SIGNAL(changed()),   this, SLOT(sCheck()));
    
    connect(_email,     SIGNAL(doubleClicked()), this, SLOT(sLaunchEmail()));
    connect(_webaddr,   SIGNAL(doubleClicked()), this, SLOT(sLaunchWebaddr()));
    
    setListVisible(true);
    
    connect(_first, SIGNAL(lostFocus()), this, SLOT(findDuplicates()));
    connect(_last, SIGNAL(lostFocus()), this, SLOT(findDuplicates()));

    connect(_crmAcct, SIGNAL(newId(int)), this, SLOT(setSearchAcct(int)));

    setFocusPolicy(Qt::StrongFocus);
    setFocusProxy(_honorific);
    setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    setLabel("");
    _limits = 0;
    silentSetId(-1);
    setOwnerVisible(false);
    _mode = Edit;
}
Exemplo n.º 5
0
void driver(){
	Integer A[]={1,2,3,4,2,2,2,4};
	cout<<"duplicates are"<<findDuplicates(A,ARRAYSIZE(A))<<endl;
}
Exemplo n.º 6
0
Arquivo: leaff.C Projeto: ondovb/canu
void
processArray(int argc, char **argv) {

  int arg = 1;
  while (arg < argc) {

    if       ((strcmp(argv[arg], "-f") == 0) ||
              (strcmp(argv[arg], "-F") == 0)) {
      delete fasta;
      fasta = new seqCache(argv[++arg]);

    } else if (strcmp(argv[arg], "-i") == 0) {

      failIfNoSource();

      ++arg;
      if ((argv[arg] == 0L) || (argv[arg][0] == '-'))
        fprintf(stderr, "ERROR: next arg to -i should be 'name', I got '%s'\n",
                (argv[arg] == 0L) ? "(nullpointer)" : argv[arg]), exit(1);

      for (uint32 s=0; s<fasta->getNumberOfSequences(); s++)
        fprintf(stdout, "G\tseq\t%s:"F_U32"\t"F_U32"\t%s\n",
                argv[arg], s, fasta->getSequenceLength(s), ">unimplemented");

    } else if (strcmp(argv[arg], "-d") == 0) {
      failIfNoSource();
      printf(F_U32"\n", fasta->getNumberOfSequences());

    } else if (strcmp(argv[arg], "-L") == 0) {
      uint32 small = strtouint32(argv[++arg]);
      uint32 large = strtouint32(argv[++arg]);

      failIfNoSource();

      for (uint32 s=0; s<fasta->getNumberOfSequences(); s++)
        if ((small <= fasta->getSequenceLength(s)) && (fasta->getSequenceLength(s) < large))
          printSequence(s);

    } else if (strcmp(argv[arg], "-N") == 0) {
      double small = atof(argv[++arg]);
      double large = atof(argv[++arg]);

      failIfNoSource();

      for (uint32 s=0; s<fasta->getNumberOfSequences(); s++) {
        seqInCore *S   = fasta->getSequenceInCore(s);
        uint32     Ns  = 0;
        uint32     len = S->sequenceLength();
        char      *seq = S->sequence();

        for (uint32 i=begPos; i<len && i<endPos; i++)
          if ((seq[i] == 'n') || (seq[i] == 'N'))
            Ns++;

        double Np = 100.0 * Ns / len;

        if ((small <= Np) && (Np < large))
          printSequence(S);

        delete S;
      }

    } else if (strcmp(argv[arg], "-W") == 0) {
      failIfNoSource();

      for (uint32 s=0; s<fasta->getNumberOfSequences(); s++)
        printSequence(s);

    } else if (strcmp(argv[arg], "-G") == 0) {
      uint32 n = strtouint32(argv[++arg]);
      uint32 s = strtouint32(argv[++arg]);
      uint32 l = strtouint32(argv[++arg]);

      char      bases[4] = {'A', 'C', 'G', 'T'};
      char     *def      = new char [1024];
      char     *seq      = new char [l + 1];

      if (s == 0)
        s = 1;
      if (s > l)
        fprintf(stderr, "leaff: usage: -G num-seqs min-length max-length\n"), exit(1);

      for (uint32 i=0; i<n; i++) {
        uint32 j = s + ((l-s == 0) ? 0 : (MT.mtRandom32() % (l-s)));
        uint32 p = 0;

        while (p < j)
          seq[p++] = bases[MT.mtRandom32() & 0x3];
        seq[p] = 0;

        sprintf(def, "random%06"F_U32P, i);

        printSequence(def, seq, 0, j);
      }

      delete [] seq;
      delete [] def;

    } else if (strcmp(argv[arg], "-s") == 0) {
      failIfNoSource();
      failIfNotRandomAccess();  //  Easy to fix, just read the first N sequences
      printSequence(argv[++arg]);

    } else if (strcmp(argv[arg], "-S") == 0) {
      failIfNoSource();
      failIfNotRandomAccess();  //  Easy to fix, just read the first N sequences

      uint32 lowID  = fasta->getSequenceIID(argv[++arg]);
      uint32 highID = fasta->getSequenceIID(argv[++arg]);

      if (lowID > highID) {
        uint32 t = lowID;
        lowID    = highID;
        highID   = t;
      }

      for (uint32 s=lowID; (s <= highID) && (s <= fasta->getNumberOfSequences()); s++)
        printSequence(s);

    } else if (strcmp(argv[arg], "-r") == 0) {
      uint32 num = strtouint32(argv[++arg]);

      failIfNoSource();
      failIfNotRandomAccess();  //  Impossible to fix, or load whole thing into memory

      if (num >= fasta->getNumberOfSequences())
        num = fasta->getNumberOfSequences();

      uint32  *seqs = new uint32 [fasta->getNumberOfSequences()];

      for (uint32 i=0; i<fasta->getNumberOfSequences(); i++)
        seqs[i] = i;

      for (uint32 i=0; i<fasta->getNumberOfSequences(); i++) {
        uint32 j = MT.mtRandom32() % (fasta->getNumberOfSequences() - i) + i;
        uint32 t = seqs[j];
        seqs[j] = seqs[i];
        seqs[i] = t;
      }

      for (uint32 i=0; i<num; i++)
        printSequence(seqs[i]);

      delete [] seqs;

    } else if (strcmp(argv[arg], "-q") == 0) {
      failIfNoSource();
      failIfNotRandomAccess();  //  Impossible to fix, or load whole thing into memory
      printIDsFromFile(argv[++arg]);

    } else if (strcmp(argv[arg], "-6") == 0) {
      withLineBreaks = 60;
      if ((argv[arg+1] != 0L) && (argv[arg+1][0] != '-'))
        withLineBreaks = strtouint32(argv[++arg]);

    } else if (strcmp(argv[arg], "-w") == 0) {
      toUppercase = !toUppercase;
      for (int z=0; z<256; z++)
        translate[z] = (toUppercase) ? alphabet.toUpper(z) : (char)z;

    } else if (strcmp(argv[arg], "-R") == 0) {
      doReverse = !doReverse;

    } else if (strcmp(argv[arg], "-C") == 0) {
      doComplement = !doComplement;

    } else if (strcmp(argv[arg], "-H") == 0) {
      withDefLine    = !withDefLine;
      specialDefLine = 0L;

    } else if (strcmp(argv[arg], "-h") == 0) {
      withDefLine    = true;
      specialDefLine = argv[++arg];

    } else if (strcmp(argv[arg], "-e") == 0) {
      begPos = strtouint32(argv[++arg]);
      endPos = strtouint32(argv[++arg]);

    } else if (strcmp(argv[arg], "-ends") == 0) {
      endExtract = strtouint32(argv[++arg]);

    } else if (strcmp(argv[arg], "-A") == 0) {
      processFile(argv[++arg]);



    } else if (strcmp(argv[arg], "--findduplicates") == 0) {
      findDuplicates(argv[++arg]);
      exit(0);

    } else if (strcmp(argv[arg], "--mapduplicates") == 0) {
      mapDuplicates(argv[arg+1], argv[arg+2]);
      exit(0);

    } else if (strcmp(argv[arg], "--md5") == 0) {
      md5_s     md5;
      char      sum[33];

      fasta = new seqCache(argv[++arg]);

      for (uint32 s=0; s<fasta->getNumberOfSequences(); s++) {
        seqInCore *S = fasta->getSequenceInCore(s);
        fprintf(stdout, "%s %s\n",
                md5_toascii(md5_string(&md5, S->sequence(), S->sequenceLength()), sum),
                S->header());
        delete S;
      }
      delete fasta;
      exit(0);

    } else if ((strcmp(argv[arg], "--partition") == 0) ||
               (strcmp(argv[arg], "--partitionmap") == 0)) {

      char *prefix = 0L;
      if (strcmp(argv[arg], "--partition") == 0)
        prefix = argv[++arg];

      //  does the next arg end with gbp, mbp, kbp or bp?  If so,
      //  partition by length, else partition into buckets.
      //
      int     al = strlen(argv[arg+1]);
      uint64  ps = strtouint64(argv[arg+1]);

      char a3 = (al<3) ? '0' : alphabet.toLower(argv[arg+1][al-3]);
      char a2 = (al<2) ? '0' : alphabet.toLower(argv[arg+1][al-2]);
      char a1 = (al<1) ? '0' : alphabet.toLower(argv[arg+1][al-1]);

      //  partition!

      if (!isdigit(a1) || !isdigit(a2) || !isdigit(a3)) {
        if        ((a3 == 'g') && (a2 == 'b') && (a1 == 'p')) {
          ps *= 1000000000;
        } else if ((a3 == 'm') && (a2 == 'b') && (a1 == 'p')) {
          ps *= 1000000;
        } else if ((a3 == 'k') && (a2 == 'b') && (a1 == 'p')) {
          ps *= 1000;
        } else if (isdigit(a3) && (a2 == 'b') && (a1 == 'p')) {
          ps *= 1;
        } else {
          fprintf(stderr, "Unknown partition size option '%s'\n", argv[arg+1]), exit(1);
        }

        if (ps == 0)
          fprintf(stderr, "Unknown or zero partition size '%s'\n", argv[arg+1]), exit(1);
        partitionBySize(prefix, ps, argv[arg+2]);
      } else {
        if (ps == 0)
          fprintf(stderr, "Unknown or zero partition size '%s'\n", argv[arg+1]), exit(1);
        partitionByBucket(prefix, ps, argv[arg+2]);
      }
      exit(0);

    } else if (strcmp(argv[arg], "--segment") == 0) {
      partitionBySegment(argv[arg+1], strtouint32(argv[arg+2]), argv[arg+3]);
      exit(0);

    } else if (strcmp(argv[arg], "--gccontent") == 0) {
      computeGCcontent(argv[++arg]);
      exit(0);

    } else if (strcmp(argv[arg], "--dumpblocks") == 0) {
      dumpBlocks(argv[++arg]);
      exit(0);

    } else if (strcmp(argv[arg], "--stats") == 0) {
      stats(argv[arg+1], (argv[arg+2] != 0L) ? strtouint64(argv[arg+2]) : 0);
      exit(0);

    } else if (strcmp(argv[arg], "--errors") == 0) {
      int    L = strtouint32(argv[++arg]);     //  Desired length
      int    l = 0;                            //  min of desired length, length of sequence
      int    N = strtouint32(argv[++arg]);     //  number of copies per sequence
      int    C = strtouint32(argv[++arg]);     //  number of mutations per copy
      double P = atof(argv[++arg]);            //  probability of mutation
      uint32 i = 0;

      fasta = new seqCache(argv[++arg]);

      seqInCore *S = fasta->getSequenceInCore(i++);
      while (S) {
        char   *seq = S->sequence();
        char   *hdr = S->header();
        int     len = S->sequenceLength();

        l = len;
        if ((L > 0) && (L < len))
          l = L;

        simseq(seq, hdr, len, N, l, C, P);

        delete S;
        S = fasta->getSequenceInCore(i++);
      }
      delete fasta;
      exit(0);

    } else if (strcmp(argv[arg], "--seqstore") == 0) {
      constructSeqStore(argv[++arg], fasta);
      exit(0);

    } else if (strcmp(argv[arg], "-help") == 0) {
      if      ((argv[arg+1]) && (strcmp(argv[arg+1], "analysis") == 0))
        helpAnalysis(argv[0]);
      else if ((argv[arg+1]) && (strcmp(argv[arg+1], "examples") == 0))
        helpExamples(argv[0]);
      else
        helpStandard(argv[0]);
      exit(0);

    } else {
      helpStandard(argv[0]);
      fprintf(stderr, "Unknown option '%s'\n", argv[arg]);
      exit(1);
    }

    arg++;
  }

  delete fasta;
  fasta = 0L;
}