-
Notifications
You must be signed in to change notification settings - Fork 119
/
gfm.cpp
72 lines (63 loc) · 2.27 KB
/
gfm.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
* Copyright 2015, Daehwan Kim <[email protected]>
*
* This file is part of HISAT 2.
*
* HISAT 2 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 3 of the License, or
* (at your option) any later version.
*
* HISAT 2 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 HISAT 2. If not, see <http://www.gnu.org/licenses/>.
*/
#include <string>
#include "gfm.h"
using namespace std;
#ifdef BOWTIE_64BIT_INDEX
const std::string gfm_ext("ht2l");
#else
const std::string gfm_ext("ht2");
#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
* "$HISAT2_INDEXES/".
*/
string adjustEbwtBase(const string& cmdline,
const string& gfmFileBase,
bool verbose)
{
string str = gfmFileBase;
ifstream in;
if(verbose) cout << "Trying " << str.c_str() << endl;
in.open((str + ".1." + gfm_ext).c_str(), ios_base::in | ios::binary);
if(!in.is_open()) {
if(verbose) cout << " didn't work" << endl;
in.close();
if(getenv("HISAT2_INDEXES") != NULL) {
str = string(getenv("HISAT2_INDEXES")) + "/" + gfmFileBase;
if(verbose) cout << "Trying " << str.c_str() << endl;
in.open((str + ".1." + gfm_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 HISAT2 index corresponding to basename \"" << gfmFileBase.c_str() << "\"" << endl;
throw 1;
}
return str;
}