1 Star 0 Fork 0

Velcon-Zheng/bowtie

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
ebwt.cpp 2.19 KB
一键复制 编辑 原始数据 按行查看 历史
Rone Charles 提交于 2019-02-06 17:02 . Include bt2 indexes in index search
/*
* ebwt.cpp
*
* Created on: Sep 23, 2009
* Author: Ben Langmead
*/
#include <string>
#include <stdexcept>
#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <unistd.h>
using namespace std;
#ifdef BOWTIE_64BIT_INDEX
std::string gEbwt_ext("ebwtl");
std::string gBt2_ext("bt2l");
#else
std::string gEbwt_ext("ebwt");
std::string gBt2_ext("bt2");
#endif // BOWTIE_64BIT_INDEX
string gLastIOErrMsg;
/**
* Try to find the Bowtie index specified by the user. First try the
* exact path given by the user. Then try the user-provided string
* appended onto the path of the "indexes" subdirectory below this
* executable, then try the provided string appended onto
* "$BOWTIE_INDEXES/".
*/
string adjustEbwtBase(const string& cmdline,
const string& ebwtFileBase,
bool verbose = false)
{
string str = ebwtFileBase;
ifstream in;
if(verbose) cout << "Trying " << str << endl;
if (access((str + ".1." + gBt2_ext).c_str(), R_OK) == 0) {
gEbwt_ext = gBt2_ext;
}
in.open((str + ".1." + gEbwt_ext).c_str(), ios_base::in | ios::binary);
if(!in.is_open()) {
if(verbose) cout << " didn't work" << endl;
in.close();
str = cmdline;
size_t st = str.find_last_of("/\\");
if(st != string::npos) {
str.erase(st);
str += "/indexes/";
} else {
str = "indexes/";
}
str += ebwtFileBase;
if(verbose) cout << "Trying " << str << endl;
in.open((str + ".1." + gEbwt_ext).c_str(), ios_base::in | ios::binary);
if(!in.is_open()) {
if(verbose) cout << " didn't work" << endl;
in.close();
if(getenv("BOWTIE_INDEXES") != NULL) {
str = string(getenv("BOWTIE_INDEXES")) + "/" + ebwtFileBase;
if(verbose) cout << "Trying " << str << endl;
if (access((str + ".1." + gBt2_ext).c_str(), R_OK) == 0) {
gEbwt_ext = gBt2_ext;
}
in.open((str + ".1." + gEbwt_ext).c_str(), ios_base::in | ios::binary);
if(!in.is_open()) {
if(verbose) cout << " didn't work" << endl;
in.close();
} else {
if(verbose) cout << " worked" << endl;
}
}
}
}
if(!in.is_open()) {
cerr << "Could not locate a Bowtie index corresponding to basename \"" << ebwtFileBase << "\"" << endl;
throw 1;
}
return str;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/Velcon-Zheng/bowtie.git
git@gitee.com:Velcon-Zheng/bowtie.git
Velcon-Zheng
bowtie
bowtie
master

搜索帮助