score_t Phaser::aligner(size_t i_ini, size_t j_ini, size_t k_ini, size_t i_end, size_t j_end, size_t k_end) { size_t i_med, j_med, k_med; score_t ans = partial_aligner(i_ini, j_ini, k_ini, i_end, j_end, k_end, &i_med, &j_med, &k_med); if (verbose) { printf("%lu, %lu, %lu \n", k_ini, k_med, k_end); } bool p1 = false; bool p2 = false; score_t ans_1, ans_2; if (k_ini <= k_med && k_med != k_end && k_ini < k_med+1) { ans_1= aligner(i_ini, j_ini, k_ini, i_med, j_med, k_med); p1 = true; } if (k_med+1 <= k_end && k_ini < k_med+1) { ans_2= aligner(i_med + 1, j_med + 1, k_med + 1, i_end , j_end, k_end); p2 = true; } if (p1 && p2) { if (ans != ans_1 + ans_2) { fprintf(stderr, "This should never happen.\n"); fprintf(stderr, "Inconsistency in recursive call, Phaser::aligner.\n"); fprintf(stderr, "Please send us a report.\n"); exit(-1); } } else { if (p1 || p2) { printf("im curious:\n"); printf("%lu, %lu, %lu \n", k_ini, k_med, k_end); } } return ans; }
void RemapKmers(const Sequence& old_s, const Sequence& new_s) { VERIFY(this->IsAttached()); size_t old_length = old_s.size() - k_ + 1; size_t new_length = new_s.size() - k_ + 1; UniformPositionAligner aligner(old_s.size() - k_ + 1, new_s.size() - k_ + 1); Kmer old_kmer = old_s.start<Kmer>(k_); for (size_t i = k_ - 1; i < old_s.size(); ++i) { // Instead of shifting right if (i != k_ - 1) { old_kmer <<= old_s[i]; } size_t old_kmer_offset = i - k_ + 1; size_t new_kmer_offest = aligner.GetPosition(old_kmer_offset); if(old_kmer_offset * 2 + 1 == old_length && new_length % 2 == 0) { Kmer middle(unsigned(k_ - 1), new_s, new_length / 2); if(typename Kmer::less2()(middle, !middle)) { new_kmer_offest = new_length - 1 - new_kmer_offest; } } Kmer new_kmer(unsigned(k_), new_s, new_kmer_offest); auto it = mapping_.find(new_kmer); if (it != mapping_.end()) { if(verification_on_) VERIFY(Substitute(new_kmer) == old_kmer); mapping_.erase(it); } if(old_kmer != new_kmer) mapping_[old_kmer] = new_kmer; } }
bool CheckCanRemap(const Sequence& old_s, const Sequence& new_s) const { if(!CheckAllDifferent(old_s, new_s)) return false; size_t old_length = old_s.size() - k_ + 1; size_t new_length = new_s.size() - k_ + 1; UniformPositionAligner aligner(old_s.size() - k_ + 1, new_s.size() - k_ + 1); Kmer old_kmer = old_s.start<Kmer>(k_); old_kmer >>= 0; for (size_t i = k_ - 1; i < old_s.size(); ++i) { old_kmer <<= old_s[i]; size_t old_kmer_offset = i - k_ + 1; size_t new_kmer_offest = aligner.GetPosition(old_kmer_offset); if(old_kmer_offset * 2 + 1 == old_length && new_length % 2 == 0) { Kmer middle(k_ - 1, new_s, new_length / 2); if (typename Kmer::less2()(middle, !middle)) { new_kmer_offest = new_length - 1 - new_kmer_offest; } } Kmer new_kmer(k_, new_s, new_kmer_offest); auto it = mapping_.find(new_kmer); if (it != mapping_.end()) { if (Substitute(new_kmer) != old_kmer) { return false; } } } return true; }
void KoTextEditor::setHorizontalTextAlignment(Qt::Alignment align) { if (isEditProtected()) { return; } class Aligner : public BlockFormatVisitor { public: Aligner(Qt::Alignment align) : alignment(align) {} void visit(QTextBlock &block) const { QTextBlockFormat format = block.blockFormat(); format.setAlignment(alignment); QTextCursor cursor(block); cursor.setBlockFormat(format); } Qt::Alignment alignment; }; Aligner aligner(align); d->updateState(KoTextEditor::Private::Format, i18nc("(qtundo-format)", "Change Alignment")); BlockFormatVisitor::visitSelection(this, aligner, i18nc("(qtundo-format)", "Change Alignment")); d->updateState(KoTextEditor::Private::NoOp); emit textFormatChanged(); }
int main(int argc, char *argv[]) { ArgumentParser ap; ap.parse_args(argc, argv); initialize_dash_dirs(); if (ap.index) { if (ap.genome == "" || ap.seed_len <= 0 || ap.threads <= 0) { parse_error(ap); } else { indexer(ap.genome, ap.seed_len, ap.threads); } } else if (ap.align) { if (ap.out == "" || ap.in == "" || ap.threads <= 0 || ap.edit_dist < 0 \ || ap.conf <= 0 ) { parse_error(ap); } else { aligner(ap.in, ap.out, ap.threads, ap.edit_dist, ap.conf); } } else { parse_error(ap); } return 0; }
IAligner * CAlignTest::CreateAligner( EAlignmentAlgo algo, CScoreTbl * scoreTbl ) const { auto_ptr<IAligner> aligner( NewAligner( algo, m_xDropoff ) ); ASSERT( aligner.get() ); aligner->SetScoreTbl( *scoreTbl ); return aligner.release(); }
// Serilize Constructor MessageTaskDeliver() : Message( PROTOCOL_VERSION , 131 , 0 ) { task_id( "" ); uri_list( ); aligner( "" ); sorter( "" ); reference( "" ); }
static AlignmentResult<score_t> testAlign( const std::string& seq, const std::string& ref) { AlignmentScores<score_t> scores(2,-4,-5,-1,-4); GlobalAligner<score_t> aligner(scores); AlignmentResult<score_t> result; aligner.align(seq.begin(),seq.end(),ref.begin(),ref.end(),result); return result; }
TEST(Alignment, OutputTest) { //TODO why do we have 3 softclipped nucleotides on both edges? const std::string query = "PROTEINPROTEIN"; const std::string ref = "PROTEINPROTEIN"; StripedSmithWaterman::Aligner aligner(10, -10, 11, 11); //match, mismatch, gap open, gap extend StripedSmithWaterman::Filter filter; StripedSmithWaterman::Alignment alignment; aligner.SetReferenceSequence(ref.c_str(), ref.length()); aligner.Align(query.c_str(), filter, &alignment); OutputFormatter::print_alignment(std::cout, alignment, ref, query, "Ref", "Query"); }
static JumpAlignmentResult<score_t> testAlignScores( const std::string& seq, const std::string& ref1, const std::string& ref2, int match, int mismatch, int open, int extend, int spliceOpen, int offEdge, int spliceOffEdge) { AlignmentScores<score_t> scores(match, mismatch, open, extend, offEdge); score_t jumpScore(-3); GlobalJumpIntronAligner<score_t> aligner(scores,jumpScore,spliceOpen,spliceOffEdge); JumpAlignmentResult<score_t> result; aligner.align( seq.begin(),seq.end(), ref1.begin(),ref1.end(), ref2.begin(),ref2.end(), false, false, //todo make tests for all ortientations result); return result; }
static JumpAlignmentResult<score_t> testAlignScores( const std::string& seq, const std::string& ref1, const std::string& ref2, int match, int mismatch, int open, int extend, int spliceOpen, int offEdge, int spliceOffEdge, int jump, bool stranded, bool bp1Fw, bool bp2Fw) { AlignmentScores<score_t> scores(match, mismatch, open, extend, offEdge); score_t jumpScore(jump); GlobalJumpIntronAligner<score_t> aligner(scores,jumpScore,spliceOpen,spliceOffEdge); JumpAlignmentResult<score_t> result; aligner.align( seq.begin(),seq.end(), ref1.begin(),ref1.end(), ref2.begin(),ref2.end(), bp1Fw, bp2Fw, stranded, result); return result; }
score_t Phaser::similarity_and_phase() { score_t ans = aligner(0, 0, 0, M_len-1, F_len-1, C_len-1); PrintPhaseString(); return ans; }
Config::Config(int argc, const char **argv) { Command_line_parser parser; parser.add_command("makedb", "Build DIAMOND database from a FASTA file") .add_command("blastp", "Align amino acid query sequences against a protein reference database") .add_command("blastx", "Align DNA query sequences against a protein reference database") .add_command("view", "View DIAMOND alignment archive (DAA) formatted file") .add_command("help", "Produce help message") .add_command("version", "Display version information") .add_command("getseq", "") .add_command("benchmark", "") .add_command("random-seqs", "") .add_command("compare", ""); Options_group general ("General options"); general.add() ("threads", 'p', "number of CPU threads", threads_) ("db", 'd', "database file", database) ("out", 'o', "output file", output_file) ("outfmt", 'f', "output format (tab/sam/xml/daa)", output_format) ("verbose", 'v', "verbose console output", verbose) ("log", 0, "enable debug log", debug_log) ("quiet", 0, "disable console output", quiet); Options_group makedb("Makedb options"); makedb.add() ("in", 0, "input reference file in FASTA format", input_ref_file) #ifdef EXTRA ("dbtype", po::value<string>(&program_options::db_type), "database type (nucl/prot)") #endif ; Options_group aligner("Aligner options"); aligner.add() ("query",'q', "input query file", query_file) ("max-target-seqs",'k', "maximum number of target sequences to report alignments for", max_alignments, uint64_t(25)) ("top", 0, "report alignments within this percentage range of top alignment score (overrides --max-target-seqs)", toppercent, 100.0) ("compress", 0, "compression for output files (0=none, 1=gzip)", compression) ("evalue",'e', "maximum e-value to report alignments", max_evalue, 0.001) ("min-score", 0, "minimum bit score to report alignments (overrides e-value setting)", min_bit_score) ("id", 0, "minimum identity% to report an alignment", min_id) ("query-cover", 0, "minimum query cover% to report an alignment", query_cover) ("sensitive", 0, "enable sensitive mode (default: fast)", mode_sensitive) ("more-sensitive", 0, "enable more sensitive mode (default: fast)", mode_more_sensitive) ("block-size", 'b', "sequence block size in billions of letters (default=2.0)", chunk_size, 2.0) ("index-chunks",'c', "number of chunks for index processing", lowmem, 4u) ("tmpdir",'t', "directory for temporary files", tmpdir) ("gapopen", 0, "gap open penalty (default=11 for protein)", gap_open, -1) ("gapextend", 0, "gap extension penalty (default=1 for protein)", gap_extend, -1) #ifdef EXTRA ("reward", po::value<int>(&program_options::reward)->default_value(2), "match reward score (blastn only)") ("penalty", po::value<int>(&program_options::penalty)->default_value(-3), "mismatch penalty score (blastn only)") #endif ("matrix", 0, "score matrix for protein alignment", matrix, string("blosum62")) ("seg", 0, "enable SEG masking of queries (yes/no)", seg) ("salltitles", 0, "print full subject titles in output files", salltitles); Options_group advanced("Advanced options"); advanced.add() ("run-len", 'l', "mask runs between stop codons shorter than this length", run_len) ("freq-sd", 0, "number of standard deviations for ignoring frequent seeds", freq_sd, 0.0) ("id2", 0, "minimum number of identities for stage 1 hit", min_identities) ("window", 'w', "window size for local hit search", window) ("xdrop", 'x', "xdrop for ungapped alignment", xdrop, 20) ("gapped-xdrop", 'X', "xdrop for gapped alignment in bits", gapped_xdrop, 20) ("ungapped-score", 0, "minimum raw alignment score to continue local extension", min_ungapped_raw_score) ("hit-band", 0, "band for hit verification", hit_band) ("hit-score", 0, "minimum score to keep a tentative alignment", min_hit_score) ("band", 0, "band for dynamic programming computation", padding) ("shapes", 's', "number of seed shapes (0 = all available)", shapes) ("index-mode", 0, "index mode (0=4x12, 1=16x9)", index_mode) ("fetch-size", 0, "trace point fetch size", fetch_size, 4096u) ("rank-factor", 0, "include subjects within this range of max-target-seqs", rank_factor, 2.0) ("rank-ratio", 0, "include subjects within this ratio of last hit", rank_ratio, 0.35) ("single-domain", 0, "Discard secondary domains within one target sequence", single_domain) ("dbsize", 0, "effective database size (in letters)", db_size) ("no-auto-append", 0, "disable auto appending of DAA and DMND file extensions", no_auto_append) ("target-fetch-size", 0, "", target_fetch_size, 4u); Options_group view_options("View options"); view_options.add() ("daa", 'a', "DIAMOND alignment archive (DAA) file", daa_file) ("forwardonly", 0, "only show alignments of forward strand", forwardonly); Options_group hidden_options(""); hidden_options.add() ("extend-all", 0, "extend all seed hits", extend_all) ("local-align", 0, "Local alignment algorithm", local_align_mode, 0u) ("slow-search", 0, "", slow_search) ("seq", 0, "", seq_no) ("ht", 0, "", ht_mode) ("old-freq", 0, "", old_freq) ("qp", 0, "", query_parallel) ("match1", 0, "", match_file1) ("match2", 0, "", match_file2) ("max-hits", 'C', "maximum number of hits to consider for one seed", hit_cap) ("seed-freq", 0, "maximum seed frequency", max_seed_freq, -15.0); parser.add(general).add(makedb).add(aligner).add(advanced).add(view_options).add(hidden_options); parser.store(argc, argv, command); switch (command) { case Config::makedb: if (input_ref_file == "") throw std::runtime_error("Missing parameter: input file (--in)"); if (database == "") throw std::runtime_error("Missing parameter: database file (--db/-d)"); if (chunk_size != 2.0) throw std::runtime_error("Invalid option: --block-size/-b. Block size is set for the alignment commands."); break; case Config::blastp: case Config::blastx: if (query_file == "") throw std::runtime_error("Missing parameter: query file (--query/-q)"); if (database == "") throw std::runtime_error("Missing parameter: database file (--db/-d)"); if (daa_file.length() > 0) { if (output_file.length() > 0) throw std::runtime_error("Options --daa and --out cannot be used together."); if (output_format.length() > 0 && output_format != "daa") throw std::runtime_error("Invalid parameter: --daa/-a. Output file is specified with the --out/-o parameter."); output_file = daa_file; } if (daa_file.length() > 0 || output_format == "daa") { if (compression != 0) throw std::runtime_error("Compression is not supported for DAA format."); if (!no_auto_append) auto_append_extension(output_file, ".daa"); } break; case Config::view: if (daa_file == "") throw std::runtime_error("Missing parameter: DAA file (--daa/-a)"); default: ; } if (hit_cap != 0) throw std::runtime_error("Deprecated parameter: --max-hits/-C."); if (debug_log) verbosity = 3; else if (quiet) verbosity = 0; else if (verbose) verbosity = 2; else if (((command == Config::view || command == blastx || command == blastp) && output_file == "") || command == Config::version) verbosity = 0; else verbosity = 1; switch (verbosity) { case 0: message_stream = Message_stream(false); break; case 3: log_stream = Message_stream(); case 2: verbose_stream = Message_stream(); default: ; } if (!no_auto_append) { auto_append_extension(database, ".dmnd"); if (command == Config::view) auto_append_extension(daa_file, ".daa"); if (compression == 1) auto_append_extension(output_file, ".gz"); } message_stream << Const::program_name << " v" << Const::version_string << "." << (unsigned)Const::build_version << " | by Benjamin Buchfink <*****@*****.**>" << endl; message_stream << "Check http://github.com/bbuchfink/diamond for updates." << endl << endl; #ifndef NDEBUG verbose_stream << "Assertions enabled." << endl; #endif set_option(threads_, tthread::thread::hardware_concurrency()); switch (command) { case Config::makedb: case Config::blastp: case Config::blastx: case Config::view: message_stream << "#CPU threads: " << threads_ << endl; default: ; } if (command == Config::blastp || command == Config::blastx || command == Config::benchmark) { if (tmpdir == "") tmpdir = extract_dir(output_file); if (gap_open == -1) gap_open = 11; if (gap_extend == -1) gap_extend = 1; score_matrix = Score_matrix(to_upper_case(matrix), gap_open, gap_extend, reward, penalty); message_stream << "Scoring parameters: " << score_matrix << endl; if (seg == "" && command == blastx) seg = "yes"; verbose_stream << "SEG masking = " << (seg == "yes") << endl; have_ssse3 = check_SSSE3(); if (have_ssse3) verbose_stream << "SSSE3 enabled." << endl; verbose_stream << "Reduction: " << Reduction::reduction << endl; if (mode_more_sensitive) { set_option(index_mode, 1u); set_option(freq_sd, 200.0); } else if (mode_sensitive) { set_option(index_mode, 1u); set_option(freq_sd, 10.0); } else { set_option(index_mode, 0u); set_option(freq_sd, 50.0); } verbose_stream << "Seed frequency SD: " << freq_sd << endl; ::shapes = shape_config(index_mode, shapes); verbose_stream << "Shape configuration: " << ::shapes << endl; message_stream << "#Target sequences to report alignments for: "; if (max_alignments == 0) { max_alignments = std::numeric_limits<uint64_t>::max(); message_stream << "unlimited" << endl; } else message_stream << max_alignments << endl; } if (command == blastx) input_value_traits = nucleotide_traits; if (command == help) parser.print_help(); /*log_stream << "sizeof(hit)=" << sizeof(hit) << " sizeof(packed_uint40_t)=" << sizeof(packed_uint40_t) << " sizeof(sorted_list::entry)=" << sizeof(sorted_list::entry) << endl;*/ }
/* * allocation d'une zone memoire * appel a la fonction mem_fit_first * prend en parametre la taille de la zone a allouer * renvoie l'adresse de la zone allouee (ou l'utilisateur peut ecrire) * ou NULL si allocation impossible (size = 0 ou manque de place) */ void* mem_alloc(size_t size) { prendre_verrou(); struct fb bloc_choisi; size_t* ptr_taille; struct fb* ptr_bloc_choisi; size_t taille_requise = size + sizeof(size_t); size_t taille_restante; struct fb* ptr_new_bloc; void* retour = NULL; // allocation d'au moins 1 octet if (size > 0) { // appel a la methode mem_fit_first afin de recuperer l'adresse du bloc choisi ptr_bloc_choisi = f_mem_fit(size); // allocation impossible, pas de bloc libre de taille suffisante : renvoie NULL if(ptr_bloc_choisi == NULL) { relacher_verrou(); return NULL; } // on copie les donnees de la structure du bloc libre dans la structure bloc_choisi // avant ecriture de la taille a la place bloc_choisi = *ptr_bloc_choisi; // ajout du padding si besoin taille_requise = aligner(taille_requise); // on stocke la taille totale du bloc au debut ptr_taille = (size_t*) ptr_bloc_choisi; *ptr_taille = taille_requise; // on calcule la taille restante du bloc choisi taille_restante = bloc_choisi.size - taille_requise; // si on a encore de la place pour au moins la structure fb : on peut creer un nouveau bloc libre if ( taille_restante >= sizeof(struct fb) ) { // ecriture de la structure du nouveau bloc ptr_new_bloc = (struct fb*)((char*)ptr_bloc_choisi + taille_requise); (*ptr_new_bloc).size = taille_restante; (*ptr_new_bloc).next = bloc_choisi.next; } else { // pas de nouveau bloc libre, le suivant sera le suivant de l'ancien bloc ptr_new_bloc = bloc_choisi.next; // ajout de la taille en plus dans le bloc alloue (padding) ptr_bloc_choisi->size += taille_restante; } // appel a la fonction maj_chainage maj_chainage_alloc(ptr_bloc_choisi, ptr_new_bloc); // renvoie l'adresse decalee de sizeof(size_t) representant la taille de la zone allouee retour = (void*)((char*)ptr_bloc_choisi + sizeof(size_t)); relacher_verrou(); } else if(size == 0) { relacher_verrou(); // si demande d'allocation de 0 octet, on alloue 1 octet retour = mem_alloc(1); } else { // allocation impossible : la taille doit etre > 0 retour = NULL; relacher_verrou(); } return retour; }
void CAppNWA::x_RunOnPair() const { const CArgs& args = GetArgs(); // analyze parameters const bool bMM = args["mm"]; const bool bMT = args["mt"]; bool output_type1 ( args["o1"] ); bool output_type2 ( args["o2"] ); bool output_asn ( args["oasn"] ); bool output_fasta ( args["ofasta"] ); int band (args["band"].AsInteger()); int shift(args["shift"].AsInteger()); if(bMT && !bMM) { NCBI_THROW(CAppNWAException, eInconsistentParameters, "Mutliple thread mode supported " "for Myers-Miller method only (invoke with -mm)"); } if(bMM && band >= 0) { NCBI_THROW(CAppNWAException, eInconsistentParameters, "-mm and -band are inconsistent with each other"); } #ifndef NCBI_THREADS if(bMT) { NCBI_THROW(CAppNWAException, eNotSupported, "This application was built without multithreading support. " "To run in multiple threads, please re-configure and rebuild" " with proper options."); } #endif // read input sequences vector<char> v1, v2; CRef<CSeq_id> seqid1 = x_ReadFastaFile(args["seq1"].AsString(), &v1); CRef<CSeq_id> seqid2 = x_ReadFastaFile(args["seq2"].AsString(), &v2); // determine sequence/score matrix type const SNCBIPackedScoreMatrix* psm = (args["matrix"].AsString() == "blosum62")? &NCBISM_Blosum62: 0; CNWAligner* pnwaligner = 0; if(bMM) { pnwaligner = new CMMAligner(&v1[0], v1.size(), &v2[0], v2.size(), psm); } else if (band < 0) { pnwaligner = new CNWAligner(&v1[0], v1.size(), &v2[0], v2.size(), psm); } else { CBandAligner * ba = new CBandAligner(&v1[0], v1.size(), &v2[0], v2.size(), psm, band); Uint1 where = shift >= 0? 0: 1; ba->SetShift(where,abs(shift)); pnwaligner = ba; } auto_ptr<CNWAligner> aligner (pnwaligner); if(psm == NULL) { aligner->SetWm (args["Wm"]. AsInteger()); aligner->SetWms (args["Wms"].AsInteger()); aligner->SetScoreMatrix(NULL); } aligner->SetWg (args["Wg"]. AsInteger()); aligner->SetWs (args["Ws"]. AsInteger()); aligner->SetScoreMatrix(psm); // re-set score matrix to handle // possible ambiguity chars if(bMT && bMM) { CMMAligner* pmma = static_cast<CMMAligner*> (aligner.get()); pmma -> EnableMultipleThreads(); } auto_ptr<ofstream> pofs1 (0); auto_ptr<ofstream> pofs2 (0); auto_ptr<ofstream> pofsAsn (0); auto_ptr<ofstream> pofsFastA (0); if(output_type1) { pofs1.reset(open_ofstream (args["o1"].AsString()).release()); } if(output_type2) { pofs2.reset(open_ofstream (args["o2"].AsString()).release()); } if(output_asn) { pofsAsn.reset(open_ofstream (args["oasn"].AsString()).release()); } if(output_fasta) { pofsFastA.reset(open_ofstream (args["ofasta"].AsString()).release()); } {{ // setup end penalties string ends = args["esf"].AsString(); bool L1 = ends[0] == 'z'; bool R1 = ends[1] == 'z'; bool L2 = ends[2] == 'z'; bool R2 = ends[3] == 'z'; aligner->SetEndSpaceFree(L1, R1, L2, R2); }} int score = aligner->Run(); cerr << "Score = " << score << endl; CNWFormatter formatter (*aligner); formatter.SetSeqIds(seqid1, seqid2); const size_t line_width = 100; string s; if(pofs1.get()) { formatter.AsText(&s, CNWFormatter::eFormatType1, line_width); *pofs1 << s; } if(pofs2.get()) { formatter.AsText(&s, CNWFormatter::eFormatType2, line_width); *pofs2 << s; } if(pofsAsn.get()) { formatter.AsText(&s, CNWFormatter::eFormatAsn, line_width); *pofsAsn << s; } if(pofsFastA.get()) { formatter.AsText(&s, CNWFormatter::eFormatFastA, line_width); *pofsFastA << s; } if(!output_type1 && !output_type2 && !output_asn && !output_fasta) { formatter.AsText(&s, CNWFormatter::eFormatType2, line_width); cout << s; } }
int CAlignTest::Execute() { CScoreTbl scoreTbl( m_identityScore, m_mismatchScore, m_gapOpeningScore, m_gapExtentionScore ); auto_ptr<IAligner> aligner( CreateAligner( m_algo, &scoreTbl ) ); CAlignerBase::SetPrintDebug( true ); if( m_flags & fAlign_colorspace ) THROW( logic_error, "Colorspace option is not immplemented" ); if( GetArgIndex() + 2 > GetArgCount() ) THROW( runtime_error, "Two sequences are required!" ); if( m_offsetQuery < 0 || m_offsetSubject < 0 ) THROW( runtime_error, "Offset should never be negative" ); const char * qs = GetArg( GetArgIndex() ); const char * ss = GetArg( GetArgIndex() + 1 ); int ql = strlen( qs ); int sl = strlen( ss ); cerr << DISPLAY( qs ) << DISPLAY( ql ) << endl; cerr << DISPLAY( ss ) << DISPLAY( sl ) << endl; if( ql == 0 || sl == 0 ) THROW( runtime_error, "Sequences should have at least one base!" ); vector<char> query; vector<char> subject; query.reserve( ql ); subject.reserve( sl ); while( *qs ) query.push_back( CNcbi8naBase( CIupacnaBase( *qs++ ) ) ); while( *ss ) subject.push_back( CNcbi8naBase( CIupacnaBase( *ss++ ) ) ); qs = &query[0]; ss = &subject[0]; qs += m_offsetQuery; ql -= m_offsetQuery; ss += m_offsetSubject; sl -= m_offsetSubject; if( ql <= 0 || sl <= 0 ) THROW( runtime_error, "Offset is too big" ); if( GetFlags( fQuery_reverse ) ) { qs = qs + ql; ql = -ql; } if( GetFlags( fSubject_reverse ) ) { ss = ss + sl; sl = -sl; } int aflags = CAlignerBase::fComputePicture | CAlignerBase::fComputeScore | CAlignerBase::fPictureSubjectStrand; aligner->SetBestPossibleQueryScore( min( ql, sl ) * m_identityScore ); aligner->Align( CSeqCoding::eCoding_ncbi8na, qs, ql, CSeqCoding::eCoding_ncbi8na, ss, sl, aflags ); const CAlignerBase& abase = aligner->GetAlignerBase(); cout << ( GetFlags( fQuery_reverse ) ? 3 : 5 ) << "'=" << abase.GetQueryString() << "=" << ( GetFlags( fQuery_reverse ) ? 5 : 3 ) << "'\n"; cout << " " << abase.GetAlignmentString() << " " << " i=" << abase.GetIdentityCount() << ", m=" << abase.GetMismatchCount() << ", g=" << abase.GetIndelCount() << ", s=" << abase.GetRawScore() << "/" << abase.GetBestQueryScore() << "=" << abase.GetScore() << "%\n"; cout << "5'=" << abase.GetSubjectString() << "=3'\n"; return 0; }
int main(int argc, char **argv) { return aligner(argc, argv); }