Biorithm  1.1
 All Classes Functions Variables Typedefs Friends
gene.h
00001 /**************************************************************************
00002  * Copyright (c) 2002-2011 T. M. Murali                                   *
00003  * Copyright (c) 2010-2011 Christopher L. Poirel                          *
00004  *                                                                        *
00005  * This file is part of Biorithm.                                         *
00006  *                                                                        *
00007  * Biorithm is free software: you can redistribute it and/or modify       *
00008  * it under the terms of the GNU General Public License as published by   *
00009  * the Free Software Foundation, either version 3 of the License, or      *
00010  * (at your option) any later version.                                    *
00011  *                                                                        *
00012  * Biorithm is distributed in the hope that it will be useful,            *
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of         *
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
00015  * GNU General Public License for more details.                           *
00016  *                                                                        *
00017  * You should have received a copy of the GNU General Public License      *
00018  * along with Biorithm.  If not, see <http://www.gnu.org/licenses/>.      *
00019  *                                                                        *
00020  **************************************************************************/
00021 
00022 #ifndef _GENE_H
00023 #define _GENE_H
00024 
00025 #include "global.h"
00026 #include "read.h"
00027 
00028 // class for storing points.
00029 class MyAffyGene: public MyInfo
00030 {
00031 public:
00032   // constructors and destructors.
00033   MyAffyGene(MyString id = "", MyString sid = "")
00034       : MyInfo(id, sid)
00035     {}
00036 
00037   MyAffyGene(const MyAffyGene& copy)
00038       : MyInfo(copy)
00039     {}
00040 
00041   virtual ~MyAffyGene()
00042     {}
00043   
00044   // return a clone of MyAffyGene.
00045   virtual MyInfo* clone() const
00046     {
00047       MyAffyGene* clone = new MyAffyGene(*this);
00048       return(clone);
00049     }
00050 
00051   // numNames is a hacky way of specifying how many names the input
00052   // file contains for each gene. there must be a cleaner way of
00053   // passing the expected format of a line.
00054   void read(istream &istr, char delim = '\t', int numNames = 1);  
00055   void read(istream &istr, vector< MyNT >& coords, unsigned int& dimension, 
00056                   char delim = '\t', int numNames = 1, bool hasCallData = false);
00057   bool read(istream &istr, vector< MyNT >& coords, unsigned int& dimension,
00058                   const MyAffyFileFormat &format, 
00059                   set< unsigned int > &missing);
00060   
00061   void write(ostream &ostr) const
00062     {
00063       ostr << "Name = " << getName() << endl;
00064       ostr << "Short name = " << getShortName() << endl;
00065     }
00066 
00067   // add an index for which the expression value is missing.
00068   void addMissingIndex(unsigned int i)
00069   {
00070     missingIndices.insert(i);
00071   }
00072   
00073   // check if the expression value for an index is missing.
00074   bool isMissing(unsigned int i) const
00075   {
00076     return(missingIndices.end() != missingIndices.find(i));
00077   }
00078 
00079 private:
00080   set< unsigned int > missingIndices;
00081 };
00082 
00083 inline istream& operator>>(istream& istr, MyAffyGene &gene)
00084 {
00085   gene.read(istr);
00086   return istr;
00087 }
00088 
00089 inline ostream& operator<<(ostream& ostr, const MyAffyGene& gene)
00090 {
00091   gene.write(ostr);
00092   return ostr;
00093 }
00094 
00095 
00096 #endif // _GENE_H 
 All Classes Functions Variables Typedefs Friends