-/***************************************************************************
- * Copyright (C) 2006 by Michael Andreen *
- * andreen@student.chalmers.se *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA *
- ***************************************************************************/
-
-#ifndef __GENEORDER_H__
-#define __GENEORDER_H__
-
-#include <vector>
-#include <stdexcept>
-#include <cstdlib>
-
-#include "misc.h"
-
-/**
- * Stores a gene order permutation and ensures that all genes are present and not duplicated.
- * \author Michael Andreen
-*/
-class GeneOrder{
- public:
-
- typedef std::vector<Gene> GeneList;
- typedef GeneList::size_type size_type;
-
- /**
- * Creates a copy of the given gene order
- */
- GeneOrder(const GeneOrder& go);
-
- /**
- * Creates a gene order from a given list.
- *
- * \throws invalid_argument if the list is not a valid permutation.
- */
- template<class T>
- GeneOrder(T begin, T end);
-
- /**
- * Destroyes the gene order.
- */
- ~GeneOrder();
-
- /**
- * Copies the given gene order.
- */
- const GeneOrder& operator=(const GeneOrder& go);
-
- /**
- * Returns the gene at the given index.
- *
- * \throws out_of_range if i is smaller than 0 or too big.
- */
- const Gene& operator[](size_type i) const;
-
- /**
- * Returns the size of the permutation.
- */
- int size() const;
-
- /**
- * Returns the vector containing the gene order permutation.
- */
- const GeneList& list() const;
-
- /**
- * Reverses an interval and returns the new permutation
- */
- GeneOrder reverse(size_type i, size_type j) const;
-
- /**
- * Moves the gene on position i to position j, returning a new permutation
- */
- GeneOrder transpos(size_type i, size_type j) const;
-
- private:
- GeneList _geneorder;
-};
-
-
-/**
- * Put all the genes in the list, check that all genes are included, pad with 0 and n+1 if needed.
- * TODO: This is far from done atm
- */
-template<typename T>
-GeneOrder::GeneOrder(T begin, T end): _geneorder(begin,end){
-
- /*TODO: Pad code, just not sure if I need it all the time.
- if (_geneorder[0] != 0)
- _geneorder.insert(_geneorder.begin(),0);
- if(_geneorder[_geneorder.size()-1] != _geneorder.size() - 1)
- _geneorder.push_back(_geneorder.size());
- */
-
- GeneList genes(_geneorder.size());
- for (GeneList::iterator gene = _geneorder.begin(); gene != _geneorder.end(); ++gene){
- ++genes[std::abs(*gene)];
- }
- for (GeneList::iterator gene = genes.begin(); gene != genes.end(); ++gene){
- if (*gene != 1)
- throw std::invalid_argument("Not all genes are present only 1 time");
- }
-}
-
-#endif
-