运行时错误: terminate called after throwing an instance of 'std::out_of_range'
terminate called after throwing an instance of 'std::out_of_range'
what(): vector::_M_range_check
Program received signal SIGABRT, Aborted.
0x00002ace363f5765 in raise () from /lib/libc.so.6
(gdb) where
#0 0x00002ace363f5765 in raise () from /lib/libc.so.6
#1 0x00002ace363f71c0 in abort () from /lib/libc.so.6
#2 0x00002ace35cf07b4 in __gnu_cxx::__verbose_terminate_handler () from /usr/lib/libstdc++.so.6
#3 0x00002ace35cee746 in ?? () from /usr/lib/libstdc++.so.6
#4 0x00002ace35cee773 in std::terminate () from /usr/lib/libstdc++.so.6
#5 0x00002ace35cee85a in __cxa_throw () from /usr/lib/libstdc++.so.6
#6 0x00002ace35c8a35a in std::__throw_out_of_range () from /usr/lib/libstdc++.so.6
#7 0x000000000041b19c in std::vector<seed_region, std::allocator<seed_region> >::_M_range_check (
this=0x20063b10, __n=3) at /usr/include/c++/4.1.3/bits/stl_vector.h:503
#8 0x000000000041b1bb in std::vector<seed_region, std::allocator<seed_region> >::at (this=0x20063b10,
__n=3) at /usr/include/c++/4.1.3/bits/stl_vector.h:521
#9 0x0000000000404838 in find_spliced_mapping (reads=@0x7fff7509c850, reads_unmapped=@0x7fff7509c6d0,
spliced_mapping=@0x7fff7509c7d0) at srmap_spliced.cpp:1020
#10 0x0000000000408910 in main (argc=1, argv=0x7fff7509ca38) at srmap_spliced.cpp:1230
find_spliced_mapping() 内部错误。。。。
struct seed_region
{
seed_region(const unsigned short a,const unsigned int b,const unsigned int c,const bool d,const bool e):
chrom_id(a),start(b),end(c),seed_position(d),strand(e){}
unsigned short chrom_id;
unsigned int start;
unsigned int end;
bool seed_position;
bool strand;
};
struct read_info
{
read_info(const string n,const string s,const string r) :
name(n),seq(s),rev_seq(r){}
string name;
string seq;
string rev_seq;
};
void find_spliced_mapping(vector<read_info> &reads,hash_map<unsigned int,vector<seed_region> > &reads_unmapped,vector<spliced_read> &spliced_mapping)
{
cout<<endl<<"Now finding spliced mapping reads..."<<endl;
ofstream out("pairs");
hash_map<unsigned int,vector<seed_region> >::iterator it = reads_unmapped.begin();
for(;it!=reads_unmapped.end();it++)
{
int count=it->second.size();
int flag;
sort(it->second.begin(),it->second.end(),less_strand);
for(int i=0;i<count;i++)
{
if(it->second.at(i).strand==1)
{
flag=i;
break;
}
}
for(int j=0;j<flag;j++)
{
for(int h=j;h<flag;h++)
{
if(it->second.at(j).seed_position!=it->second.at(h).seed_position)
{
if(2<abs(it->second.at(j).end-it->second.at(h).end) && abs(it->second.at(j).end-it->second.at(h).end)<3000)
{
if((it->second.at(j).end+it->second.at(h).end-it->second.at(j).start-it->second.at(h).start)>=35)
{
out<<"read"<<it->first<<": "<<it->second.at(j).start<<" "<<it->second.at(j).end<<" "<<it->second.at(j).seed_position<<" "<<it->second.at(j).strand<<" and "<<it->second.at(h).start<<" "<<it->second.at(h).end<<" "<<it->second.at(h).seed_position<<" "<<it->second.at(h).strand<<endl;
}
}
}
}
}
for(int j=flag;j<count;j++)
{
for(int h=j;h<count;h++)
{
if(it->second.at(j).seed_position!=it->second.at(h).seed_position)
{
if(2<abs(it->second.at(j).end-it->second.at(h).end) && abs(it->second.at(j).end-it->second.at(h).end)<3000)
{
if((it->second.at(j).end+it->second.at(h).end-it->second.at(j).start-it->second.at(h).start)>=35)
{
out<<"read"<<it->first<<": "<<it->second.at(j).start<<" "<<it->second.at(j).end<<" "<<it->second.at(j).seed_position<<" "<<it->second.at(j).strand<<" and "<<it->second.at(h).start<<" "<<it->second.at(h).end<<" "<<it->second.at(h).seed_position<<" "<<it->second.at(h).strand<<endl;
}
}
}
}
}
}
}