示例#1
0
static IntChunk_ID get_second_mate_index
(
  TChunkMesg chunks[],
  const Tfragment frags[],
  const Tedge edges[],
  const IntChunk_ID sentinel,
  const IntChunk_ID b_index,
  const IntChunk_ID other_index,
  const float cgb_unique_cutoff
)
{
  int i;
  const AChunkMesg * chunk = GetVA_AChunkMesg(chunks,O2CI(b_index));
  IntChunk_ID mate_index = sentinel;
  IntChunk_ID temp_index = sentinel;
  const int b_side = O2S(b_index);
  const int32 raw_degree =
    (b_side == 1) ? chunk->b_degree_raw : chunk->a_degree_raw;
  const IntEdge_ID edge_id = (b_side == 1) ? chunk->b_list_raw : chunk->a_list_raw;

  // loop over the edges
  for( i = 0; i < raw_degree; i++ )
  {
    const Tnes edge = get_nes_edge( edges, edge_id + i );

    // if it's the right kind of edge
    if( AS_CGB_INTERCHUNK_EDGE == edge )
    {
      // get the chunk index
      IntChunk_ID temp_chunk = get_chunk_index( chunks, frags,
					  edges, edge_id + i );
      int temp_suffix = get_chunk_suffix( chunks, frags,
					  edges, edge_id + i );
      temp_index = CIS2O( temp_chunk, temp_suffix);

      if( (temp_index != other_index )
#ifdef UUNIQUE
	  &&
	  (GetVA_AChunkMesg( chunks, temp_chunk )->coverage_stat >= cgb_unique_cutoff)
#endif
	  )
      {
        if( mate_index == sentinel )
        {
          // if it's the first non-other index, set the mate_index
          mate_index = temp_index;
        }
        else if( temp_index != mate_index )
        {
          // it's a third mate, return sentinel
          return sentinel;
        }
      }
    }
  }
  // return either unique second mate or sentinel
  return mate_index;
}
示例#2
0
文件: async_op.c 项目: 3rf/mongo
/*
 * __async_compact --
 *	WT_ASYNC_OP->compact implementation for op handles.
 */
static int
__async_compact(WT_ASYNC_OP *asyncop)
{
	WT_ASYNC_OP_IMPL *op;
	WT_DECL_RET;
	WT_SESSION_IMPL *session;

	op = (WT_ASYNC_OP_IMPL *)asyncop;
	ASYNCOP_API_CALL(O2C(op), session, compact);
	WT_STAT_FAST_CONN_INCR(O2S(op), async_op_compact);
	WT_ERR(__async_op_wrap(op, WT_AOP_COMPACT));
err:	API_END_RET(session, ret);
}
示例#3
0
文件: async_op.c 项目: ksuarz/mongo
/*
 * __async_search --
 *	WT_ASYNC_OP->search implementation for op handles.
 */
static int
__async_search(WT_ASYNC_OP *asyncop)
{
	WT_ASYNC_OP_IMPL *op;
	WT_DECL_RET;
	WT_SESSION_IMPL *session;

	op = (WT_ASYNC_OP_IMPL *)asyncop;
	ASYNCOP_API_CALL(O2C(op), session, search);
	WT_STAT_CONN_INCR(O2S(op), async_op_search);
	WT_ERR(__async_op_wrap(op, WT_AOP_SEARCH));
err:	API_END_RET(session, ret);
}
示例#4
0
static IntChunk_ID get_lone_mate_index
(
 TChunkMesg chunks[],
 const Tfragment frags[],
 const Tedge edges[],
 const IntChunk_ID sentinel,
 const IntChunk_ID b_index,
 const float cgb_unique_cutoff
)
{
  int i;
  IntChunk_ID mate_index = sentinel;
  const AChunkMesg * chunk = GetVA_AChunkMesg( chunks, O2CI( b_index ) );
  const int b_side = O2S( b_index );
  const int32 raw_degree =
    (b_side == 1) ? chunk->b_degree_raw : chunk->a_degree_raw;
  const IntEdge_ID edge_id = (b_side == 1)
    ? chunk->b_list_raw : chunk->a_list_raw;

  // loop over the edges
  for( i = 0; i < raw_degree; i++ )
  {
    const Tnes edge = get_nes_edge( edges, edge_id + i );

    // if it's the right kind of edge
    if( AS_CGB_INTERCHUNK_EDGE == edge )
    {
      const IntChunk_ID temp_index = get_chunk_index( chunks, frags, edges, edge_id + i );

      if(
	 (mate_index == sentinel )
#ifdef UUNIQUE
	 &&
	 (GetVA_AChunkMesg( chunks, temp_index )->coverage_stat >= cgb_unique_cutoff )
#endif
	 ) {
	// first mate found
	mate_index =
	  CIS2O( get_chunk_index( chunks, frags, edges, edge_id + i ),
		 get_chunk_suffix( chunks, frags, edges, edge_id + i ) );
      }
      else if( O2CI( mate_index ) !=
	       get_chunk_index( chunks, frags, edges, edge_id + i ) ) {
	// it's a second mate, return sentinel
	return sentinel;
      }
    }
  }
  // return either lone mate or sentinel
  return mate_index;
}
示例#5
0
文件: async_op.c 项目: ksuarz/mongo
/*
 * __async_set_key --
 *	WT_ASYNC_OP->set_key implementation for op handles.
 */
static void
__async_set_key(WT_ASYNC_OP *asyncop, ...)
{
	WT_CURSOR *c;
	va_list ap;

	c = &asyncop->c;
	va_start(ap, asyncop);
	__wt_cursor_set_keyv(c, c->flags, ap);
	if (!WT_DATA_IN_ITEM(&c->key) && !WT_CURSOR_RECNO(c))
		c->saved_err = __wt_buf_set(
		    O2S((WT_ASYNC_OP_IMPL *)asyncop),
		    &c->key, c->key.data, c->key.size);
	va_end(ap);
}
示例#6
0
文件: async_op.c 项目: ksuarz/mongo
/*
 * __async_set_value --
 *	WT_ASYNC_OP->set_value implementation for op handles.
 */
static void
__async_set_value(WT_ASYNC_OP *asyncop, ...)
{
	WT_CURSOR *c;
	va_list ap;

	c = &asyncop->c;
	va_start(ap, asyncop);
	__wt_cursor_set_valuev(c, ap);
	/* Copy the data, if it is pointing at data elsewhere. */
	if (!WT_DATA_IN_ITEM(&c->value))
		c->saved_err = __wt_buf_set(
		    O2S((WT_ASYNC_OP_IMPL *)asyncop),
		    &c->value, c->value.data, c->value.size);
	va_end(ap);
}
示例#7
0
static int is_hanging_chunk_end
(
 TChunkMesg chunks[],
 const Tfragment frags[],
 const Tedge edges[],
 const IntChunk_ID b_index
)
{
  int i;
  const AChunkMesg * chunk = GetVA_AChunkMesg( chunks, O2CI( b_index ) );
  const int b_side = O2S( b_index );
  const int32 raw_degree =
    (b_side == 1) ? chunk->b_degree_raw : chunk->a_degree_raw;
  const IntEdge_ID edge_id = (b_side == 1)
    ? chunk->b_list_raw : chunk->a_list_raw;

  // loop over the edges
  for( i = 0; i < raw_degree; i++ )
  {
    const Tnes edge = get_nes_edge( edges, edge_id + i );

    switch(edge) {
    // if it's any dovetail edge
    case AS_CGB_INTERCHUNK_EDGE:
    case AS_CGB_INTRACHUNK_EDGE:
    case AS_CGB_TOUCHES_CONTAINED_EDGE:
    case AS_CGB_BETWEEN_CONTAINED_EDGE:
      //case AS_CGB_TOUCHES_CRAPPY_EDGE:
    case AS_CGB_MARKED_BY_BRANCH_DVT:
    case AS_CGB_REMOVED_BY_THRESHOLD_DVT:
    case AS_CGB_REMOVED_BY_TRANSITIVITY_DVT:
      return FALSE;
    default:
      break;
    }
  }
  return TRUE;
}
示例#8
0
uint32 count_crappies
(
 const char * const crappies_report_filename,
 const float cgb_unique_cutoff,
 const Tfragment  frags[],
 const Tedge      edges[],
 TChunkFrag       chunk_frags[],
 TChunkMesg       chunks[]
)
{
  uint32         num_crappies = 0;
  const IntChunk_ID  num_chunks = GetNumVA_AChunkMesg( chunks );
  const IntChunk_ID  sentinel = CIS2O( num_chunks, 0 );
  IntChunk_ID        schunk;
  int                ssuffix;
  FILE             * fp_crappies;

  fp_crappies = fopen( crappies_report_filename, "w" );
  if( fp_crappies == NULL )
  {
    fprintf( stderr, "Failed to open file %s for writing\n",
             crappies_report_filename );
    return 0;
  }

  // loop over chunks
  for( schunk = 0; schunk < num_chunks; schunk++ )
    for( ssuffix = 0; ssuffix < 2; ssuffix++ )
  {
    const IntChunk_ID  s_index = CIS2O(schunk,ssuffix);
    IntChunk_ID  c_index = sentinel;
    IntChunk_ID  d_index = sentinel;

    assert( schunk == O2CI(s_index) );
    // s must consist of exactly one fragment
    if( (GetVA_AChunkMesg( chunks, O2CI(s_index)))->num_frags != 1 )
      continue;

    // s must have exactly zero b-mates
    if( FALSE == is_hanging_chunk_end( chunks, frags, edges, O2O(s_index)) )
      continue;

    // s must have exactly one a-mate (c)
    c_index =
      get_lone_mate_index( chunks, frags, edges, sentinel, s_index, cgb_unique_cutoff );
    if( c_index == sentinel )
      continue;

    // c must have exactly two b-mates (s,d)
    d_index =
      get_second_mate_index( chunks, frags, edges,
			     sentinel, c_index, s_index, cgb_unique_cutoff );
    if( d_index == sentinel )
      continue;

    // d must have exactly one a-mate (c)
    if( get_lone_mate_index( chunks, frags, edges,
                             sentinel, d_index, cgb_unique_cutoff ) != c_index )
      continue;

    // if here, it's a crappy fragment.
    if( num_crappies == 0 )
    {
      fprintf( fp_crappies,
	       "# si is the chunk consisting of single crappy fragment\n" );
      fprintf( fp_crappies,
	       "# ci & di are split by prefix/suffix of s\n" );
      fprintf( fp_crappies, "#\n" );
      fprintf( fp_crappies, "#           (s)\n" );
      fprintf( fp_crappies, "#           /\n" );
      fprintf( fp_crappies, "#          /\n" );
      fprintf( fp_crappies, "#         /\n" );
      fprintf( fp_crappies, "#    \\   /                /\n" );
      fprintf( fp_crappies, "#    -(c)---------------(d)-\n" );
      fprintf( fp_crappies, "#    /                     \\\n" );
      fprintf( fp_crappies, "#\n" );
      fprintf( fp_crappies,
               "# "
	       "(si,ss) (ci,cs) (di,ds)\n");
      fprintf( fp_crappies,
               "#-------------------------------------------------"
               "----------------------------------------\n" );
    }
    num_crappies++;
    fprintf( fp_crappies,
	     "(%10" F_IIDP ",%1d) (%10" F_IIDP ",%1d) (%10" F_IIDP ",%1d)\n",
             O2CI(s_index ),  //s_chunk->iaccession,
	     O2S( s_index ),
             O2CI(c_index ),  //c_chunk->iaccession,
             O2S( c_index ),
             O2CI(d_index ),  //d_chunk->iaccession
             O2S( d_index )
	     );
  }

  fclose( fp_crappies );
  return num_crappies;
}
示例#9
0
uint32 count_chimeras
(
 const char * const chimeras_report_filename,
 const float cgb_unique_cutoff,
 const Tfragment  frags[],
 const Tedge      edges[],
 TChunkFrag       chunk_frags[],
 TChunkMesg       chunks[]
)
{
  uint32         num_chimeras = 0;
  const IntChunk_ID  num_chunks = GetNumVA_AChunkMesg( chunks );
  const IntChunk_ID  sentinel = CIS2O( num_chunks, 0 );
  IntChunk_ID        schunk;
  FILE             * fp_chimeras;

  fp_chimeras = fopen( chimeras_report_filename, "w" );
  if( fp_chimeras == NULL )
  {
    fprintf( stderr, "Failed to open file %s for writing\n",
             chimeras_report_filename );
    return 0;
  }

  // loop over chunks
  for( schunk = 0; schunk < num_chunks; schunk++ )
  {
    const IntChunk_ID  s_index = CIS2O(schunk,0);
    IntChunk_ID  a_index = sentinel;
    IntChunk_ID  b_index = sentinel;
    IntChunk_ID  c_index = sentinel;
    IntChunk_ID  d_index = sentinel;

    assert( schunk == O2CI(s_index) );
    // s must consist of exactly one fragment
    if( (GetVA_AChunkMesg( chunks, O2CI(s_index)))->num_frags != 1 )
      continue;

    // s must have exactly one b-mate (b)
    b_index =
      get_lone_mate_index( chunks, frags, edges, sentinel, O2O(s_index), cgb_unique_cutoff );
    if( b_index == sentinel )
      continue;

    // s must have exactly one a-mate (c)
    c_index =
      get_lone_mate_index( chunks, frags, edges, sentinel, s_index, cgb_unique_cutoff );
    if( c_index == sentinel )
      continue;

    // b != c (chunk within a chunk?)
    if( O2CI( c_index ) == O2CI( b_index ) )
      continue;

    // b must have exactly two a-mates (s,a)
    a_index =
      get_second_mate_index( chunks, frags, edges,
			     sentinel, b_index, O2O(s_index), cgb_unique_cutoff );
    if( a_index == sentinel )
      continue;

    // c must have exactly two b-mates (s,d)
    d_index =
      get_second_mate_index( chunks, frags, edges,
			     sentinel, c_index, s_index, cgb_unique_cutoff );
    if( d_index == sentinel )
      continue;

    // a !=d (quadrilateral, not a Z)
    if( O2CI( a_index ) == O2CI( d_index ) )
      continue;

    // a != c (quadrilateral, not a Z)
    if( O2CI( a_index ) == O2CI( c_index ) )
      continue;

    // b != d (quadrilateral, not a Z)
    if( O2CI( b_index ) == O2CI( d_index ) )
      continue;

    // a must have exactly one b-mate (b)
    if( get_lone_mate_index( chunks, frags, edges,
                             sentinel, a_index, cgb_unique_cutoff ) != b_index )
      continue;

    // d must have exactly one a-mate (c)
    if( get_lone_mate_index( chunks, frags, edges,
                             sentinel, d_index, cgb_unique_cutoff ) != c_index )
      continue;

    // if here, it's a chimeric fragment
    if( num_chimeras == 0 )
    {
      fprintf( fp_chimeras,
             "# s = index of chunk consisting of single chimeric fragment\n" );
      fprintf( fp_chimeras,
        "# a & b are split by suffix of s, c & d are split by prefix of s\n" );
      fprintf( fp_chimeras,
               "# a2b is 1 if suffix of a has edge with b, and so on.\n" );
      fprintf( fp_chimeras, "#\n" );
      fprintf( fp_chimeras, "#    \\                     /\n" );
      fprintf( fp_chimeras, "#    -(a)---------------(b)-\n" );
      fprintf( fp_chimeras, "#    /                  /  \\\n" );
      fprintf( fp_chimeras, "#                     /\n" );
      fprintf( fp_chimeras, "#                   /\n" );
      fprintf( fp_chimeras, "#                 /\n" );
      fprintf( fp_chimeras, "#              (s)\n" );
      fprintf( fp_chimeras, "#             /\n" );
      fprintf( fp_chimeras, "#           /\n" );
      fprintf( fp_chimeras, "#         /\n" );
      fprintf( fp_chimeras, "#    \\  /                  /\n" );
      fprintf( fp_chimeras, "#    -(c)---------------(d)-\n" );
      fprintf( fp_chimeras, "#    /                     \\\n" );
      fprintf( fp_chimeras, "#\n" );
      fprintf( fp_chimeras,
               "# "
	       "si : (ai,as) (bi,bs) (ci,cs) (di,ds)\n");
      fprintf( fp_chimeras,
               "#-------------------------------------------------"
               "----------------------------------------\n" );
    }
    num_chimeras++;
    fprintf( fp_chimeras,
	     "%10" F_IIDP " :  (%10" F_IIDP ",%1d) (%10" F_IIDP ",%1d) (%10" F_IIDP ",%1d) (%10" F_IIDP ",%1d)\n",
             O2CI(s_index ),  //s_chunk->iaccession,
	     O2CI(a_index ),  //a_chunk->iaccession,
             O2S( a_index ),
             O2CI(b_index ),  //b_chunk->iaccession,
             O2S( b_index ),
             O2CI(c_index ),  //c_chunk->iaccession,
             O2S( c_index ),
             O2CI(d_index ),  //d_chunk->iaccession
             O2S( d_index )
	     );
  }

  fclose( fp_chimeras );
  return num_chimeras;
}
示例#10
0
文件: async_op.c 项目: 3rf/mongo
/*
 * __async_op_wrap --
 *	Common wrapper for all async operations.
 */
static int
__async_op_wrap(WT_ASYNC_OP_IMPL *op, WT_ASYNC_OPTYPE type)
{
	op->optype = type;
	return (__wt_async_op_enqueue(O2S(op), op));
}