view srf2fastq/io_lib-1.12.2/io_lib/seqIOCTF.c @ 0:d901c9f41a6a default tip

Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
author dawe
date Tue, 07 Jun 2011 17:48:05 -0400
parents
children
line wrap: on
line source

/* 
 * Title:       seqIOCTF
 * 
 * File: 	seqIOCTF.c
 * Purpose:	Reading/writing of CTF sequences
 * Last update: March 2000
 *
 * Change log:
 * Created mieg, march 2000, importing code from wabi/ctftrace.c
 */


/* ---- Imports ---- */

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>

#include "io_lib/Read.h"
#include "io_lib/seqIOCTF.h"
#include "io_lib/abi.h"
#include "io_lib/mach-io.h"
#include "io_lib/xalloc.h"
#include "io_lib/stdio_hack.h"

/* ---- Constants ---- */

/*
 * Read the CTF format sequence from FILE *fp into a Read structure.

 * Returns:
 *   Read *	- Success, the Read structure read.
 *   NULLRead	- Failure.
 */
Read *fread_ctf (FILE *fp) {
    Read *read = ctfFRead (fp) ;

    return read ;
}

/*
 * Read the CTF format sequence from file 'fn' into a Read structure.
 */

Read *read_ctf (char *fn) {
    Read *read;
    FILE *fp;

    /* Open file */
    if ((fp = fopen(fn, "rb")) == NULL)
	return NULLRead;

    read = fread_ctf(fp);
    fclose(fp);

    if (read && (read->trace_name = (char *)xmalloc(strlen(fn)+1)))
	strcpy(read->trace_name, fn);

    return read;
}
    

/*
 * Write to an CTF file - unsupported.
 */
/* ARGSUSED */
int fwrite_ctf (FILE *fp, Read *read) {
  return ctfFWrite (fp, read) ;
}

/*
 * Write to an CTF file 
 */
/* ARGSUSED */
int write_ctf(char *fn, Read *read) {
  FILE *fp;
  
  /* Open file */
  if ((fp = fopen(fn, "wb")) == NULL)
    return -1 ;
  
  fwrite_ctf (fp, read) ;
  fclose(fp);

  return 0 ;
}