Пример #1
0
void SaveScreen::SaveArea(int X1,int Y1,int X2,int Y2)
{
	fix_coordinates(X1, Y1, X2, Y2);

	m_X1=X1;
	m_Y1=Y1;
	m_X2=X2;
	m_Y2=Y2;

	ScreenBuf.allocate(height(), width());
	SaveArea();
}
Пример #2
0
/* Pileup function for single end data.
   Input: 
   1. int * plus_tags: the 5' ends of tags aligned to plus strand. Start from 0.
   2. long l_plus_tags:  number of plus tags.
   3. int * minus_tags: the 3' ends of tags aligned to minus strand. Start from 0.
   4. long l_minus_tags: number of minus tags.
   5. int five_shift: shift value at 5' end to recover the DNA fragment
   6. int three_shift: shift value at 3' end to recover the DNA fragment
   7. int leftmost_coord: any coords smaller than it will be set to it
   8. int rightmost_coord: any coords larger than it will be set to it
   9. float scale_factor: scale factor on pileup
   10. float baseline_value: the minimum value of pileup

   Return:
   1. PosVal *: position-value pairs in bedGraph fashion.
   2. long * final_length: the final length for the returned array of PosVal.

   Example of usage:
   
   pileup = single_end_pileup ( {1,2,3}, 3, {2,3,4}, 3, 0, 3, 0, 20, 0.5, 1.0, &final_length );
   for ( i = 0; i < final_length; i++ )
    {
      printf( "pos:%d value:%.2f\n", pileup[i].pos, pileup[i].value );
    }

 */
struct PosVal * single_end_pileup( int * plus_tags, long l_plus_tags, int * minus_tags, long l_minus_tags, int five_shift, int three_shift, int leftmost_coord, int rightmost_coord, float scale_factor, float baseline_value, long * final_length )
{
  long i_s, i_e, i;
  int p, pre_p, pileup;
  long l = l_plus_tags + l_minus_tags;
  int * start_poss, * end_poss, * ptr_start_poss, * ptr_end_poss;
  struct PosVal * pos_value_array;
  
  start_poss = (int *) malloc( l * sizeof( int ) );
  end_poss = (int *) malloc( l * sizeof( int ) );

  ptr_start_poss = start_poss;
  ptr_end_poss = end_poss;

  for ( i = 0; i < l_plus_tags; i++ )
    {
      *ptr_start_poss = plus_tags[ i ] - five_shift; ptr_start_poss++;
      *ptr_end_poss   = plus_tags[ i ] + three_shift; ptr_end_poss++;
    }
  
  for ( i = 0; i < l_minus_tags; i++ )
    {
      *ptr_start_poss = minus_tags[ i ] - three_shift; ptr_start_poss++;
      *ptr_end_poss   = minus_tags[ i ] + five_shift; ptr_end_poss++;
    }

  qsort( start_poss, l, sizeof( int ), cmpfunc_simple );
  qsort( end_poss,   l, sizeof( int ), cmpfunc_simple );

  // fix negative coordinations and those extends over end of chromosomes
  start_poss = fix_coordinates ( start_poss, l,  leftmost_coord, rightmost_coord );
  end_poss   = fix_coordinates ( end_poss, l, leftmost_coord, rightmost_coord );

  pos_value_array = quick_pileup ( start_poss, end_poss, l, scale_factor, baseline_value, final_length );

  // clean mem
  free( start_poss );
  free( end_poss );
  return pos_value_array;
}
Пример #3
0
SaveScreen::SaveScreen(int X1,int Y1,int X2,int Y2)
{
	fix_coordinates(X1, Y1, X2, Y2);
	_OT(SysLog(L"[%p] SaveScreen::SaveScreen(X1=%i,Y1=%i,X2=%i,Y2=%i)",this,X1,Y1,X2,Y2));
	SaveArea(X1,Y1,X2,Y2);
}