/* * Write a sequence to a file "fn" of format "format". If "format" is 0, * we choose our favourite - SCF. * * Returns: * 0 for success * -1 for failure */ int write_reading(char *fn, Read *read, int format) { mFILE *fp = mfopen(fn, "wb"); if (!fp) return -1; return mfwrite_reading(fp, read, format); }
static int convert(char *in, mFILE *ofp, char *out, int format, int prec, int comp, int normalise) { Read *r; if (NULL == (r = read_reading(in, format))) { fprintf(stderr, "%s: failed to read\n", in); return 1; } if (normalise) { subtract_background(r); reset_max_called_height(r); rescale_heights(r); } add_comments(r, in, format); if (prec == 1) scale_trace8(r); if (comp != -1) set_compression_method(comp); if (0 != (mfwrite_reading(ofp, r, TT_SCF))) { fprintf(stderr, "%s: failed to write\n", out); read_deallocate(r); return 1; } read_deallocate(r); return 0; }
/*! * Write a sequence to a file "fn" of format "format". If "format" is 0, * we choose our favourite - SCF. * * Returns: * 0 for success * -1 for failure */ int write_reading(char *fn, Read *read, int format) { int ret; mFILE *fp = mfopen(fn, "wb"); if (!fp) return -1; ret = mfwrite_reading(fp, read, format); mfclose(fp); return ret; }
/*! * Write a sequence to a FILE *fp of format "format". If "format" is 0, * we choose our favourite - SCF. * * Returns: * 0 for success * -1 for failure */ int fwrite_reading(FILE *fp, Read *read, int format) { int ret; mFILE *mf = mfreopen(NULL, "wbx", fp); if (mf) { ret = mfwrite_reading(mf, read, format); mfflush(mf); mf->fp = NULL; /* Don't want this closed here */ mfclose(mf); } else { return -1; } return ret; }
int fwrite_reading(FILE *fp, Read *read, int format) { return mfwrite_reading(mfreopen(NULL, "w", fp), read, format); }