AMOS::Read_t red;
void ParseMates (Mapping_t & mapping){  AMOS::Read_t red;  AMOS::Fragment_t frg;  AMOS::Library_t lib;  AMOS::Matepair_t mtp;  AMOS::Bank_t red_bank (AMOS::Read_t::NCODE);  AMOS::Bank_t frg_bank (AMOS::Fragment_t::NCODE);  AMOS::Bank_t lib_bank (AMOS::Library_t::NCODE);  AMOS::BankStream_t mtp_bank (AMOS::Matepair_t::NCODE);  ReadMap_t * rmp, temprm;  pair<    vector<ReadMap_t *>::iterator,    vector<ReadMap_t *>::iterator    > rmpip;  try {    mtp_bank . open (OPT_BankName, AMOS::B_READ);    red_bank . open (OPT_BankName, AMOS::B_READ);    frg_bank . open (OPT_BankName, AMOS::B_READ);    lib_bank . open (OPT_BankName, AMOS::B_READ);    //-- Populate the mate records    while ( mtp_bank >> mtp )      {	//-- Find the read	temprm . id = mtp . getReads( ) . first;	rmpip = equal_range (mapping . reads . begin( ),			     mapping . reads . end( ),			     &temprm, ReadIdCmp_t( ));	//-- If 0 or >1 reads, or already mated, skip	if ( rmpip . second - rmpip . first != 1  ||	     (*(rmpip . first)) -> mate . read != NULL )	  continue;	rmp = *(rmpip . first);	//-- Find the mate	temprm . id = mtp . getReads( ) . second;	rmpip = equal_range (mapping . reads . begin( ),			     mapping . reads . end( ),			     &temprm, ReadIdCmp_t( ));	//-- If 0 or >1 mates	if ( rmpip . second - rmpip . first != 1 )	  continue;	assert ( (*(rmpip . first)) -> mate . read == NULL );	//- Link the mated reads	rmp -> mate . read = *(rmpip . first);	rmp -> mate . read -> mate . read = rmp;	//-- Get the library record for this insert	red_bank . fetch (rmp -> id, red);	frg_bank . fetch (red . getFragment( ), frg);	lib_bank . fetch (frg . getLibrary( ), lib);	//-- Set the mate offsets	rmp -> mate . minoff = rmp -> mate . maxoff =	  lib . getDistribution( ) . mean;	rmp -> mate . minoff -= lib . getDistribution( ) . sd * 3;	rmp -> mate . maxoff += lib . getDistribution( ) . sd * 3;	rmp -> mate . read -> mate . minoff = rmp -> mate . minoff;	rmp -> mate . read -> mate . maxoff = rmp -> mate . maxoff;      }  }  catch (const AMOS::Exception_t & e) {    cerr << "WARNING: " << e . what( ) << endl	 << "  could not retrieve mate-pair information" << endl;  }  mtp_bank . close( );  red_bank . close( );  frg_bank . close( );  lib_bank . close( );}