当前位置: 首页>>代码示例>>C++>>正文


C++ Sequence::get_id方法代码示例

本文整理汇总了C++中Sequence::get_id方法的典型用法代码示例。如果您正苦于以下问题:C++ Sequence::get_id方法的具体用法?C++ Sequence::get_id怎么用?C++ Sequence::get_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sequence的用法示例。


在下文中一共展示了Sequence::get_id方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: read_sequences

void SequenceCleaner::read_sequences (istream* pios) {
    Sequence seq;
    string retstring;
    int ft = test_seq_filetype_stream(*pios, retstring);
    int num_current_char = 0;
    bool first = true;
    
    while (read_next_seq_from_stream(*pios, ft, retstring, seq)) {
        sequences_[seq.get_id()] = seq.get_sequence();
        num_current_char = seq.get_sequence().size();
        if (first) {
            num_char_ = num_current_char; // just getting this from an arbitrary (first) sequence for now
            if (is_dna_) {
                string alpha_name = seq.get_alpha_name();
                if (alpha_name == "AA") {
                    is_dna_ = false;
                    //cout << "I believe this is a protein!" << endl;
                }
            }
            first = false;
            continue;
        } else {
            if (num_current_char != num_char_) {
                cout << "Error: sequences are not all of the same length. Exiting."
                    << endl;
                exit(0);
            }
        }
    }
    if (ft == 2) {
        sequences_[seq.get_id()] = seq.get_sequence();
        num_current_char = seq.get_sequence().size();
        if (num_current_char != num_char_) {
            cout << "Error: sequences are not all of the same length. Exiting."
                << endl;
            exit(0);
        }
    }
    num_taxa_ = sequences_.size();
}
开发者ID:FePhyFoFum,项目名称:phyx,代码行数:40,代码来源:clsq.cpp

示例2: while

NJOI::NJOI (istream* pios, int & threads):ntax_(0), nchar_(0), nthreads_(threads) {
    Sequence seq;
    string retstring;
    int ft = test_seq_filetype_stream(*pios, retstring);
    
    int seqcount = 0;
    // some error checking. should be in general seq reader class
    bool first = true;
    while (read_next_seq_from_stream(*pios, ft, retstring, seq)) {
        sequences_[seq.get_id()] = seq.get_sequence();
        if (!first) {
            if ((int)seq.get_length() != nchar_) {
                cout << "Error: sequence " << seq.get_id() << " has "
                    << seq.get_length() << " characters, was expecting " 
                    << nchar_ << "." << endl << "Exiting." << endl;
                exit(1);
            }
        } else {
            nchar_ = seq.get_length();
            first = false;
        }
        seqcount++;
    }
    //fasta has a trailing one
    if (ft == 2) {
        sequences_[seq.get_id()] = seq.get_sequence();
        if ((int)seq.get_length() != nchar_) {
            cout << "Error: sequence " << seq.get_id() << " has "
                << seq.get_length() << " characters, was expecting " 
                << nchar_ << "." << endl << "Exiting." << endl;
            exit(1);
        };
        seqcount++;
    }
    ntax_ = seqcount;
    set_name_key ();
    Matrix = BuildMatrix(sequences_);
    TREEMAKE(names_, name_key_, Matrix);
}
开发者ID:FePhyFoFum,项目名称:phyx,代码行数:39,代码来源:nj.cpp

示例3: main

int main(int argc, char * argv[]) {
    
    log_call(argc, argv);
    
    bool cfileset = false;
    bool tfileset = false;
    bool outfileset = false;
    
    char * treef = NULL;
    char * charf = NULL;
    char * outf = NULL;
    int analysis = 0;
    while (1) {
        int oi = -1;
        int c = getopt_long(argc, argv, "c:t:o:hV", long_options, &oi);
        if (c == -1) {
            break;
        }
        switch(c) {
            case 'c':
                cfileset = true;
                charf = strdup(optarg);
                check_file_exists(charf);
                break;
            case 't':
                tfileset = true;
                treef = strdup(optarg);
                check_file_exists(treef);
                break;
            case 'o':
                outfileset = true;
                outf = strdup(optarg);
                break;
            case 'h':
                print_help();
                exit(0);
            case 'V':
                cout << versionline << endl;
                exit(0);
            default:
                print_error(argv[0], (char)c);
                exit(0);
        }
    }

    istream * pios = NULL;
    istream * poos = NULL;
    ifstream * cfstr = NULL;
    ifstream * tfstr = NULL;

    ostream * poouts = NULL;
    ofstream * ofstr = NULL;
    

    if (tfileset == true) {
        tfstr = new ifstream(treef);
        poos = tfstr;
    } else {
        poos = &cin;
    }

    if (cfileset == true) {
        cfstr = new ifstream(charf);
        pios = cfstr;
    } else {
        cout << "you have to set a character file. Only a tree file can be read in through the stream;" << endl;
    }

    //out file
    //
    if (outfileset == true){
        ofstr = new ofstream(outf);
        poouts = ofstr;
    } else{
        poouts = &cout;
    }
    //

    string retstring;
    int ft = test_char_filetype_stream(*pios, retstring);
    if (ft != 1 && ft != 2) {
        cout << "only fasta and phylip (with spaces) supported so far" << endl;
        exit(0);
    }
    Sequence seq;
    vector <Sequence> seqs;
    map <string, int> seq_map;
    int y = 0;
    int nchars = 0 ;
    while (read_next_seq_char_from_stream(*pios, ft, retstring, seq)) {
        seqs.push_back(seq);
        nchars = seq.get_num_cont_char();
        seq_map[seq.get_id()] = y;
        seq.clear_cont_char();
        y++;
    }
    cout << "nchars: " <<  nchars << endl;
    
    if (ft == 2) {
        seqs.push_back(seq);
//.........这里部分代码省略.........
开发者ID:FePhyFoFum,项目名称:phyx,代码行数:101,代码来源:main_contbl.cpp

示例4: read_sequences

void SequenceConcatenater::read_sequences (string & seqf) {
    filename_ = seqf;
    string retstring;
    istream * pios = new ifstream(filename_);
    ft_ = test_seq_filetype_stream(*pios, retstring);
    Sequence seq;
    int counter = 0;
    int length = 0;
    
    // phylip (1) NEXUS (0)
    if (ft_ == 1 || ft_ == 0) {
        if (ft_ == 1) {
            vector <string> fileDim = tokenize(retstring);
            num_taxa_ = stoi(fileDim[0]);
            num_char_ = stoi(fileDim[1]);
        } else {
            get_nexus_dimensions_file(seqf, num_taxa_, num_char_, interleave_);
        }
        if (!interleave_) {
            while (read_next_seq_from_stream(*pios, ft_, retstring, seq)) {
                length = (int)seq.get_sequence().size();
                if (length != num_char_) {
                    cout << "Sequence '" << seq.get_id() << "' has " << length << " characters, but the file '"
                        << filename_ << "' specified " << num_char_ << " characters. Exiting." << endl;
                    delete pios;
                    exit(1);
                }
                if (toupcase_) {
                    seq.set_sequence(seq.seq_to_upper());
                }
                seqs_.push_back(seq);
                counter++;
            }
            if (counter != num_taxa_) {
                cout << "Read " << counter << " taxa, but the file '" << filename_ << "' specified "
                    << num_taxa_ << " taxa. Exiting." << endl;
                delete pios;
                exit(1);
            }
        } else {
            seqs_ = read_interleaved_nexus_file(seqf, num_taxa_, num_char_);
            if (toupcase_) {
                for (int i = 0; i < num_taxa_; i++) {
                    seqs_[i].set_sequence(seqs_[i].seq_to_upper());
                }
            }
        }
        
    } else if (ft_ == 2) { // fasta
        bool first = true;
        while (read_next_seq_from_stream(*pios, ft_, retstring, seq)) {
            int curr = (int)seq.get_sequence().size();
            if (!first) {
                if (curr != length) {
                    cout << "Error: current sequence has " << curr << " characters, but previous sequence had "
                        << length << " characters. Exiting." << endl;
                    delete pios;
                    exit(1);
                }
            } else {
                length = curr;
                first = false;
            }
            if (toupcase_) {
                seq.set_sequence(seq.seq_to_upper());
            }
            seqs_.push_back(seq);
            counter++;
        }
        // fasta has a trailing one
        if (toupcase_) {
            seq.set_sequence(seq.seq_to_upper());
        }
        seqs_.push_back(seq);
        counter++;
        num_taxa_ = counter;
        num_char_ = length;
    } else {
        cout << "I don't know what that alignment file format is! Exiting." << endl;
        exit(0);
    }
    num_partitions_ = 1;
    partition_sizes_.push_back(num_char_);
    delete pios;
}
开发者ID:FePhyFoFum,项目名称:phyx,代码行数:85,代码来源:concat.cpp

示例5: main

int main(int argc, char * argv[]) {
    
    log_call(argc, argv);
    
    bool outfileset = false;
    bool sfileset = false;
    bool cfileset = false;
    bool nfileset = false;
    bool verbose = false;
    char * outf = NULL;
    char * seqf = NULL;
    string cnamef = "";
    string nnamef = "";
    while (1) {
        int oi = -1;
        int c = getopt_long(argc, argv, "s:c:n:o:vhV", long_options, &oi);
        if (c == -1) {
            break;
        }
        switch(c) {
            case 's':
                sfileset = true;
                seqf = strdup(optarg);
                check_file_exists(seqf);
                break;
            case 'c':
                cfileset = true;
                cnamef = strdup(optarg);
                check_file_exists(cnamef.c_str());
                break;
            case 'n':
                nfileset = true;
                nnamef = strdup(optarg);
                check_file_exists(nnamef.c_str());
                break;
            case 'o':
                outfileset = true;
                outf = strdup(optarg);
                break;
            case 'v':
                verbose = true;
                break;
            case 'h':
                print_help();
                exit(0);
            case 'V':
                cout << versionline << endl;
                exit(0);
            default:
                print_error(argv[0], (char)c);
                exit(0);
        }
    }
    
    if (sfileset && outfileset) {
        check_inout_streams_identical(seqf, outf);
    }
    
    istream * pios = NULL;
    ostream * poos = NULL;
    ifstream * fstr = NULL;
    ofstream * ofstr = NULL;
    
    if (!nfileset | !cfileset) {
        cout << "Must supply both name files (-c for current, -n for new)." << endl;
        exit(0);
    }
    
    if (sfileset == true) {
        fstr = new ifstream(seqf);
        pios = fstr;
    } else {
        pios = &cin;
        if (check_for_input_to_stream() == false) {
            print_help();
            exit(1);
        }
    }
    if (outfileset == true) {
        ofstr = new ofstream(outf);
        poos = ofstr;
    } else {
        poos = &cout;
    }
    
    Relabel rl (cnamef, nnamef, verbose);
    
    set <string> orig = rl.get_names_to_replace();
    
    Sequence seq;
    string retstring;
    
    int ft = test_seq_filetype_stream(*pios, retstring);
    
    bool success = false;
    
    while (read_next_seq_from_stream(*pios, ft, retstring, seq)) {
        string terp = seq.get_id();
        success = rl.relabel_sequence(seq);
        if (success) {
//.........这里部分代码省略.........
开发者ID:FePhyFoFum,项目名称:phyx,代码行数:101,代码来源:main_rls.cpp

示例6: main


//.........这里部分代码省略.........
        dmatrix = aa_rmatrix;
    }
    
    istream * pios = NULL;
    ostream * poos = NULL;
    ifstream * fstr = NULL;
    ofstream * ofstr = NULL;
    
    if (outfileset == true) {
        ofstr = new ofstream(outf);
        poos = ofstr;
    } else {
        poos = &cout;
    }
    if (fileset == true) {
        fstr = new ifstream(treef);
        pios = fstr;
    } else {
        pios = &cin;
        if (check_for_input_to_stream() == false) {
            print_help();
            exit(1);
        }
    }
    
    
    /*
     * Default Base Frequencies and Rate Matrix
     *
     */
    //vector <double> basefreq(4, 0.0);
    //basefreq[0] = .25;
    //basefreq[1] = .25;
    //basefreq[2] = .25;
    //basefreq[3] = 1.0 - basefreq[0] - basefreq[1] - basefreq[2];
    /*    
    vector< vector <double> > rmatrix(4, vector<double>(4, 0.33));
    for (unsigned int i = 0; i < rmatrix.size(); i++) {
        for (unsigned int j = 0; j < rmatrix.size(); j++) {
            if (i == j) {//Fill Diagnol
                rmatrix[i][j] = -1.0;
            }
        }
    }
    */
    string retstring;
    int ft = test_tree_filetype_stream(*pios, retstring);
    if (ft != 0 && ft != 1) {
        cerr << "this really only works with nexus or newick" << endl;
        exit(0);
    }
    
    // allow > 1 tree in input. passing but not yet using nreps
    int treeCounter = 0;
    bool going = true;
    if (ft == 1) { // newick. easy
        Tree * tree;
        while (going) {
            tree = read_next_tree_from_stream_newick (*pios, retstring, &going);
            if (tree != NULL) {
                //cout << "Working on tree #" << treeCounter << endl;
                SequenceGenerator SGen(seqlen, basefreq, dmatrix, tree, showancs,
                    nreps, seed, alpha, pinvar, ancseq, printpost, multirates, aabasefreq, is_dna);
                vector <Sequence> seqs = SGen.get_sequences();
                for (unsigned int i = 0; i < seqs.size(); i++) {
                    Sequence seq = seqs[i];
                    (*poos) << ">" << seq.get_id() << endl;
                    //cout << "Here" << endl;
                    (*poos) << seq.get_sequence() << endl;
                }
                delete tree;
                treeCounter++;
            }
        }
    } else if (ft == 0) { // Nexus. need to worry about possible translation tables
        map <string, string> translation_table;
        bool ttexists;
        ttexists = get_nexus_translation_table(*pios, &translation_table, &retstring);
        Tree * tree;
        while (going) {
            tree = read_next_tree_from_stream_nexus(*pios, retstring, ttexists,
                &translation_table, &going);
            if (going == true) {
                cout << "Working on tree #" << treeCounter << endl;
                SequenceGenerator SGen(seqlen, basefreq, dmatrix, tree, showancs,
                    nreps, seed, alpha, pinvar, ancseq, printpost, multirates, aabasefreq, is_dna);
                vector <Sequence> seqs = SGen.get_sequences();
                for (unsigned int i = 0; i < seqs.size(); i++) {
                    Sequence seq = seqs[i];
                    (*poos) << ">" << seq.get_id() << endl;
                    (*poos) << seq.get_sequence() << endl;
                }
                delete tree;
                treeCounter++;
            }
        }
    }
    
    return EXIT_SUCCESS;
}
开发者ID:FePhyFoFum,项目名称:phyx,代码行数:101,代码来源:main_seqgen.cpp


注:本文中的Sequence::get_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。