Permalink
Browse files

Adds timestamp check to reference shortcut files

  • Loading branch information...
1 parent 1f88637 commit 1e4fe9813a523f5d7e19b2a094ef6f6ab05dfc9f @mothur-westcott mothur-westcott committed Jul 11, 2016
@@ -45,6 +45,12 @@ void Classify::generateDatabaseAndNames(string tfile, string tempFile, string me
ifstream kmerFileTest(kmerDBName.c_str());
if(kmerFileTest){
bool GoodFile = m->checkReleaseVersion(kmerFileTest, m->getVersion());
+ int shortcutTimeStamp = m->getTimeStamp(kmerDBName);
+ int referenceTimeStamp = m->getTimeStamp(tempFile);
+
+ //if the shortcut file is older then the reference file, remake shortcut file
+ if (shortcutTimeStamp < referenceTimeStamp) { GoodFile = false; }
+
if (GoodFile) { needToGenerate = false; }
}
}
@@ -188,9 +188,9 @@ static DWORD WINAPI MyUchimeThreadFunction(LPVOID lpParam){
int error;
if (pDataArray->hasCount) {
- error = cparser->getSeqs(pDataArray->groups[i], pDataArray->filename, true); if ((error == 1) || pDataArray->m->control_pressed) { delete cparser; return 0; }
+ error = cparser->getSeqs(pDataArray->groups[i], pDataArray->filename, "/ab=", "/", true); if ((error == 1) || pDataArray->m->control_pressed) { delete cparser; return 0; }
}else {
- error = parser->getSeqs(pDataArray->groups[i], pDataArray->filename, true); if ((error == 1) || pDataArray->m->control_pressed) { delete parser; return 0; }
+ error = parser->getSeqs(pDataArray->groups[i], pDataArray->filename, "/ab=", "/", true); if ((error == 1) || pDataArray->m->control_pressed) { delete parser; return 0; }
}
//int numSeqs = driver((outputFName + groups[i]), filename, (accnos+ groups[i]), (alns+ groups[i]), numChimeras);
@@ -67,13 +67,19 @@ AlignmentDB::AlignmentDB(string fastaFileName, string s, int kmerSize, float gap
string kmerDBName;
if(method == "kmer") {
search = new KmerDB(fastaFileName, kmerSize);
-
-
+
kmerDBName = fastaFileName.substr(0,fastaFileName.find_last_of(".")+1) + char('0'+ kmerSize) + "mer";
+
ifstream kmerFileTest(kmerDBName.c_str());
if(kmerFileTest){
bool GoodFile = m->checkReleaseVersion(kmerFileTest, m->getVersion());
+ int shortcutTimeStamp = m->getTimeStamp(kmerDBName);
+ int referenceTimeStamp = m->getTimeStamp(fastaFileName);
+
+ //if the shortcut file is older then the reference file, remake shortcut file
+ if (shortcutTimeStamp < referenceTimeStamp) { GoodFile = false; }
+
if (GoodFile) { needToGenerate = false; }
}
View
@@ -3927,27 +3927,6 @@ void MothurOut::splitAtDash(string& estim, vector<string>& container) {
string individual = "";
int estimLength = estim.size();
bool prevEscape = false;
- /*for(int i=0;i<estimLength;i++){
- if(prevEscape){
- individual += estim[i];
- prevEscape = false;
- }
- else{
- if(estim[i] == '\\'){
- prevEscape = true;
- }
- else if(estim[i] == '-'){
- container.push_back(individual);
- individual = "";
- prevEscape = false;
- }
- else{
- individual += estim[i];
- prevEscape = false;
- }
- }
- }*/
-
for(int i=0;i<estimLength;i++){
if(estim[i] == '-'){
@@ -3983,28 +3962,6 @@ void MothurOut::splitAtDash(string& estim, set<string>& container) {
string individual = "";
int estimLength = estim.size();
bool prevEscape = false;
- /*
- for(int i=0;i<estimLength;i++){
- if(prevEscape){
- individual += estim[i];
- prevEscape = false;
- }
- else{
- if(estim[i] == '\\'){
- prevEscape = true;
- }
- else if(estim[i] == '-'){
- container.insert(individual);
- individual = "";
- prevEscape = false;
- }
- else{
- individual += estim[i];
- prevEscape = false;
- }
- }
- }
- */
for(int i=0;i<estimLength;i++){
if(estim[i] == '-'){
@@ -4038,28 +3995,6 @@ void MothurOut::splitAtDash(string& estim, set<int>& container) {
int lineNum;
int estimLength = estim.size();
bool prevEscape = false;
- /*
- for(int i=0;i<estimLength;i++){
- if(prevEscape){
- individual += estim[i];
- prevEscape = false;
- }
- else{
- if(estim[i] == '\\'){
- prevEscape = true;
- }
- else if(estim[i] == '-'){
- convert(individual, lineNum); //convert the string to int
- container.insert(lineNum);
- individual = "";
- prevEscape = false;
- }
- else{
- individual += estim[i];
- prevEscape = false;
- }
- }
- }*/
for(int i=0;i<estimLength;i++){
if(estim[i] == '-'){
@@ -4125,20 +4060,6 @@ void MothurOut::splitAtComma(string& estim, vector<string>& container) {
}
container.push_back(individual);
-
-
-
-// string individual;
-//
-// while (estim.find_first_of(',') != -1) {
-// individual = estim.substr(0,estim.find_first_of(','));
-// if ((estim.find_first_of(',')+1) <= estim.length()) { //checks to make sure you don't have comma at end of string
-// estim = estim.substr(estim.find_first_of(',')+1, estim.length());
-// container.push_back(individual);
-// }
-// }
-// //get last one
-// container.push_back(estim);
}
catch(exception& e) {
errorOut(e, "MothurOut", "splitAtComma");
@@ -4163,18 +4084,6 @@ void MothurOut::splitAtChar(string& prefix, string& suffix, char c){
}
}
-
- /*
-
- prefix = suffix.substr(0,suffix.find_first_of(c));
- if ((suffix.find_first_of(c)+2) <= suffix.length()) { //checks to make sure you don't have comma at end of string
- suffix = suffix.substr(suffix.find_first_of(c)+1, suffix.length());
- string space = " ";
- while(suffix.at(0) == ' ')
- suffix = suffix.substr(1, suffix.length());
- }else { suffix = ""; }
- */
-
}
catch(exception& e) {
errorOut(e, "MothurOut", "splitAtChar");
@@ -4430,6 +4339,63 @@ bool MothurOut::checkReleaseVersion(ifstream& file, string version) {
}
}
/**************************************************************************************************/
+int MothurOut::getTimeStamp(string filename) {
+ try {
+ int timeStamp = 0;
+
+#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
+ struct stat st;
+ int errorCode = stat (filename.c_str(), &st);
+ if (errorCode != 0) {
+ mothurOut("[ERROR]: Can't find timestamp for " + filename + "\n"); control_pressed = true;
+ }else {
+ timeStamp = st.st_mtime;
+ }
+#else
+ HANDLE hFile;
+
+ hFile = CreateFile(filename.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL,
+ OPEN_EXISTING, 0, NULL);
+
+ if(hFile == INVALID_HANDLE_VALUE) {
+ mothurOut("[ERROR]: Can't find timestamp for " + filename + "\n"); control_pressed = true;
+ return timestamp;
+ }
+
+ FILETIME ftCreate, ftAccess, ftWrite;
+ SYSTEMTIME stUTC;
+ DWORD dwRet;
+
+ // Retrieve the file times for the file.
+ bool success = GetFileTime(hFile, &ftCreate, &ftAccess, &ftWrite);
+
+ if (success) {
+ FileTimeToSystemTime(&ftWrite, &stUTC);
+
+ tm time;
+ time.tm_sec = stUTC.wSecond;
+ time.tm_min = stUTC.wMinute;
+ time.tm_hour = stUTC.wHour;
+ time.tm_mday = stUTC.wDay;
+ time.tm_mon = stUTC.wMonth - 1;
+ time.tm_year = stUTC.wYear - 1900;
+ time.tm_isdst = -1;
+ time_t t = mktime(&time);
+
+ timeStamp = t;
+ }
+ else { mothurOut("[ERROR]: Can't find timestamp for " + filename + "\n"); control_pressed = true; }
+
+#endif
+
+ return timeStamp;
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "getTimeStamp");
+ exit(1);
+ }
+}
+/**************************************************************************************************/
vector<double> MothurOut::getAverages(vector< vector<double> >& dists) {
try{
vector<double> averages; //averages.resize(numComp, 0.0);
View
@@ -150,6 +150,7 @@ class MothurOut {
//searchs and checks
bool checkReleaseVersion(ifstream&, string);
+ int getTimeStamp(string filename);
bool anyLabelsToProcess(string, set<string>&, string);
bool inUsersGroups(vector<string>, vector<string>); //returns true if any of the strings in first vector are in second vector
bool inUsersGroups(vector<int>, vector< vector<int> >);
View
@@ -1615,7 +1615,7 @@ vector<int> TrimOligos::stripForward(Sequence& forwardSeq, Sequence& reverseSeq,
//check for reverse match
if (alignment != NULL) { delete alignment; }
- if (irbarcodes.size() > 0) { alignment = new NeedlemanOverlap(-1.0, 1.0, -1.0, (maxRPrimerLength+pdiffs+1)); }
+ if (irprimers.size() > 0) { alignment = new NeedlemanOverlap(-1.0, 1.0, -1.0, (maxRPrimerLength+pdiffs+1)); }
else{ alignment = NULL; }
//can you find the barcode

0 comments on commit 1e4fe98

Please sign in to comment.