1 Star 0 Fork 0

Velcon-Zheng/bowtie2

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
pe.cpp 30.83 KB
一键复制 编辑 原始数据 按行查看 历史
langmead 提交于 2012-12-18 20:53 . Changing my email address
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940
/*
* Copyright 2011, Ben Langmead <langmea@cs.jhu.edu>
*
* This file is part of Bowtie 2.
*
* Bowtie 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.
*
* Bowtie 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 Bowtie 2. If not, see <http://www.gnu.org/licenses/>.
*/
#include "assert_helpers.h"
#include "pe.h"
using namespace std;
/**
* Return a PE_TYPE flag indicating, given a PE_POLICY and coordinates
* for a paired-end alignment, what type of alignment it is, i.e.,
* whether it's:
*
* 1. Straightforwardly concordant
* 2. Mates dovetail (one extends beyond the end of the other)
* 3. One mate contains the other but they don't dovetail
* 4. One mate overlaps the other but neither contains the other and
* they don't dovetail
* 5. Discordant
*/
int PairedEndPolicy::peClassifyPair(
int64_t off1, // offset of mate 1
size_t len1, // length of mate 1
bool fw1, // whether mate 1 aligned to Watson
int64_t off2, // offset of mate 2
size_t len2, // length of mate 2
bool fw2) // whether mate 2 aligned to Watson
const
{
assert_gt(len1, 0);
assert_gt(len2, 0);
// Expand the maximum fragment length if necessary to accomodate
// the longer mate
size_t maxfrag = maxfrag_;
if(len1 > maxfrag && expandToFit_) maxfrag = len1;
if(len2 > maxfrag && expandToFit_) maxfrag = len2;
size_t minfrag = minfrag_;
if(minfrag < 1) {
minfrag = 1;
}
bool oneLeft = false;
if(pol_ == PE_POLICY_FF) {
if(fw1 != fw2) {
// Bad combination of orientations
return PE_ALS_DISCORD;
}
oneLeft = fw1;
} else if(pol_ == PE_POLICY_RR) {
if(fw1 != fw2) {
// Bad combination of orientations
return PE_ALS_DISCORD;
}
oneLeft = !fw1;
} else if(pol_ == PE_POLICY_FR) {
if(fw1 == fw2) {
// Bad combination of orientations
return PE_ALS_DISCORD;
}
oneLeft = fw1;
} else if(pol_ == PE_POLICY_RF) {
if(fw1 == fw2) {
// Bad combination of orientations
return PE_ALS_DISCORD;
}
oneLeft = !fw1;
}
// Calc implied fragment size
int64_t fraglo = min<int64_t>(off1, off2);
int64_t fraghi = max<int64_t>(off1+len1, off2+len2);
assert_gt(fraghi, fraglo);
size_t frag = (size_t)(fraghi - fraglo);
if(frag > maxfrag || frag < minfrag) {
// Pair is discordant by virtue of the extents
return PE_ALS_DISCORD;
}
int64_t lo1 = off1;
int64_t hi1 = off1 + len1 - 1;
int64_t lo2 = off2;
int64_t hi2 = off2 + len2 - 1;
bool containment = false;
// Check whether one mate entirely contains the other
if((lo1 >= lo2 && hi1 <= hi2) ||
(lo2 >= lo1 && hi2 <= hi1))
{
containment = true;
}
int type = PE_ALS_NORMAL;
// Check whether one mate overlaps the other
bool olap = false;
if((lo1 <= lo2 && hi1 >= lo2) ||
(lo1 <= hi2 && hi1 >= hi2) ||
containment)
{
// The mates overlap
olap = true;
if(!olapOk_) return PE_ALS_DISCORD;
type = PE_ALS_OVERLAP;
}
// Check if the mates are in the wrong relative orientation,
// without any overlap
if(!olap) {
if((oneLeft && lo2 < lo1) || (!oneLeft && lo1 < lo2)) {
return PE_ALS_DISCORD;
}
}
// If one mate contained the other, report that
if(containment) {
if(!containOk_) return PE_ALS_DISCORD;
type = PE_ALS_CONTAIN;
}
// Check whether there's dovetailing; i.e. does the left mate
// extend past the right end of the right mate, or vice versa
if(( oneLeft && (hi1 > hi2 || lo2 < lo1)) ||
(!oneLeft && (hi2 > hi1 || lo1 < lo2)))
{
if(!dovetailOk_) return PE_ALS_DISCORD;
type = PE_ALS_DOVETAIL;
}
return type;
}
/**
* Given details about how one mate aligns, and some details about the
* reference sequence it aligned to, calculate a window and orientation s.t.
* a paired-end alignment is concordant iff the opposite mate aligns in the
* calculated window with the calculated orientation. The "window" is really a
* cosntraint on which positions the extreme end of the opposite mate can fall.
* This is a different type of constraint from the one placed on seed-extend
* dynamic programming problems. That constraints requires that alignments at
* one point pass through one of a set of "core" columns.
*
* When the opposite mate is to the left, we're constraining where its
* left-hand extreme can fall, i.e., which cells in the top row of the matrix
* it can end in. When the opposite mate is to the right, we're cosntraining
* where its right-hand extreme can fall, i.e., which cells in the bottom row
* of the matrix it can end in. However, in practice we can only constrain
* where we start the backtrace, i.e. where the RHS of the alignment falls.
* See frameFindMateRect for details.
*
* This calculaton does not consider gaps - the dynamic programming framer will
* take gaps into account.
*
* Returns false if no concordant alignments are possible, true otherwise.
*/
bool PairedEndPolicy::otherMate(
bool is1, // true -> mate 1 aligned and we're looking
// for 2, false -> vice versa
bool fw, // orientation of aligned mate
int64_t off, // offset into the reference sequence
int64_t maxalcols, // max # columns spanned by alignment
size_t reflen, // length of reference sequence aligned to
size_t len1, // length of mate 1
size_t len2, // length of mate 2
bool& oleft, // out: true iff opp mate must be to right of anchor
int64_t& oll, // out: leftmost Watson off for LHS of opp alignment
int64_t& olr, // out: rightmost Watson off for LHS of opp alignment
int64_t& orl, // out: leftmost Watson off for RHS of opp alignment
int64_t& orr, // out: rightmost Watson off for RHS of opp alignment
bool& ofw) // out: true iff opp mate must be on Watson strand
const
{
assert_gt(len1, 0);
assert_gt(len2, 0);
assert_gt(maxfrag_, 0);
assert_geq(minfrag_, 0);
assert_geq(maxfrag_, minfrag_);
assert(maxalcols == -1 || maxalcols > 0);
// Calculate whether opposite mate should align to left or to right
// of given mate, and what strand it should align to
pePolicyMateDir(pol_, is1, fw, oleft, ofw);
size_t alen = is1 ? len1 : len2; // length of opposite mate
// Expand the maximum fragment length if necessary to accomodate
// the longer mate
size_t maxfrag = maxfrag_;
size_t minfrag = minfrag_;
if(minfrag < 1) {
minfrag = 1;
}
if(len1 > maxfrag && expandToFit_) maxfrag = len1;
if(len2 > maxfrag && expandToFit_) maxfrag = len2;
if(!expandToFit_ && (len1 > maxfrag || len2 > maxfrag)) {
// Not possible to find a concordant alignment; one of the
// mates is too long
return false;
}
// Now calculate bounds within which a dynamic programming
// algorithm should search for an alignment for the opposite mate
if(oleft) {
// -----------FRAG MAX----------------
// -------FRAG MIN-------
// |-alen-|
// Anchor mate
// ^off
// |------|
// Not concordant: LHS not outside min
// |------|
// Concordant
// |------|
// Concordant
// |------|
// Not concordant: LHS outside max
// -----------FRAG MAX----------------
// -------FRAG MIN-------
// |-alen-|
// Anchor mate
// ^off
// |------------|
// LHS can't be outside this range
// -----------FRAG MAX----------------
// |------------------------------------------------------------|
// LHS can't be outside this range, assuming no restrictions on
// flipping, dovetailing, containment, overlap, etc.
// |-------|
// maxalcols
// |-----------------------------------------|
// LHS can't be outside this range, assuming no flipping
// |---------------------------------|
// LHS can't be outside this range, assuming no dovetailing
// |-------------------------|
// LHS can't be outside this range, assuming no overlap
oll = off + alen - maxfrag;
olr = off + alen - minfrag;
assert_geq(olr, oll);
orl = oll;
orr = off + maxfrag - 1;
assert_geq(olr, oll);
// What if overlapping alignments are not allowed?
if(!olapOk_) {
// RHS can't be flush with or to the right of off
orr = min<int64_t>(orr, off-1);
if(orr < olr) olr = orr;
assert_leq(oll, olr);
assert_leq(orl, orr);
assert_geq(orr, olr);
}
// What if dovetail alignments are not allowed?
else if(!dovetailOk_) {
// RHS can't be past off+alen-1
orr = min<int64_t>(orr, off + alen - 1);
assert_leq(oll, olr);
assert_leq(orl, orr);
}
// What if flipped alignments are not allowed?
else if(!flippingOk_ && maxalcols != -1) {
// RHS can't be right of ???
orr = min<int64_t>(orr, off + alen - 1 + (maxalcols-1));
assert_leq(oll, olr);
assert_leq(orl, orr);
}
assert_geq(olr, oll);
assert_geq(orr, orl);
assert_geq(orr, olr);
assert_geq(orl, oll);
} else {
// -----------FRAG MAX----------------
// -------FRAG MIN-------
// -----------FRAG MAX----------------
// |-alen-|
// Anchor mate
// ^off
// |------|
// Not concordant: RHS not outside min
// |------|
// Concordant
// |------|
// Concordant
// |------|
// Not concordant: RHS outside max
//
// -----------FRAG MAX----------------
// -------FRAG MIN-------
// -----------FRAG MAX----------------
// |-alen-|
// Anchor mate
// ^off
// |------------|
// RHS can't be outside this range
// |------------------------------------------------------------|
// LHS can't be outside this range, assuming no restrictions on
// dovetailing, containment, overlap, etc.
// |-------|
// maxalcols
// |-----------------------------------------|
// LHS can't be outside this range, assuming no flipping
// |---------------------------------|
// LHS can't be outside this range, assuming no dovetailing
// |-------------------------|
// LHS can't be outside this range, assuming no overlap
orr = off + (maxfrag - 1);
orl = off + (minfrag - 1);
assert_geq(orr, orl);
oll = off + alen - maxfrag;
olr = orr;
assert_geq(olr, oll);
// What if overlapping alignments are not allowed?
if(!olapOk_) {
// LHS can't be left of off+alen
oll = max<int64_t>(oll, off+alen);
if(oll > orl) orl = oll;
assert_leq(oll, olr);
assert_leq(orl, orr);
assert_geq(orl, oll);
}
// What if dovetail alignments are not allowed?
else if(!dovetailOk_) {
// LHS can't be left of off
oll = max<int64_t>(oll, off);
assert_leq(oll, olr);
assert_leq(orl, orr);
}
// What if flipped alignments are not allowed?
else if(!flippingOk_ && maxalcols != -1) {
// LHS can't be left of off - maxalcols + 1
oll = max<int64_t>(oll, off - maxalcols + 1);
assert_leq(oll, olr);
assert_leq(orl, orr);
}
assert_geq(olr, oll);
assert_geq(orr, orl);
assert_geq(orr, olr);
assert_geq(orl, oll);
}
// Boundaries and orientation determined
return true;
}
#ifdef MAIN_PE
#include <string>
#include <sstream>
void testCaseClassify(
const string& name,
int pol,
size_t maxfrag,
size_t minfrag,
bool local,
bool flip,
bool dove,
bool cont,
bool olap,
bool expand,
int64_t off1,
size_t len1,
bool fw1,
int64_t off2,
size_t len2,
bool fw2,
int expect_class)
{
PairedEndPolicy pepol(
pol,
maxfrag,
minfrag,
local,
flip,
dove,
cont,
olap,
expand);
int ret = pepol.peClassifyPair(
off1, // offset of mate 1
len1, // length of mate 1
fw1, // whether mate 1 aligned to Watson
off2, // offset of mate 2
len2, // length of mate 2
fw2); // whether mate 2 aligned to Watson
assert_eq(expect_class, ret);
cout << "peClassifyPair: " << name << "...PASSED" << endl;
}
void testCaseOtherMate(
const string& name,
int pol,
size_t maxfrag,
size_t minfrag,
bool local,
bool flip,
bool dove,
bool cont,
bool olap,
bool expand,
bool is1,
bool fw,
int64_t off,
int64_t maxalcols,
size_t reflen,
size_t len1,
size_t len2,
bool expect_ret,
bool expect_oleft,
int64_t expect_oll,
int64_t expect_olr,
int64_t expect_orl,
int64_t expect_orr,
bool expect_ofw)
{
PairedEndPolicy pepol(
pol,
maxfrag,
minfrag,
local,
flip,
dove,
cont,
olap,
expand);
int64_t oll = 0, olr = 0;
int64_t orl = 0, orr = 0;
bool oleft = false, ofw = false;
bool ret = pepol.otherMate(
is1,
fw,
off,
maxalcols,
reflen,
len1,
len2,
oleft,
oll,
olr,
orl,
orr,
ofw);
assert(ret == expect_ret);
if(ret) {
assert_eq(expect_oleft, oleft);
assert_eq(expect_oll, oll);
assert_eq(expect_olr, olr);
assert_eq(expect_orl, orl);
assert_eq(expect_orr, orr);
assert_eq(expect_ofw, ofw);
}
cout << "otherMate: " << name << "...PASSED" << endl;
}
int main(int argc, char **argv) {
// Set of 8 cases where we look for the opposite mate to the right
// of the anchor mate, with various combinations of policies and
// anchor-mate orientations.
// |--------|
// |--------|
// ^110 ^119
// |------------------|
// min frag
// |--------|
// ^120 ^129
// |----------------------------|
// max frag
// ^
// 100
{
int policies[] = { PE_POLICY_FF, PE_POLICY_RR, PE_POLICY_FR, PE_POLICY_RF, PE_POLICY_FF, PE_POLICY_RR, PE_POLICY_FR, PE_POLICY_RF };
bool is1[] = { true, true, true, true, false, false, false, false };
bool fw[] = { true, false, true, false, false, true, true, false };
bool oleft[] = { false, false, false, false, false, false, false, false };
bool ofw[] = { true, false, false, true, false, true, false, true };
for(int i = 0; i < 8; i++) {
ostringstream oss;
oss << "Simple";
oss << i;
testCaseOtherMate(
oss.str(),
policies[i], // policy
30, // maxfrag
20, // minfrag
false, // local
true, // flipping OK
true, // dovetail OK
true, // containment OK
true, // overlap OK
true, // expand-to-fit
is1[i], // mate 1 is anchor
fw[i], // anchor aligned to Watson
100, // anchor's offset into ref
-1, // max # alignment cols
200, // ref length
10, // mate 1 length
10, // mate 2 length
true, // expected return val from otherMate
oleft[i], // wheter to look for opposite to left
80, // expected leftmost pos for opp mate LHS
129, // expected rightmost pos for opp mate LHS
119, // expected leftmost pos for opp mate RHS
129, // expected rightmost pos for opp mate RHS
ofw[i]); // expected orientation in which opposite mate must align
}
}
// Set of 8 cases where we look for the opposite mate to the left
// of the anchor mate, with various combinations of policies and
// anchor-mate orientations.
// |--------|
// ^100 ^109
// |--------|
// ^110 ^119
// |------------------|
// min frag
// |-Anchor-|
// ^120 ^129
// |----------------------------|
// max frag
// ^
// 100
{
int policies[] = { PE_POLICY_FF, PE_POLICY_RR, PE_POLICY_FR, PE_POLICY_RF, PE_POLICY_FF, PE_POLICY_RR, PE_POLICY_FR, PE_POLICY_RF };
bool is1[] = { false, false, false, false, true, true, true, true };
bool fw[] = { true, false, false, true, false, true, false, true };
bool oleft[] = { true, true, true, true, true, true, true, true };
bool ofw[] = { true, false, true, false, false, true, true, false };
for(int i = 0; i < 8; i++) {
ostringstream oss;
oss << "Simple";
oss << (i+8);
testCaseOtherMate(
oss.str(),
policies[i], // policy
30, // maxfrag
20, // minfrag
false, // local
true, // flipping OK
true, // dovetail OK
true, // containment OK
true, // overlap OK
true, // expand-to-fit
is1[i], // mate 1 is anchor
fw[i], // anchor aligned to Watson
120, // anchor's offset into ref
-1, // max # alignment cols
200, // ref length
10, // mate 1 length
10, // mate 2 length
true, // expected return val from otherMate
oleft[i], // wheter to look for opposite to left
100, // expected leftmost pos for opp mate LHS
110, // expected rightmost pos for opp mate LHS
100, // expected leftmost pos for opp mate RHS
149, // expected rightmost pos for opp mate RHS
ofw[i]); // expected orientation in which opposite mate must align
}
}
// Case where min frag == max frag and opposite is to the right
// |----------------------------|
// min frag
// |--------|
// ^120 ^129
// |----------------------------|
// max frag
// ^
// 100
testCaseOtherMate(
"MinFragEqMax1",
PE_POLICY_FR, // policy
30, // maxfrag
30, // minfrag
false, // local
true, // flipping OK
true, // dovetail OK
true, // containment OK
true, // overlap OK
true, // expand-to-fit
false, // mate 1 is anchor
false, // anchor aligned to Watson
120, // anchor's offset into ref
-1, // max # alignment cols
200, // ref length
10, // mate 1 length
10, // mate 2 length
true, // expected return val from otherMate
true, // wheter to look for opposite to left
100, // expected leftmost pos for opp mate LHS
100, // expected rightmost pos for opp mate LHS
100, // expected leftmost pos for opp mate RHS
149, // expected rightmost pos for opp mate RHS
true); // expected orientation in which opposite mate must align
// Case where min frag == max frag and opposite is to the right
// |----------------------------|
// min frag ^129
// |--------|
// ^100 ^109
// |----------------------------|
// max frag
testCaseOtherMate(
"MinFragEqMax2",
PE_POLICY_FR, // policy
30, // maxfrag
30, // minfrag
false, // local
true, // flipping OK
true, // dovetail OK
true, // containment OK
true, // overlap OK
true, // expand-to-fit
true, // mate 1 is anchor
true, // anchor aligned to Watson
100, // anchor's offset into ref
-1, // max # alignment cols
200, // ref length
10, // mate 1 length
10, // mate 2 length
true, // expected return val from otherMate
false, // wheter to look for opposite to left
80, // expected leftmost pos for opp mate LHS
129, // expected rightmost pos for opp mate LHS
129, // expected leftmost pos for opp mate RHS
129, // expected rightmost pos for opp mate RHS
false); // expected orientation in which opposite mate must align
testCaseOtherMate(
"MinFragEqMax4NoDove1",
PE_POLICY_FR, // policy
30, // maxfrag
25, // minfrag
false, // local
true, // flipping OK
false, // dovetail OK
true, // containment OK
true, // overlap OK
true, // expand-to-fit
true, // mate 1 is anchor
true, // anchor aligned to Watson
100, // anchor's offset into ref
-1, // max # alignment cols
200, // ref length
10, // mate 1 length
10, // mate 2 length
true, // expected return val from otherMate
false, // wheter to look for opposite to left
100, // expected leftmost pos for opp mate LHS
129, // expected rightmost pos for opp mate LHS
124, // expected leftmost pos for opp mate RHS
129, // expected rightmost pos for opp mate RHS
false); // expected orientation in which opposite mate must align
testCaseOtherMate(
"MinFragEqMax4NoCont1",
PE_POLICY_FR, // policy
30, // maxfrag
25, // minfrag
false, // local
true, // flipping OK
false, // dovetail OK
false, // containment OK
true, // overlap OK
true, // expand-to-fit
true, // mate 1 is anchor
true, // anchor aligned to Watson
100, // anchor's offset into ref
-1, // max # alignment cols
200, // ref length
10, // mate 1 length
10, // mate 2 length
true, // expected return val from otherMate
false, // wheter to look for opposite to left
100, // expected leftmost pos for opp mate LHS
129, // expected rightmost pos for opp mate LHS
124, // expected leftmost pos for opp mate RHS
129, // expected rightmost pos for opp mate RHS
false); // expected orientation in which opposite mate must align
testCaseOtherMate(
"MinFragEqMax4NoOlap1",
PE_POLICY_FR, // policy
30, // maxfrag
25, // minfrag
false, // local
true, // flipping OK
false, // dovetail OK
false, // containment OK
false, // overlap OK
true, // expand-to-fit
true, // mate 1 is anchor
true, // anchor aligned to Watson
100, // anchor's offset into ref
-1, // max # alignment cols
200, // ref length
10, // mate 1 length
10, // mate 2 length
true, // expected return val from otherMate
false, // wheter to look for opposite to left
110, // expected leftmost pos for opp mate LHS
129, // expected rightmost pos for opp mate LHS
124, // expected leftmost pos for opp mate RHS
129, // expected rightmost pos for opp mate RHS
false); // expected orientation in which opposite mate must align
testCaseOtherMate(
"MinFragEqMax4NoDove2",
PE_POLICY_FR, // policy
30, // maxfrag
25, // minfrag
false, // local
true, // flipping OK
false, // dovetail OK
true, // containment OK
true, // overlap OK
true, // expand-to-fit
false, // mate 1 is anchor
false, // anchor aligned to Watson
120, // anchor's offset into ref
-1, // max # alignment cols
200, // ref length
10, // mate 1 length
10, // mate 2 length
true, // expected return val from otherMate
true, // whether to look for opposite to left
100, // expected leftmost pos for opp mate LHS
105, // expected rightmost pos for opp mate LHS
100, // expected leftmost pos for opp mate RHS
129, // expected rightmost pos for opp mate RHS
true); // expected orientation in which opposite mate must align
testCaseOtherMate(
"MinFragEqMax4NoOlap2",
PE_POLICY_FR, // policy
30, // maxfrag
25, // minfrag
false, // local
true, // flipping OK
false, // dovetail OK
false, // containment OK
false, // overlap OK
true, // expand-to-fit
false, // mate 1 is anchor
false, // anchor aligned to Watson
120, // anchor's offset into ref
-1, // max # alignment cols
200, // ref length
10, // mate 1 length
10, // mate 2 length
true, // expected return val from otherMate
true, // whether to look for opposite to left
100, // expected leftmost pos for opp mate LHS
105, // expected rightmost pos for opp mate LHS
100, // expected leftmost pos for opp mate RHS
119, // expected rightmost pos for opp mate RHS
true); // expected orientation in which opposite mate must align
{
int olls[] = { 110 };
int olrs[] = { 299 };
int orls[] = { 149 };
int orrs[] = { 299 };
for(int i = 0; i < 1; i++) {
ostringstream oss;
oss << "Overhang1_";
oss << (i+1);
testCaseOtherMate(
oss.str(),
PE_POLICY_FR, // policy
200, // maxfrag
50, // minfrag
false, // local
true, // flipping OK
true, // dovetail OK
true, // containment OK
false, // overlap OK
true, // expand-to-fit
true, // mate 1 is anchor
true, // anchor aligned to Watson
100, // anchor's offset into ref
-1, // max # alignment cols
200, // ref length
10, // mate 1 length
10, // mate 2 length
true, // expected return val from otherMate
false, // whether to look for opposite to left
olls[i], // expected leftmost pos for opp mate LHS
olrs[i], // expected rightmost pos for opp mate LHS
orls[i], // expected leftmost pos for opp mate RHS
orrs[i], // expected rightmost pos for opp mate RHS
false); // expected orientation in which opposite mate must align
}
}
{
int olls[] = { -100 };
int olrs[] = { 50 };
int orls[] = { -100 };
int orrs[] = { 89 };
for(int i = 0; i < 1; i++) {
ostringstream oss;
oss << "Overhang2_";
oss << (i+1);
testCaseOtherMate(
oss.str(),
PE_POLICY_FR, // policy
200, // maxfrag
50, // minfrag
false, // local
true, // flipping OK
true, // dovetail OK
true, // containment OK
false, // overlap OK
true, // expand-to-fit
true, // mate 1 is anchor
false, // anchor aligned to Watson
90, // anchor's offset into ref
-1, // max # alignment cols
200, // ref length
10, // mate 1 length
10, // mate 2 length
true, // expected return val from otherMate
true, // whether to look for opposite to left
olls[i], // expected leftmost pos for opp mate LHS
olrs[i], // expected rightmost pos for opp mate LHS
orls[i], // expected leftmost pos for opp mate RHS
orrs[i], // expected rightmost pos for opp mate RHS
true); // expected orientation in which opposite mate must align
}
}
{
int mate2offs[] = { 150, 149, 149, 100, 99, 299, 1, 250, 250 };
int mate2lens[] = { 50, 50, 51, 100, 101, 1, 50, 50, 51 };
int peExpects[] = { PE_ALS_NORMAL, PE_ALS_DISCORD, PE_ALS_OVERLAP, PE_ALS_CONTAIN, PE_ALS_DOVETAIL, PE_ALS_NORMAL, PE_ALS_DISCORD, PE_ALS_NORMAL, PE_ALS_DISCORD };
for(int i = 0; i < 9; i++) {
ostringstream oss;
oss << "Simple1_";
oss << (i);
testCaseClassify(
oss.str(),
PE_POLICY_FR, // policy
200, // maxfrag
100, // minfrag
false, // local
true, // flipping OK
true, // dovetail OK
true, // containment OK
true, // overlap OK
true, // expand-to-fit
100, // offset of mate 1
50, // length of mate 1
true, // whether mate 1 aligned to Watson
mate2offs[i], // offset of mate 2
mate2lens[i], // length of mate 2
false, // whether mate 2 aligned to Watson
peExpects[i]);// expectation for PE_ALS flag returned
}
}
{
int mate1offs[] = { 200, 201, 200, 200, 200, 100, 400, 100, 99 };
int mate1lens[] = { 50, 49, 51, 100, 101, 1, 50, 50, 51 };
int peExpects[] = { PE_ALS_NORMAL, PE_ALS_DISCORD, PE_ALS_OVERLAP, PE_ALS_CONTAIN, PE_ALS_DOVETAIL, PE_ALS_NORMAL, PE_ALS_DISCORD, PE_ALS_NORMAL, PE_ALS_DISCORD };
for(int i = 0; i < 9; i++) {
ostringstream oss;
oss << "Simple2_";
oss << (i);
testCaseClassify(
oss.str(),
PE_POLICY_FR, // policy
200, // maxfrag
100, // minfrag
false, // local
true, // flipping OK
true, // dovetail OK
true, // containment OK
true, // overlap OK
true, // expand-to-fit
mate1offs[i], // offset of mate 1
mate1lens[i], // length of mate 1
true, // whether mate 1 aligned to Watson
250, // offset of mate 2
50, // length of mate 2
false, // whether mate 2 aligned to Watson
peExpects[i]);// expectation for PE_ALS flag returned
}
}
testCaseOtherMate(
"Regression1",
PE_POLICY_FF, // policy
50, // maxfrag
0, // minfrag
false, // local
true, // flipping OK
true, // dovetail OK
true, // containment OK
true, // overlap OK
true, // expand-to-fit
true, // mate 1 is anchor
false, // anchor aligned to Watson
3, // anchor's offset into ref
-1, // max # alignment cols
53, // ref length
10, // mate 1 length
10, // mate 2 length
true, // expected return val from otherMate
true, // whether to look for opposite to left
-37, // expected leftmost pos for opp mate LHS
13, // expected rightmost pos for opp mate LHS
-37, // expected leftmost pos for opp mate RHS
52, // expected rightmost pos for opp mate RHS
false); // expected orientation in which opposite mate must align
}
#endif /*def MAIN_PE*/
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/Velcon-Zheng/bowtie2.git
git@gitee.com:Velcon-Zheng/bowtie2.git
Velcon-Zheng
bowtie2
bowtie2
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385