void CAudioOutputControlTestClass::SourceMenuResetEOFFlag()
    {
    iIsEOFReached = EFalse;
    iBytesReadFromFile = 0;

    TInt seekPos(0);
    iFile.Seek( ESeekStart, seekPos );
    }
Esempio n. 2
0
/** 
    only reads initial header information 
 */ 
void readHeader(ByteFile* bf)
{
  seekPos(bf, ALN_HEAD); 
  READ_VAR(bf->fh, bf->numTax); 
  READ_VAR(bf->fh, bf->numPattern); 
  READ_VAR(bf->fh, bf->numPartitions); 
  READ_VAR(bf->fh, bf->gappyness) ;
  bf->hasRead |= ALN_HEAD;

}
Esempio n. 3
0
/** 
    reads partition information from the byte file.
 */
void readPartitions(ByteFile *bf)
{
  int i ; 
  
  seekPos(bf, ALN_PARTITIONS); 
  
  assert(bf->partitions == (pInfo **)NULL); 
  bf->partitions = (pInfo **)calloc((size_t)bf->numPartitions, sizeof(pInfo*) );

  for(i = 0; i < bf->numPartitions; ++i)
    {
      bf->partitions[i] = (pInfo*)calloc(1,sizeof(pInfo));
      pInfo* p = bf->partitions[i];

      p->frequencies = (double*)NULL;
      p->partitionName = (char *)NULL;

      READ_VAR(bf->fh, p->states);     
      READ_VAR(bf->fh, p->maxTipStates);     
      READ_VAR(bf->fh, p->lower);
      READ_VAR(bf->fh, p->upper);
    
      /* DONT use this value! */
      READ_VAR(bf->fh, p->width);
      p->width = 0; 

      READ_VAR(bf->fh, p->dataType);
      
      READ_VAR(bf->fh, p->protModels);
      //READ_VAR(bf->fh, p->autoProtModels);
      READ_VAR(bf->fh, p->protFreqs);
      READ_VAR(bf->fh, p->nonGTR);
      READ_VAR(bf->fh, p->optimizeBaseFrequencies);
      //      READ_VAR(bf->fh, p->numberOfCategories);

      /* read string */
      unsigned int len = 0; 
      READ_VAR(bf->fh, len); 
      p->partitionName = (char*)calloc(len,sizeof(char));
      READ_ARRAY(bf->fh, p->partitionName, len, sizeof(char)); 

      p->frequencies = (double*)calloc((size_t)p->states, sizeof(double)); 
      READ_ARRAY(bf->fh, p->frequencies, (size_t)p->states , sizeof(double)); 

     
    }
  
  bf->hasRead |= ALN_PARTITIONS; 
}
Esempio n. 4
0
/** 
    reads the taxon names from the byte file  
 */ 
void readTaxa(ByteFile *bf)
{
  int i; 

  assert(bf->taxaNames == (char **)NULL);
  seekPos(bf,  ALN_TAXA); 

  bf->taxaNames = (char **)calloc(bf->numTax, sizeof(char*));
  for(i = 0; i < bf->numTax; ++i)
    {
      int len = 0; 
      READ_VAR(bf->fh, len ); 
      bf->taxaNames[i] = (char*)calloc(len, sizeof(char)); 
      READ_ARRAY(bf->fh, bf->taxaNames[i], len, sizeof(char)); 
    }

  bf->hasRead |= ALN_TAXA; 
}
Esempio n. 5
0
/** 
    uses the information in the PartitionAssignment to only extract
    data relevant to this process (weights and alignment characters).
 */ 
void readMyData(ByteFile *bf, PartitionAssignment *pa, int procId)
{
  seekPos(bf, ALN_ALIGNMENT); 

  exa_off_t
    alnPos = exa_ftell(bf->fh); 

  size_t 
    len; 

  int numAssign = pa->numAssignPerProc[procId];
  Assignment *myAssigns = pa->assignPerProc[procId];

  /* first read aln characters   */
  int i,j ; 
  for(i = 0; i < numAssign; ++i )
    {
      Assignment a = myAssigns[i]; 
      /* printf("reading for: ") ;  */
      /* printAssignment(a, procId);  */

      pInfo 
	*partition = bf->partitions[a.partId];     

      partition->width = a.width; 
      partition->offset = a.offset; 
      len = (size_t)bf->numTax * a.width; 

      if(isPomo(partition->dataType))
	{	  
	  double 
	    *xTip =  (double *)malloc_aligned(len * (size_t)partition->states * sizeof(double));
	  
	  partition->xResource = (double *)malloc_aligned(len * (size_t)partition->states * sizeof(double)); 
	  
	  memset(partition->xResource, 0, len * (size_t)partition->states * sizeof(double));  
	  memset(xTip,                 0, len * (size_t)partition->states * sizeof(double)); 

	  partition->xTipCLV    = (double **)calloc((size_t)bf->numTax + 1 , sizeof(double *)); 
	  partition->xTipVector = (double **)calloc((size_t)bf->numTax + 1 , sizeof(double *)); 

	  for(j = 1; j <= bf->numTax; ++j)
	    {
	      partition->xTipCLV[j]    = partition->xResource + (size_t)(j-1) * a.width * (size_t)partition->states; 
	      partition->xTipVector[j] = xTip                 + (size_t)(j-1) * a.width * (size_t)partition->states;	      
	    }
	}
      else
	{
	  partition->yResource = (unsigned char*)malloc_aligned( len * sizeof(unsigned char)); 
	  memset(partition->yResource,0,(size_t)len * sizeof(unsigned char)); 
	  partition->yVector = (unsigned char**) calloc((size_t)bf->numTax + 1 , sizeof(unsigned char*)); 
	  for(j = 1; j <= bf->numTax; ++j)
	    partition->yVector[j] = partition->yResource + (size_t)(j-1) * a.width; 
	}

#ifdef OLD_LAYOUT
      for(j = 1; j <= bf->numTax; ++j )
	{
	  exa_off_t pos = alnPos + (  bf->numPattern * (j-1)    +  partition->lower + a.offset ) * sizeof(unsigned char); 
	  assert(alnPos <= pos); 
	  exa_fseek(bf->fh, pos, SEEK_SET); 
	  READ_ARRAY(bf->fh, partition->yVector[j], a.width, sizeof(unsigned char));
	}
#else 
      /*  if the entire partition is assigned to this process, read it
          in one go. Otherwise, several seeks are necessary.  */
      if( a.width == (partition->upper - partition->lower ) )
        { 
	  if(isPomo(partition->dataType))
	    {
	      exa_off_t
		pos = alnPos +  (exa_off_t)partition->lower * (exa_off_t)bf->numTax * (exa_off_t)partition->states * (exa_off_t)sizeof(double); 
	      
	      assert(alnPos <= pos); 
	      exa_fseek(bf->fh, pos, SEEK_SET); 
	      READ_ARRAY(bf->fh, partition->xResource, a.width * (size_t)bf->numTax * (size_t)partition->states, sizeof(double));
	    }
	  else
	    {
	      exa_off_t
		pos = alnPos + ((exa_off_t)partition->lower * (exa_off_t)bf->numTax) * (exa_off_t)sizeof(unsigned char); 
	      
	      assert(alnPos <= pos); 
	      exa_fseek(bf->fh, pos, SEEK_SET); 
	      READ_ARRAY(bf->fh, partition->yResource, a.width * (size_t)bf->numTax, sizeof(unsigned char));
	    }
        }
      else 
        {
          for(j = 1; j <= bf->numTax; ++j )
            {
	      if(isPomo(partition->dataType))
		{
		  exa_off_t 
		    pos = alnPos + (exa_off_t)sizeof(double) * (exa_off_t)partition->states 
		    * ( 
		       ((exa_off_t)partition->lower * (exa_off_t)bf->numTax ) /* until start of partition  */
		       + ((exa_off_t)(j-1) * ((exa_off_t)partition->upper - (exa_off_t)partition->lower) ) /* until start of sequence of taxon within partition */
		       + (exa_off_t)a.offset )  ; 
		  
		  assert(alnPos <= pos); 
		  exa_fseek(bf->fh, pos, SEEK_SET); 
		  READ_ARRAY(bf->fh, partition->xTipCLV[j], a.width * (size_t)partition->states, sizeof(double));
		}
	      else
		{
		  exa_off_t 
		    pos = alnPos + (exa_off_t)sizeof(unsigned char) 
		    * ( 
		       ((exa_off_t)partition->lower * (exa_off_t)bf->numTax ) /* until start of partition  */
		       + ((exa_off_t)(j-1) * ((exa_off_t)partition->upper - (exa_off_t)partition->lower) ) /* until start of sequence of taxon within partition */
		       + (exa_off_t)a.offset )  ; 
		  
		  assert(alnPos <= pos); 
		  exa_fseek(bf->fh, pos, SEEK_SET); 
		  READ_ARRAY(bf->fh, partition->yVector[j], a.width, sizeof(unsigned char));
		}
            }
        }
#endif
    }

  
  /* now read weights  */
  seekPos(bf, ALN_WEIGHTS); 

  exa_off_t
    wgtPos = exa_ftell(bf->fh); 
  assert( ! (wgtPos <  0) );

  for(i = 0; i < numAssign; ++i)
    {
      Assignment a = myAssigns[i]; 
      pInfo *partition = bf->partitions[a.partId];

#ifdef __MIC_NATIVE
     /* for Xeon Phi, wgt must be padded to the multiple of 8 (because of site blocking in kernels) */
     const int padded_width = GET_PADDED_WIDTH(a.width);
     len = padded_width * sizeof(int);
#else
     len = a.width * sizeof(int);
#endif

      partition->wgt = (int*)malloc_aligned( len); 
      memset(partition->wgt, 0, len); 

      exa_off_t pos = wgtPos +  ((exa_off_t)partition->lower  + (exa_off_t)a.offset) * (exa_off_t)sizeof(int); 
      assert(wgtPos <= pos );
      
      exa_fseek(bf->fh, pos, SEEK_SET); 
      READ_ARRAY(bf->fh, partition->wgt, a.width, sizeof(int)); 

    }

  bf->hasRead |= ALN_ALIGNMENT; 
  bf->hasRead |= ALN_WEIGHTS; 
}