[Genabel-commits] r1729 - in pkg/ProbABEL: . src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon May 19 16:27:43 CEST 2014
Author: lckarssen
Date: 2014-05-19 16:27:43 +0200 (Mon, 19 May 2014)
New Revision: 1729
Added:
pkg/ProbABEL/src/invsigma.cpp
pkg/ProbABEL/src/invsigma.h
pkg/ProbABEL/src/mlinfo.cpp
pkg/ProbABEL/src/mlinfo.h
Removed:
pkg/ProbABEL/src/data.cpp
pkg/ProbABEL/src/data.h
Modified:
pkg/ProbABEL/configure.ac
pkg/ProbABEL/src/Makefile.am
pkg/ProbABEL/src/coxph_data.cpp
pkg/ProbABEL/src/coxph_data.h
pkg/ProbABEL/src/main.cpp
pkg/ProbABEL/src/main_functions_dump.cpp
Log:
Moved the definition and implementation of the mlinfo class from data.{h,cpp} to mlinfo.{h,cpp}.
The remaining parts in data.{h,cpp} were the definition and implementation of the InvSigma class, so this change also renames data.{h,cpp} to invsigma.{h,cpp}.
Modified: pkg/ProbABEL/configure.ac
===================================================================
--- pkg/ProbABEL/configure.ac 2014-05-19 14:17:58 UTC (rev 1728)
+++ pkg/ProbABEL/configure.ac 2014-05-19 14:27:43 UTC (rev 1729)
@@ -4,7 +4,7 @@
AC_INIT(ProbABEL, 0.4.3, genabel-devel at r-forge.wu-wien.ac.at)
AM_INIT_AUTOMAKE([silent-rules subdir-objects])
AM_SILENT_RULES([yes])
-AC_CONFIG_SRCDIR([src/data.h])
+AC_CONFIG_SRCDIR([src/mlinfo.h])
AC_CONFIG_HEADERS([src/config.h])
# Add the --disable-maintainer-mode option used by e.g. Debian and
Modified: pkg/ProbABEL/src/Makefile.am
===================================================================
--- pkg/ProbABEL/src/Makefile.am 2014-05-19 14:17:58 UTC (rev 1728)
+++ pkg/ProbABEL/src/Makefile.am 2014-05-19 14:27:43 UTC (rev 1729)
@@ -3,12 +3,19 @@
## Using wildcards in these lists doesn't work. Also GNU make's
## ($wildcard,) doesn't work. It gives warning message about
## portability, but in the end doesn't work, I tried :-).
-REGFILES = data.h data.cpp gendata.h gendata.cpp eigen_mematrix.h \
- eigen_mematrix.cpp command_line_settings.h command_line_settings.cpp \
- reg1.h usage.h usage.cpp main.cpp utilities.h utilities.cpp \
- phedata.h phedata.cpp regdata.h regdata.cpp maskedmatrix.cpp \
- maskedmatrix.h reg1.cpp main_functions_dump.h \
- main_functions_dump.cpp
+REGFILES = main.cpp \
+ invsigma.h invsigma.cpp \
+ gendata.h gendata.cpp \
+ eigen_mematrix.h eigen_mematrix.cpp \
+ command_line_settings.h command_line_settings.cpp \
+ reg1.h reg1.cpp \
+ usage.h usage.cpp \
+ utilities.h utilities.cpp \
+ phedata.h phedata.cpp \
+ regdata.h regdata.cpp \
+ maskedmatrix.h maskedmatrix.cpp \
+ main_functions_dump.h main_functions_dump.cpp \
+ mlinfo.h mlinfo.cpp
## Filevector files:
Modified: pkg/ProbABEL/src/coxph_data.cpp
===================================================================
--- pkg/ProbABEL/src/coxph_data.cpp 2014-05-19 14:17:58 UTC (rev 1728)
+++ pkg/ProbABEL/src/coxph_data.cpp 2014-05-19 14:27:43 UTC (rev 1729)
@@ -34,7 +34,6 @@
#include "survproto.h"
}
-// #include "reg1.h"
#include "fvlib/AbstractMatrix.h"
#include "fvlib/CastUtils.h"
#include "fvlib/const.h"
Modified: pkg/ProbABEL/src/coxph_data.h
===================================================================
--- pkg/ProbABEL/src/coxph_data.h 2014-05-19 14:17:58 UTC (rev 1728)
+++ pkg/ProbABEL/src/coxph_data.h 2014-05-19 14:27:43 UTC (rev 1729)
@@ -37,14 +37,11 @@
#define COXPH_DATA_H_
#include "eigen_mematrix.h"
-#include "eigen_mematrix.cpp"
-
-#include "data.h"
-#include "reg1.h"
#include "gendata.h"
+#include "mlinfo.h"
#include "phedata.h"
+#include "reg1.h"
-
/**
* \brief A coxph_data object contains the data used for Cox PH
* regression.
Deleted: pkg/ProbABEL/src/data.cpp
===================================================================
--- pkg/ProbABEL/src/data.cpp 2014-05-19 14:17:58 UTC (rev 1728)
+++ pkg/ProbABEL/src/data.cpp 2014-05-19 14:27:43 UTC (rev 1729)
@@ -1,224 +0,0 @@
-/*
- *
- * Copyright (C) 2009--2014 Various members of the GenABEL team. See
- * the SVN commit logs for more details.
- *
- * 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.
- *
- */
-
-
-#include <string>
-#include <sstream>
-#include <fstream>
-
-#include "fvlib/AbstractMatrix.h"
-#include "fvlib/CastUtils.h"
-#include "fvlib/const.h"
-#include "fvlib/convert_util.h"
-#include "fvlib/FileVector.h"
-#include "fvlib/frutil.h"
-#include "fvlib/frversion.h"
-#include "fvlib/Logger.h"
-#include "fvlib/Transposer.h"
-#include "phedata.h"
-#include "gendata.h"
-#include "data.h"
-
-#include "eigen_mematrix.h"
-#include "eigen_mematrix.cpp"
-#include "utilities.h"
-
-
-/**
- * Read SNP information from an mlinfo file generated by the
- * imputation software.
- *
- * \param filename Name of the mlinfo file
- * \param mapname Name of the map file
- */
-mlinfo::mlinfo(char * filename, char * mapname)
-{
- char tmp[1048576];
- unsigned int nlin = 0;
- std::ifstream infile(filename);
- if (infile.is_open())
- {
- while (infile.good())
- {
- infile >> tmp;
- nlin++;
- }
- nlin--; // Subtract one, the previous loop added 1 too much
- } else {
- std::cerr << "mlinfo: cannot open info file " << filename << endl;
- exit(1);
- }
- infile.close();
-
- if (nlin % 7)
- {
- std::cerr << "mlinfo: number of columns != 7 in " << filename << endl;
- exit(1);
- }
- nsnps = static_cast<int>((nlin / 7) - 1);
- std::cout << "Number of SNPs = " << nsnps << endl;
- name = new std::string[nsnps];
- A1 = new std::string[nsnps];
- A2 = new std::string[nsnps];
- Freq1 = new double[nsnps];
- MAF = new double[nsnps];
- Quality = new double[nsnps];
- Rsq = new double[nsnps];
- map = new std::string[nsnps];
-
- infile.open(filename);
- if (!infile)
- { // file couldn't be opened
- std::cerr << "mlinfo: cannot open info file " << filename << endl;
- exit(1);
- }
- /* Read the header and discard it */
- for (int i = 0; i < 7; i++)
- infile >> tmp;
-
- for (int i = 0; i < nsnps; i++)
- {
- infile >> tmp;
- name[i] = tmp;
- infile >> tmp;
- A1[i] = tmp;
- infile >> tmp;
- A2[i] = tmp;
- infile >> tmp;
- Freq1[i] = atof(tmp);
- infile >> tmp;
- MAF[i] = atof(tmp);
- infile >> tmp;
- Quality[i] = atof(tmp);
- infile >> tmp;
- Rsq[i] = atof(tmp);
- map[i] = "-999";
- }
- infile.close();
-
- if (mapname != NULL)
- {
- std::ifstream instr(mapname);
- int BFS = 1048576;
- char *line = new char[BFS];
- char *tmp = new char[BFS];
-
- if (!instr.is_open())
- {
- std::cerr << "mlinfo: cannot open map file " << mapname << endl;
- exit(1);
- }
-
- instr.getline(line, BFS);
-
- for (int i = 0; i < nsnps; i++)
- {
- instr.getline(line, BFS);
- std::stringstream line_stream(line);
- line_stream >> tmp >> map[i];
- }
-
- instr.close();
-
- delete[] line;
- delete[] tmp;
- }
-}
-
-mlinfo::~mlinfo()
-{
- delete[] mlinfo::name;
- delete[] mlinfo::A1;
- delete[] mlinfo::A2;
- delete[] mlinfo::Freq1;
- delete[] mlinfo::MAF;
- delete[] mlinfo::Quality;
- delete[] mlinfo::Rsq;
- delete[] mlinfo::map;
-}
-
-//_________________________________________Maksim_start
-
-InvSigma::InvSigma(const char * filename_, const phedata& phe) : filename(filename_)
-{
- npeople = phe.nids;
- std::ifstream myfile(filename_);
- char * line = new char[MAXIMUM_PEOPLE_AMOUNT];
- std::string id;
-
- matrix.reinit(npeople, npeople);
-
- // idnames[k], if (allmeasured[i]==1)
-
- if (myfile.is_open())
- {
- double val;
- unsigned row = 0;
- while (myfile.getline(line, MAXIMUM_PEOPLE_AMOUNT))
- {
- std::stringstream line_stream(line);
- line_stream >> id;
-
- if (phe.idnames[row] != id)
- {
- std::cerr << "error:in row " << row << " id="
- << phe.idnames[row]
- << " in inverse variance matrix but id=" << id
- << " must be there. Wrong inverse variance matrix"
- << " (only measured id must be there)\n";
- exit(1);
- }
- unsigned col = 0;
- while (line_stream >> val)
- {
- matrix.put(val, row, col);
- col++;
- }
-
- if (col != npeople)
- {
- std::cerr << "error: inv file: Number of columns in row "
- << row << " equals to " << col
- << " but number of people is " << npeople << "\n";
- myfile.close();
- exit(1);
- }
- row++;
- }
- myfile.close();
- } else {
- std::cerr << "error: inv file: cannot open file '"
- << filename_ << "'\n";
- }
-
- delete[] line;
-}
-
-
-InvSigma::~InvSigma()
-{
-}
-
-mematrix<double> & InvSigma::get_matrix(void)
-{
- return matrix;
-}
Deleted: pkg/ProbABEL/src/data.h
===================================================================
--- pkg/ProbABEL/src/data.h 2014-05-19 14:17:58 UTC (rev 1728)
+++ pkg/ProbABEL/src/data.h 2014-05-19 14:27:43 UTC (rev 1729)
@@ -1,83 +0,0 @@
-/**
- * \file data.h
- * \author mkooyman
- *
- * \brief Contains several classes we didn't put somewhere else yet
- *
- *
- * Copyright (C) 2009--2014 Various members of the GenABEL team. See
- * the SVN commit logs for more details.
- *
- * 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 DATA_H_
-#define DATA_H_
-#include <string>
-
-extern bool is_interaction_excluded;
-//TODO(unknown) This function is not used. Remove in near future
-//unsigned int Nmeasured(char * fname, int nphenocols, int npeople);
-#include "phedata.h"
-#include "gendata.h"
-
-/**
- * \brief Data from the mlinfo file.
- *
- */
-class mlinfo {
- public:
- int nsnps; /**< Number of SNPs */
- std::string * name; /**< Array of SNP names */
- std::string * A1; /**< Array with the first allele */
- std::string * A2; /**< Array with the second allele */
- double * Freq1;
- double * MAF; /**< The minor allele frequency */
- double * Quality; /**< The imputation quality metric */
- double * Rsq; /**< The imputation \f$R^2\f$ */
- std::string * map; /**< Array with the SNP positions */
- mlinfo()
- {
- Freq1 = NULL;
- MAF = NULL;
- Quality = NULL;
- Rsq = NULL;
- nsnps = 0;
- A1 = NULL;
- A2 = NULL;
- name = NULL;
- map = NULL;
- }
- mlinfo(char * filename, char * mapname);
- ~mlinfo();
-};
-
-class InvSigma {
- private:
- static const unsigned MAXIMUM_PEOPLE_AMOUNT = 1000000;
- unsigned int npeople; /* number of people */
- std::string filename;
- mematrix<double> matrix; /* file is stored here */
-
- public:
- InvSigma(const char * filename_, const phedata& phe);
- mematrix<double> & get_matrix();
- ~InvSigma();
-};
-
-#endif//DATA_H_
Copied: pkg/ProbABEL/src/invsigma.cpp (from rev 1725, pkg/ProbABEL/src/data.cpp)
===================================================================
--- pkg/ProbABEL/src/invsigma.cpp (rev 0)
+++ pkg/ProbABEL/src/invsigma.cpp 2014-05-19 14:27:43 UTC (rev 1729)
@@ -0,0 +1,115 @@
+/**
+ * \file invsigma.cpp
+ * \author mkooyman
+ *
+ * \brief Contains the implementation of the InvSigma class.
+ */
+/*
+ *
+ * Copyright (C) 2009--2014 Various members of the GenABEL team. See
+ * the SVN commit logs for more details.
+ *
+ * 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.
+ *
+ */
+
+
+#include <string>
+#include <sstream>
+#include <fstream>
+
+#include "fvlib/AbstractMatrix.h"
+#include "fvlib/CastUtils.h"
+#include "fvlib/const.h"
+#include "fvlib/convert_util.h"
+#include "fvlib/FileVector.h"
+#include "fvlib/frutil.h"
+#include "fvlib/frversion.h"
+#include "fvlib/Logger.h"
+#include "fvlib/Transposer.h"
+#include "invsigma.h"
+#include "phedata.h"
+#include "gendata.h"
+#include "eigen_mematrix.h"
+#include "eigen_mematrix.cpp"
+#include "utilities.h"
+
+
+InvSigma::InvSigma(const char * filename_, const phedata& phe) : filename(filename_)
+{
+ npeople = phe.nids;
+ std::ifstream myfile(filename_);
+ char * line = new char[MAXIMUM_PEOPLE_AMOUNT];
+ std::string id;
+
+ matrix.reinit(npeople, npeople);
+
+ // idnames[k], if (allmeasured[i]==1)
+
+ if (myfile.is_open())
+ {
+ double val;
+ unsigned row = 0;
+ while (myfile.getline(line, MAXIMUM_PEOPLE_AMOUNT))
+ {
+ std::stringstream line_stream(line);
+ line_stream >> id;
+
+ if (phe.idnames[row] != id)
+ {
+ std::cerr << "error:in row " << row << " id="
+ << phe.idnames[row]
+ << " in inverse variance matrix but id=" << id
+ << " must be there. Wrong inverse variance matrix"
+ << " (only measured id must be there)\n";
+ exit(1);
+ }
+ unsigned col = 0;
+ while (line_stream >> val)
+ {
+ matrix.put(val, row, col);
+ col++;
+ }
+
+ if (col != npeople)
+ {
+ std::cerr << "error: inv file: Number of columns in row "
+ << row << " equals to " << col
+ << " but number of people is " << npeople << "\n";
+ myfile.close();
+ exit(1);
+ }
+ row++;
+ }
+ myfile.close();
+ } else {
+ std::cerr << "error: inv file: cannot open file '"
+ << filename_ << "'\n";
+ }
+
+ delete[] line;
+}
+
+
+InvSigma::~InvSigma()
+{
+}
+
+
+mematrix<double> & InvSigma::get_matrix(void)
+{
+ return matrix;
+}
Copied: pkg/ProbABEL/src/invsigma.h (from rev 1725, pkg/ProbABEL/src/data.h)
===================================================================
--- pkg/ProbABEL/src/invsigma.h (rev 0)
+++ pkg/ProbABEL/src/invsigma.h 2014-05-19 14:27:43 UTC (rev 1729)
@@ -0,0 +1,53 @@
+/**
+ * \file invsigma.h
+ * \author mkooyman
+ *
+ * \brief Contains the definition of the InvSigma class.
+ */
+/*
+ * Copyright (C) 2009--2014 Various members of the GenABEL team. See
+ * the SVN commit logs for more details.
+ *
+ * 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 DATA_H_
+#define DATA_H_
+#include <string>
+
+extern bool is_interaction_excluded;
+//TODO(unknown) This function is not used. Remove in near future
+//unsigned int Nmeasured(char * fname, int nphenocols, int npeople);
+#include "phedata.h"
+#include "gendata.h"
+
+
+class InvSigma {
+ private:
+ static const unsigned MAXIMUM_PEOPLE_AMOUNT = 1000000;
+ unsigned int npeople; /* number of people */
+ std::string filename;
+ mematrix<double> matrix; /* file is stored here */
+
+ public:
+ InvSigma(const char * filename_, const phedata& phe);
+ mematrix<double> & get_matrix();
+ ~InvSigma();
+};
+
+#endif // DATA_H_
Modified: pkg/ProbABEL/src/main.cpp
===================================================================
--- pkg/ProbABEL/src/main.cpp 2014-05-19 14:17:58 UTC (rev 1728)
+++ pkg/ProbABEL/src/main.cpp 2014-05-19 14:27:43 UTC (rev 1729)
@@ -70,13 +70,13 @@
#include "eigen_mematrix.h"
#include "eigen_mematrix.cpp"
#include "maskedmatrix.h"
-#include "data.h"
#include "reg1.h"
#include "command_line_settings.h"
#include "coxph_data.h"
#include "main_functions_dump.h"
+#include "mlinfo.h"
+#include "invsigma.h"
-
/**
* Main routine. The main logic of ProbABEL can be found here
*
Modified: pkg/ProbABEL/src/main_functions_dump.cpp
===================================================================
--- pkg/ProbABEL/src/main_functions_dump.cpp 2014-05-19 14:17:58 UTC (rev 1728)
+++ pkg/ProbABEL/src/main_functions_dump.cpp 2014-05-19 14:27:43 UTC (rev 1729)
@@ -36,8 +36,9 @@
#include <vector>
#include "maskedmatrix.h"
+#include "mlinfo.h"
#include "phedata.h"
-#include "data.h"
+#include "invsigma.h"
#include "command_line_settings.h"
/**
Added: pkg/ProbABEL/src/mlinfo.cpp
===================================================================
--- pkg/ProbABEL/src/mlinfo.cpp (rev 0)
+++ pkg/ProbABEL/src/mlinfo.cpp 2014-05-19 14:27:43 UTC (rev 1729)
@@ -0,0 +1,147 @@
+/**
+ * \file mlinfo.cpp
+ * \author The GenABEL team
+ *
+ * \brief Contains the class implementation of the mlinfo class.
+ */
+/*
+ *
+ * Copyright (C) 2009--2014 Various members of the GenABEL team. See
+ * the SVN commit logs for more details.
+ *
+ * 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.
+ *
+ */
+
+
+#include <sstream>
+#include <fstream>
+#include <iostream>
+#include "mlinfo.h"
+
+
+/**
+ * Read SNP information from an mlinfo file generated by the
+ * imputation software.
+ *
+ * \param filename Name of the mlinfo file
+ * \param mapname Name of the map file
+ */
+mlinfo::mlinfo(char * filename, char * mapname)
+{
+ char tmp[1048576];
+ unsigned int nlin = 0;
+ std::ifstream infile(filename);
+ if (infile.is_open())
+ {
+ while (infile.good())
+ {
+ infile >> tmp;
+ nlin++;
+ }
+ nlin--; // Subtract one, the previous loop added 1 too much
+ } else {
+ std::cerr << "mlinfo: cannot open info file " << filename << std::endl;
+ exit(1);
+ }
+ infile.close();
+
+ if (nlin % 7)
+ {
+ std::cerr << "mlinfo: number of columns != 7 in " << filename << std::endl;
+ exit(1);
+ }
+ nsnps = static_cast<int>((nlin / 7) - 1);
+ std::cout << "Number of SNPs = " << nsnps << std::endl;
+ name = new std::string[nsnps];
+ A1 = new std::string[nsnps];
+ A2 = new std::string[nsnps];
+ Freq1 = new double[nsnps];
+ MAF = new double[nsnps];
+ Quality = new double[nsnps];
+ Rsq = new double[nsnps];
+ map = new std::string[nsnps];
+
+ infile.open(filename);
+ if (!infile)
+ { // file couldn't be opened
+ std::cerr << "mlinfo: cannot open info file " << filename << std::endl;
+ exit(1);
+ }
+ /* Read the header and discard it */
+ for (int i = 0; i < 7; i++)
+ infile >> tmp;
+
+ for (int i = 0; i < nsnps; i++)
+ {
+ infile >> tmp;
+ name[i] = tmp;
+ infile >> tmp;
+ A1[i] = tmp;
+ infile >> tmp;
+ A2[i] = tmp;
+ infile >> tmp;
+ Freq1[i] = atof(tmp);
+ infile >> tmp;
+ MAF[i] = atof(tmp);
+ infile >> tmp;
+ Quality[i] = atof(tmp);
+ infile >> tmp;
+ Rsq[i] = atof(tmp);
+ map[i] = "-999";
+ }
+ infile.close();
+
+ if (mapname != NULL)
+ {
+ std::ifstream instr(mapname);
+ int BFS = 1048576;
+ char *line = new char[BFS];
+ char *tmp = new char[BFS];
+
+ if (!instr.is_open())
+ {
+ std::cerr << "mlinfo: cannot open map file " << mapname << std::endl;
+ exit(1);
+ }
+
+ instr.getline(line, BFS);
+
+ for (int i = 0; i < nsnps; i++)
+ {
+ instr.getline(line, BFS);
+ std::stringstream line_stream(line);
+ line_stream >> tmp >> map[i];
+ }
+
+ instr.close();
+
+ delete[] line;
+ delete[] tmp;
+ }
+}
+
+mlinfo::~mlinfo()
+{
+ delete[] mlinfo::name;
+ delete[] mlinfo::A1;
+ delete[] mlinfo::A2;
+ delete[] mlinfo::Freq1;
+ delete[] mlinfo::MAF;
+ delete[] mlinfo::Quality;
+ delete[] mlinfo::Rsq;
+ delete[] mlinfo::map;
+}
Added: pkg/ProbABEL/src/mlinfo.h
===================================================================
--- pkg/ProbABEL/src/mlinfo.h (rev 0)
+++ pkg/ProbABEL/src/mlinfo.h 2014-05-19 14:27:43 UTC (rev 1729)
@@ -0,0 +1,70 @@
+/**
+ * \file mlinfo.h
+ * \author The GenABEL team
+ *
+ * \brief Contains the class information for the mlinfo class.
+ *
+ * The mlinfo class contains the information read from the .info of
+ * .mlinfo files.
+ *
+ */
+/* Copyright (C) 2009--2014 Various members of the GenABEL team. See
+ * the SVN commit logs for more details.
+ *
+ * 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 MLINFO_H_
+#define MLINFO_H_
+#include <string>
+#include <cstdlib>
+
+/**
+ * \brief Data from the mlinfo file.
+ *
+ */
+class mlinfo {
+ public:
+ int nsnps; /**< Number of SNPs */
+ std::string * name; /**< Array of SNP names */
+ std::string * A1; /**< Array with the first allele */
+ std::string * A2; /**< Array with the second allele */
+ double * Freq1;
+ double * MAF; /**< The minor allele frequency */
+ double * Quality; /**< The imputation quality metric */
+ double * Rsq; /**< The imputation \f$R^2\f$ */
+ std::string * map; /**< Array with the SNP positions */
+
+
+ // Constructors and destructors
+ mlinfo()
+ {
+ Freq1 = NULL;
+ MAF = NULL;
+ Quality = NULL;
+ Rsq = NULL;
+ nsnps = 0;
+ A1 = NULL;
+ A2 = NULL;
+ name = NULL;
+ map = NULL;
+ }
+ mlinfo(char * filename, char * mapname);
+ ~mlinfo();
+};
+
+#endif // MLINFO_H_
More information about the Genabel-commits
mailing list