File: distcdataset.cpp

package info (click to toggle)
mothur 1.48.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 13,692 kB
  • sloc: cpp: 161,866; makefile: 122; sh: 31
file content (92 lines) | stat: -rw-r--r-- 3,515 bytes parent folder | download | duplicates (3)
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include "distcdataset.h"
#include "getdistscommand.h"
#include "listseqscommand.h"
#include "getseqscommand.h"

/***********************************************************************/
DistCDataSet::DistCDataSet() {
    m = MothurOut::getInstance();
    current = CurrentFile::getInstance();
    columnFile = "/Users/sarahwestcott/Desktop/mothur/TestMothur/TestFiles/stability.MISeq_SOP.trim.contigs.good.unique.good.filter.unique.precluster.pick.pick.pick.dist";
    countFile = "/Users/sarahwestcott/Desktop/mothur/TestMothur/TestFiles/stability.count_table";
}
/***********************************************************************/
vector<string> DistCDataSet::getFiles(int numSeqs) {
    vector<string> newFiles;
    
    if (numSeqs > 2055) { m->mothurOut("[ERROR]: too many seqs requested in DistCDataSet::getFiles\n"); }
    else {
        string inputString = "count=" + countFile;
        m->mothurOut("/******************************************/\n"); 
        m->mothurOut("Running command: list.seqs(" + inputString + ")\n"); 
        current->setMothurCalling(true);
        
        Command* listCommand = new ListSeqsCommand(inputString);
        listCommand->execute();
        
        map<string, vector<string> > filenames = listCommand->getOutputFiles();
        
        delete listCommand;
        current->setMothurCalling(false);
        
        string accnosfile = filenames["accnos"][0];
        m->mothurOut("/******************************************/\n"); 
        
        ifstream in;
        util.openInputFile(accnosfile, in);
        
        ofstream out;
        util.openOutputFile("temp.accnos", out);
        
        int count = 0; string name;
        while(!in.eof()) {
            if (m->getControl_pressed()) { break; }
            
            in >> name; util.gobble(in);
            out << name << endl;
            count++;
            
            if (count >= numSeqs) { break; }
        }
        in.close();
        out.close();
        util.mothurRemove(accnosfile);
        
        inputString = "count=" + countFile + ", accnos=temp.accnos";
        m->mothurOut("/******************************************/\n"); 
        m->mothurOut("Running command: get.seqs(" + inputString + ")\n"); 
        current->setMothurCalling(true);
        
        Command* getCommand = new GetSeqsCommand(inputString);
        getCommand->execute();
        
        filenames = getCommand->getOutputFiles();
        
        delete getCommand;
        current->setMothurCalling(false);
        
        string newCountfile = filenames["count"][0];
        m->mothurOut("/******************************************/\n"); 
        
        inputString = "column=" + columnFile + ", accnos=temp.accnos";
        m->mothurOut("/******************************************/\n"); 
        m->mothurOut("Running command: get.dists(" + inputString + ")\n"); 
        current->setMothurCalling(true);
        
        Command* getDCommand = new GetDistsCommand(inputString);
        getDCommand->execute();
        
        filenames = getDCommand->getOutputFiles();
        
        delete getDCommand;
        current->setMothurCalling(false);
        
        string newColumnfile = filenames["column"][0];
        m->mothurOut("/******************************************/\n"); 
        
        newFiles.push_back(newColumnfile); newFiles.push_back(newCountfile);
    }
    
    return newFiles;
}
/***********************************************************************/