예제 #1
0
파일: sff.c 프로젝트: golharam/TS
sff_t *
sff_init1()
{
  sff_t *sff = NULL;

  sff = ion_calloc(1, sizeof(sff_t), __func__, "sff");
  sff->gheader = NULL;
  sff->rheader = sff_read_header_init();
  sff->read = sff_read_init();

  return sff;
}
예제 #2
0
파일: sff_read_header.c 프로젝트: alecw/TS
sff_read_header_t *
sff_read_header_read(FILE *fp)
{
  sff_read_header_t *rh = NULL;
  uint32_t n = 0;

  rh = sff_read_header_init();

  if(1 != fread(&rh->rheader_length, sizeof(uint16_t), 1, fp)
     || 1 != fread(&rh->name_length, sizeof(uint16_t), 1, fp)
     || 1 != fread(&rh->n_bases, sizeof(uint32_t), 1, fp)
     || 1 != fread(&rh->clip_qual_left, sizeof(uint16_t), 1, fp)
     || 1 != fread(&rh->clip_qual_right, sizeof(uint16_t), 1, fp)
     || 1 != fread(&rh->clip_adapter_left, sizeof(uint16_t), 1, fp)
     || 1 != fread(&rh->clip_adapter_right, sizeof(uint16_t), 1, fp)) {
      free(rh);
      return NULL;
  }
  n += sizeof(uint32_t) + 6*sizeof(uint16_t);

  // convert values from big-endian
  sff_read_header_ntoh(rh);

  rh->name = ion_string_init(rh->name_length+1);

  if(rh->name_length != fread(rh->name->s, sizeof(char), rh->name_length, fp)) {
      // truncated file, error
      ion_error(__func__, "fread", Exit, ReadFileError);
  }
  n += sizeof(char)*rh->name_length;

  // set read name length and null-terminator
  rh->name->l = rh->name_length;
  rh->name->s[rh->name->l]='\0';

  n += ion_read_padding(fp, n);

#ifdef ION_SFF_DEBUG
  sff_read_header_print(stderr, rh);
#endif

  if(rh->rheader_length != n) {
      ion_error(__func__, "SFF read header length did not match", Exit, ReadFileError);
  }

  return rh;
}