Commits

Casey Greene  committed 7369876

open dabs as pcls when needed, but don't dramatically alter whitespace

  • Participants
  • Parent commits 4d10998

Comments (0)

Files changed (2)

 const char CPCLImpl::c_szOne[] = "1";
 const char CPCLImpl::c_szExtension[] = ".pcl";
 const char CPCLImpl::c_szBinExtension[] = ".bin";
+const char CPCLImpl::c_szDabExtension[] = ".dab";
 
 struct SNeighbors {
 	CFullMatrix<pair<size_t, float> > m_MatNeighbors;
 
 bool CPCL::Open(const char* szFile, size_t iSkip, bool Memmap) {
 	bool isBinary = false;
+	bool isDAB = false;
 	ifstream ifsm;
 	if (!strcmp(szFile + strlen(szFile) - strlen(c_szBinExtension), c_szBinExtension)) {
 		isBinary = true;
 	}
+	if (!strcmp(szFile + strlen(szFile) - strlen(c_szDabExtension), c_szDabExtension)) {
+		isDAB = true;
+	}
 	if (isBinary && Memmap) {
 		g_CatSleipnir().notice("CPCL::Open, openning with memory mapping");
 		Reset();
 	else if (isBinary) {
 		ifsm.open(szFile, ios::binary);
 		return OpenBinary(ifsm);
+	} else if (isDAB) {
+		CDat dat;
+		if (!dat.Open(szFile,false, 0, false, false)) {
+		    cerr << "Could not open dab to make pcl." << endl;
+		    return false;
+		}
+		std::vector<std::string> features;
+		std::vector<std::string> genes = dat.GetGeneNames();
+		Open(genes, genes, features);
+		for (size_t i = 0; i < dat.GetGenes(); i++) {
+		    for (size_t j = i; j < dat.GetGenes(); j++) {
+			if (i == j) {
+			    Set(i, j, 1);
+			}
+			else {
+			    float pairVal = dat.Get(i,j);
+			    Set(i, j, pairVal);
+			    Set(j, i, pairVal);
+			}
+		    }
+		}
+		return true;
 	} else {
 		ifstream ifsm;
 		if (szFile)
 	static const char c_szOne[];
 	static const char c_szExtension[];
 	static const char c_szBinExtension[];
+	static const char c_szDabExtension[];
 
 	typedef std::vector<std::string> TVecStr;
 	typedef std::set<size_t> TSetI;