Skip to content
Commits on Source (9)
......@@ -33,10 +33,10 @@ sudo: false
# Copied from https://github.com/nim-lang/Nim/wiki/TravisCI
#language: c
env:
# Build and test against the master and devel branches of Nim
#- BRANCH=master
- BRANCH=devel
#- BRANCH=v0.17.2
# Build and test against the master and/or devel branches of Nim
- BRANCH=master
#- BRANCH=devel
#- BRANCH=v0.18.0
compiler:
# Build and test using both gcc and clang
- gcc
......@@ -76,8 +76,8 @@ before_script:
# - nim doc --docSeeSrcUrl:https://github.com/AUTHOR/MYPROJECT/blob/master --project MYFILE.nim
cache:
directories:
#- nim-master
- nim-devel
- nim-master
#- nim-devel
branches:
except:
- gh-pages
This diff is collapsed.
This diff is collapsed.
......@@ -16,7 +16,7 @@
static char *Usage = "[-U] [-w<int(80)>] <path:db>";
int main(int argc, char *argv[])
{ HITS_DB _db, *db = &_db;
{ DAZZ_DB _db, *db = &_db;
FILE *dbfile;
int nfiles;
int UPPER, WIDTH;
......@@ -83,7 +83,7 @@ int main(int argc, char *argv[])
// For each file do:
{ HITS_READ *reads;
{ DAZZ_READ *reads;
char *read;
int f, first;
FILE *ofile;
......@@ -107,7 +107,7 @@ int main(int argc, char *argv[])
for (i = first; i < last && i < db->nreads; i++)
{ int j, len;
HITS_READ *r;
DAZZ_READ *r;
r = reads + i;
len = r->rlen;
......
......@@ -6,7 +6,7 @@
#include <assert.h>
// From Jason, with 1 change
static char* Load_Read_Data(HITS_DB *db) {
static char* Load_Read_Data(DAZZ_DB *db) {
FILE *bases = (FILE*) db->bases;
struct stat sbuf;
char *data;
......@@ -22,7 +22,7 @@ static char* Load_Read_Data(HITS_DB *db) {
}
// Wrapper
int Open_DBX(char *path, HITS_DBX *dbx, bool preload) {
int Open_DBX(char *path, DAZZ_DBX *dbx, bool preload) {
dbx->data = NULL;
int rc = Open_DB(path, &dbx->db);
switch (rc) {
......@@ -44,10 +44,10 @@ int Open_DBX(char *path, HITS_DBX *dbx, bool preload) {
}
// From Jason
static int Load_Read_From_RAM(HITS_DB *db, char *data, int i, char *read, int ascii) {
static int Load_Read_From_RAM(DAZZ_DB *db, char *data, int i, char *read, int ascii) {
int64 off;
int len, clen;
HITS_READ *r = db->reads;
DAZZ_READ *r = db->reads;
if (i >= db->nreads) { EXIT(1); }
......@@ -70,7 +70,7 @@ static int Load_Read_From_RAM(HITS_DB *db, char *data, int i, char *read, int as
}
// Wrapper
int Load_ReadX(HITS_DBX *dbx, int i, char *read, int ascii) {
int Load_ReadX(DAZZ_DBX *dbx, int i, char *read, int ascii) {
if (dbx->data) {
return Load_Read_From_RAM(&dbx->db, dbx->data, i, read, ascii);
} else {
......@@ -79,7 +79,7 @@ int Load_ReadX(HITS_DBX *dbx, int i, char *read, int ascii) {
}
// Wrapper
void Close_DBX(HITS_DBX *dbx) {
void Close_DBX(DAZZ_DBX *dbx) {
Close_DB(&dbx->db);
if (dbx->data) free(dbx->data);
}
#ifndef DALIGNER_DBX_H
#define DALIGNER_DBX_H
/* Wrappers to extend HITS_DB.
/* Wrappers to extend DAZZ_DB.
*
* Note that none of the extra fields are ever stored on-disk.
*/
......@@ -8,18 +8,18 @@
#include <stdbool.h>
typedef struct {
HITS_DB db;
DAZZ_DB db;
/*
* When "data" is non-null, it stores the entire DB
* in memory, so we can avoid random-access disk operations.
* But if null, then wrappers simply delegate.
*/
char* data;
} HITS_DBX;
} DAZZ_DBX;
int Open_DBX(char *path, HITS_DBX *dbx, bool preload);
int Load_ReadX(HITS_DBX *dbx, int i, char *read, int ascii);
//void Trim_DB(HITS_DBX *dbx);
void Close_DBX(HITS_DBX *dbx);
int Open_DBX(char *path, DAZZ_DBX *dbx, bool preload);
int Load_ReadX(DAZZ_DBX *dbx, int i, char *read, int ascii);
//void Trim_DB(DAZZ_DBX *dbx);
void Close_DBX(DAZZ_DBX *dbx);
#endif
/*****************************************************************************\
PacBio Disclaimer
THIS WEBSITE AND CONTENT AND ALL SITE-RELATED SERVICES, INCLUDING ANY DATA, ARE
PROVIDED "AS IS," WITH ALL FAULTS, WITH NO REPRESENTATIONS OR WARRANTIES OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTIES
OF MERCHANTABILITY, SATISFACTORY QUALITY, NON-INFRINGEMENT OR FITNESS FOR A
PARTICULAR PURPOSE. YOU ASSUME TOTAL RESPONSIBILITY AND RISK FOR YOUR USE OF
THIS SITE, ALL SITE-RELATED SERVICES, AND ANY THIRD PARTY WEBSITES OR
APPLICATIONS. NO ORAL OR WRITTEN INFORMATION OR ADVICE SHALL CREATE A WARRANTY
OF ANY KIND. ANY REFERENCES TO SPECIFIC PRODUCTS OR SERVICES ON THE WEBSITES DO
NOT CONSTITUTE OR IMPLY A RECOMMENDATION OR ENDORSEMENT BY PACIFIC BIOSCIENCES.
\******************************************************************************/
THISDIR:=$(abspath $(dir $(realpath $(lastword ${MAKEFILE_LIST}))))
LIBDIRS?=${THISDIR}/../DAZZ_DB
#LIBDIRS?=${THISDIR}/../DAZZ_DB
CFLAGS+= -O3 -Wall -Wextra -fno-strict-aliasing -Wno-unused-result
CPPFLAGS+= -I${THISDIR}/../DAZZ_DB -I${PREFIX}/include
#CPPFLAGS+= -I${THISDIR}/../DAZZ_DB -I${PREFIX}/include
#CPPFLAGS+= -MMD -MP
LDLIBS+= -ldazzdb -lm -lpthread
LDLIBS+= -lm -lpthread
LDFLAGS+= $(patsubst %,-L%,${LIBDIRS})
MOST = daligner HPC.daligner LAsort LAmerge LAsplit LAcat LAshow LAdump LAcheck LAindex
ALL:=${MOST} daligner_p LA4Falcon LA4Ice DB2Falcon
vpath %.c ${THISDIR}
vpath %.a ${THISDIR}/../DAZZ_DB
#vpath %.a ${THISDIR}/../DAZZ_DB
%: %.c
......@@ -16,7 +16,9 @@ all: ${ALL}
daligner: filter.o
daligner_p: filter_p.o
LA4Falcon: DBX.o
${ALL}: align.o
${ALL}: libdazzdb.a
libdazzdb.a: libdazzdb.a(DB.o QV.o align.o)
install:
rsync -av ${ALL} ${PREFIX}/bin
......@@ -25,7 +27,7 @@ symlink:
clean:
rm -f ${ALL}
rm -f ${DEPS}
rm -fr *.dSYM *.o *.d
rm -fr *.dSYM *.o *.d *.a
.PHONY: clean all
......
This diff is collapsed.
......@@ -147,7 +147,7 @@ static bool add_overlap(const Alignment *aln, const Overlap *ovl, const int coun
return added;
}
static void print_hits(const int hit_count, HITS_DBX *dbx2, char *bbuffer, char buffer[], int64 bsize, const int MAX_HIT_COUNT) {
static void print_hits(const int hit_count, DAZZ_DBX *dbx2, char *bbuffer, char buffer[], int64 bsize, const int MAX_HIT_COUNT) {
int tmp_idx;
qsort(ovlgrps, (hit_count+1), sizeof(OverlapGroup), compare_ovlgrps);
for (tmp_idx = 0; tmp_idx < (hit_count+1) && tmp_idx < MAX_HIT_COUNT; tmp_idx++) {
......@@ -159,7 +159,7 @@ static void print_hits(const int hit_count, HITS_DBX *dbx2, char *bbuffer, char
int64 const rlen = (int64)(grp->end.path.bepos) - (int64)(grp->beg.path.bbpos);
if (rlen < bsize) {
strncpy( buffer, bbuffer + grp->beg.path.bbpos, rlen );
buffer[rlen - 1] = '\0';
buffer[rlen] = '\0';
printf("%08d %s\n", grp->end.bread, buffer);
} else {
fprintf(stderr, "[WARNING]Skipping super-long read %08d, len=%lld, buf=%lld\n", grp->end.bread, rlen, bsize);
......@@ -182,10 +182,10 @@ static int ORDER(const void *l, const void *r)
}
int main(int argc, char *argv[])
{ HITS_DBX _dbx1, *dbx1 = &_dbx1;
HITS_DBX _dbx2, *dbx2 = &_dbx2;
HITS_DB *db1 = &dbx1->db;
HITS_DB *db2 = &dbx2->db;
{ DAZZ_DBX _dbx1, *dbx1 = &_dbx1;
DAZZ_DBX _dbx2, *dbx2 = &_dbx2;
DAZZ_DB *db1 = &dbx1->db;
DAZZ_DB *db2 = &dbx2->db;
Overlap _ovl, *ovl = &_ovl;
Alignment _aln, *aln = &_aln;
......@@ -457,9 +457,9 @@ int main(int argc, char *argv[])
exit (1);
if (fread(&novl,sizeof(int64),1,input) != 1)
SYSTEM_ERROR
SYSTEM_READ_ERROR
if (fread(&tspace,sizeof(int),1,input) != 1)
SYSTEM_ERROR
SYSTEM_READ_ERROR
if (tspace == 0) {
printf("\nCRITICAL ERROR: tspace=0 in '%s'", root);
......
......@@ -72,8 +72,8 @@ static int ORDER(const void *l, const void *r)
}
int main(int argc, char *argv[])
{ HITS_DB _db1, *db1 = &_db1;
HITS_DB _db2, *db2 = &_db2;
{ DAZZ_DB _db1, *db1 = &_db1;
DAZZ_DB _db2, *db2 = &_db2;
Overlap _ovl, *ovl = &_ovl;
Alignment _aln, *aln = &_aln;
......@@ -259,9 +259,9 @@ int main(int argc, char *argv[])
exit (1);
if (fread(&novl,sizeof(int64),1,input) != 1)
SYSTEM_ERROR
SYSTEM_READ_ERROR
if (fread(&tspace,sizeof(int),1,input) != 1)
SYSTEM_ERROR
SYSTEM_READ_ERROR
if (tspace <= TRACE_XOVR)
{ small = 1;
......
......@@ -90,13 +90,13 @@ int main(int argc, char *argv[])
if ((input = fopen(name,"r")) == NULL) break;
if (fread(&povl,sizeof(int64),1,input) != 1)
SYSTEM_ERROR
SYSTEM_READ_ERROR
novl += povl;
if (fread(&mspace,sizeof(int),1,input) != 1)
SYSTEM_ERROR
SYSTEM_READ_ERROR
if (i == 0)
{ tspace = mspace;
if (tspace <= TRACE_XOVR)
if (tspace <= TRACE_XOVR && tspace != 0)
tbytes = sizeof(uint8);
else
tbytes = sizeof(uint16);
......@@ -108,8 +108,10 @@ int main(int argc, char *argv[])
fclose(input);
}
fwrite(&novl,sizeof(int64),1,stdout);
fwrite(&tspace,sizeof(int),1,stdout);
if (fwrite(&novl,sizeof(int64),1,stdout) != 1)
SYSTEM_READ_ERROR
if (fwrite(&tspace,sizeof(int),1,stdout) != 1)
SYSTEM_READ_ERROR
}
{ int i, j;
......@@ -127,9 +129,9 @@ int main(int argc, char *argv[])
if ((input = fopen(name,"r")) == NULL) break;
if (fread(&povl,sizeof(int64),1,input) != 1)
SYSTEM_ERROR
SYSTEM_READ_ERROR
if (fread(&mspace,sizeof(int),1,input) != 1)
SYSTEM_ERROR
SYSTEM_READ_ERROR
if (VERBOSE)
fprintf(stderr," Concatenating %s: %lld la\'s\n",Numbered_Suffix(root,i+1,root2),povl);
......@@ -141,7 +143,7 @@ int main(int argc, char *argv[])
{ if (iptr + ovlsize > itop)
{ int64 remains = itop-iptr;
if (remains > 0)
memcpy(iblock,iptr,remains);
memmove(iblock,iptr,remains);
iptr = iblock;
itop = iblock + remains;
itop += fread(itop,1,bsize-remains,input);
......@@ -151,24 +153,25 @@ int main(int argc, char *argv[])
tsize = w->path.tlen*tbytes;
if (optr + ovlsize + tsize > otop)
{ fwrite(oblock,1,optr-oblock,stdout);
{ if (fwrite(oblock,1,optr-oblock,stdout) != (size_t) (optr-oblock))
SYSTEM_READ_ERROR
optr = oblock;
}
memcpy(optr,iptr,ovlsize);
memmove(optr,iptr,ovlsize);
optr += ovlsize;
iptr += ovlsize;
if (iptr + tsize > itop)
{ int64 remains = itop-iptr;
if (remains > 0)
memcpy(iblock,iptr,remains);
memmove(iblock,iptr,remains);
iptr = iblock;
itop = iblock + remains;
itop += fread(itop,1,bsize-remains,input);
}
memcpy(optr,iptr,tsize);
memmove(optr,iptr,tsize);
optr += tsize;
iptr += tsize;
}
......@@ -177,7 +180,9 @@ int main(int argc, char *argv[])
}
if (optr > oblock)
fwrite(oblock,1,optr-oblock,stdout);
{ if (fwrite(oblock,1,optr-oblock,stdout) != (size_t) (optr-oblock))
SYSTEM_READ_ERROR
}
}
if (VERBOSE)
......
......@@ -23,8 +23,8 @@ static char *Usage = "[-vS] <src1:db|dam> [ <src2:db|dam> ] <align:las> ...";
#define MEMORY 1000 // How many megabytes for output buffer
int main(int argc, char *argv[])
{ HITS_DB _db1, *db1 = &_db1;
HITS_DB _db2, *db2 = &_db2;
{ DAZZ_DB _db1, *db1 = &_db1;
DAZZ_DB _db2, *db2 = &_db2;
int VERBOSE;
int SORTED;
int ISTWO;
......@@ -103,9 +103,9 @@ int main(int argc, char *argv[])
{ char *iblock;
int64 bsize, ovlsize, ptrsize;
int i, j;
HITS_READ *reads1 = db1->reads;
DAZZ_READ *reads1 = db1->reads;
int nreads1 = db1->nreads;
HITS_READ *reads2 = db2->reads;
DAZZ_READ *reads2 = db2->reads;
int nreads2 = db2->nreads;
// Setup IO buffers
......@@ -138,9 +138,9 @@ int main(int argc, char *argv[])
goto error;
if (fread(&novl,sizeof(int64),1,input) != 1)
SYSTEM_ERROR
SYSTEM_READ_ERROR
if (fread(&tspace,sizeof(int),1,input) != 1)
SYSTEM_ERROR
SYSTEM_READ_ERROR
if (novl < 0)
{ if (VERBOSE)
fprintf(stderr," %s: Number of alignments < 0\n",root);
......@@ -152,7 +152,7 @@ int main(int argc, char *argv[])
goto error;
}
if (tspace <= TRACE_XOVR)
if (tspace <= TRACE_XOVR && tspace != 0)
tbytes = sizeof(uint8);
else
tbytes = sizeof(uint16);
......@@ -179,7 +179,7 @@ int main(int argc, char *argv[])
if (iptr + ovlsize > itop)
{ int64 remains = itop-iptr;
if (remains > 0)
memcpy(iblock,iptr,remains);
memmove(iblock,iptr,remains);
iptr = iblock;
itop = iblock + remains;
itop += fread(itop,1,bsize-remains,input);
......@@ -197,7 +197,7 @@ int main(int argc, char *argv[])
if (iptr + tsize > itop)
{ int64 remains = itop-iptr;
if (remains > 0)
memcpy(iblock,iptr,remains);
memmove(iblock,iptr,remains);
iptr = iblock;
itop = iblock + remains;
itop += fread(itop,1,bsize-remains,input);
......
......@@ -22,7 +22,7 @@
#include "align.h"
static char *Usage =
"[-cdt] [-o] <src1:db|dam> [ <src2:db|dam> ] <align:las> [ <reads:FILE> | <reads:range> ... ]";
"[-cdtlo] <src1:db|dam> [<src2:db|dam>] <align:las> [<reads:FILE> | <reads:range> ...]";
#define LAST_READ_SYMBOL '$'
......@@ -33,18 +33,19 @@ static int ORDER(const void *l, const void *r)
}
int main(int argc, char *argv[])
{ HITS_DB _db1, *db1 = &_db1;
HITS_DB _db2, *db2 = &_db2;
{ DAZZ_DB _db1, *db1 = &_db1;
DAZZ_DB _db2, *db2 = &_db2;
Overlap _ovl, *ovl = &_ovl;
FILE *input;
int64 novl;
int tspace, tbytes, small;
int tmax;
int reps, *pts;
int input_pts;
int OVERLAP;
int DOCOORDS, DODIFFS, DOTRACE;
int DOCOORDS, DODIFFS, DOTRACE, DOLENS;
int ISTWO;
// Process options
......@@ -59,7 +60,7 @@ int main(int argc, char *argv[])
if (argv[i][0] == '-')
switch (argv[i][1])
{ default:
ARG_FLAGS("ocdtUF")
ARG_FLAGS("ocdtl")
break;
}
else
......@@ -70,12 +71,33 @@ int main(int argc, char *argv[])
DOCOORDS = flags['c'];
DODIFFS = flags['d'];
DOTRACE = flags['t'];
DOLENS = flags['l'];
if (DOTRACE)
DOCOORDS = 1;
if (argc <= 2)
{ fprintf(stderr,"Usage: %s %s\n",Prog_Name,Usage);
fprintf(stderr,"\n");
fprintf(stderr," P #a #b #o #c -");
fprintf(stderr," (#a,#b^#o) have an LA between them where #o is 'n' or 'c' and\n");
fprintf(stderr," ");
fprintf(stderr," #c is '>' (start of best chain), '+' (start of alternate chain),\n");
fprintf(stderr," ");
fprintf(stderr," '-' (continuation of chain), or '.' (no chains in file).\n");
fprintf(stderr,"\n");
fprintf(stderr," -c: C #ab #ae #bb #be - #a[#ab,#ae] aligns with #b^#o[#bb,#be]\n");
fprintf(stderr," -d: D # - there are # differences in the LA\n");
fprintf(stderr," -t: T #n -");
fprintf(stderr," there are #n trace point intervals for the LA\n");
fprintf(stderr," (#d #y )^#n -");
fprintf(stderr," there are #d difference aligning the #y bp's of B with the\n");
fprintf(stderr," next fixed-size interval of A\n");
fprintf(stderr," -l: L #la #lb -");
fprintf(stderr," #la is the length of the a-read and #lb that of the b-read\n");
fprintf(stderr,"\n");
fprintf(stderr," -o: Output proper overlaps only\n");
exit (1);
}
}
......@@ -258,11 +280,11 @@ int main(int argc, char *argv[])
exit (1);
if (fread(&novl,sizeof(int64),1,input) != 1)
SYSTEM_ERROR
SYSTEM_READ_ERROR
if (fread(&tspace,sizeof(int),1,input) != 1)
SYSTEM_ERROR
SYSTEM_READ_ERROR
if (tspace <= TRACE_XOVR)
if (tspace <= TRACE_XOVR && tspace != 0)
{ small = 1;
tbytes = sizeof(uint8);
}
......@@ -279,7 +301,7 @@ int main(int argc, char *argv[])
{ int j, al, tlen;
int in, npt, idx, ar;
int64 novls, odeg, omax, sdeg, smax, ttot, tmax;
int64 novls, odeg, omax, sdeg, smax, ttot;
in = 0;
npt = pts[0];
......@@ -359,32 +381,31 @@ int main(int argc, char *argv[])
printf("+ P %lld\n",novls);
printf("%% P %lld\n",omax);
printf("+ T %lld\n",ttot);
if (DOTRACE)
{ printf("+ T %lld\n",ttot);
printf("%% T %lld\n",smax);
printf("@ T %lld\n",tmax);
printf("@ T %d\n",tmax);
}
}
// Read the file and display selected records
{ int j;
{ int j, k;
uint16 *trace;
int tmax;
int in, npt, idx, ar;
int64 verse;
DAZZ_READ *read1, *read2;
rewind(input);
fread(&verse,sizeof(int64),1,input);
fread(&novl,sizeof(int64),1,input);
fread(&tspace,sizeof(int),1,input);
if (verse < 0)
{ for (j = 0; j < 5; j++)
fread(&verse,sizeof(int64),1,input);
}
tmax = 1000;
trace = (uint16 *) Malloc(sizeof(uint16)*tmax,"Allocating trace vector");
if (trace == NULL)
exit (1);
read1 = db1->reads;
read2 = db2->reads;
in = 0;
npt = pts[0];
idx = 1;
......@@ -396,12 +417,6 @@ int main(int argc, char *argv[])
// Read it in
{ Read_Overlap(input,ovl);
if (ovl->path.tlen > tmax)
{ tmax = ((int) 1.2*ovl->path.tlen) + 100;
trace = (uint16 *) Realloc(trace,sizeof(uint16)*tmax,"Allocating trace vector");
if (trace == NULL)
exit (1);
}
ovl->path.trace = (void *) trace;
Read_Trace(input,ovl,tbytes);
......@@ -458,6 +473,9 @@ int main(int argc, char *argv[])
printf(" .");
printf("\n");
if (DOLENS)
printf("L %d %d\n",read1[ovl->aread].rlen,read2[ovl->bread].rlen);
if (DOCOORDS)
printf("C %d %d %d %d\n",ovl->path.abpos,ovl->path.aepos,ovl->path.bbpos,ovl->path.bepos);
......@@ -471,8 +489,8 @@ int main(int argc, char *argv[])
if (small)
Decompress_TraceTo16(ovl);
printf("T %d\n",tlen>>1);
for (j = 0; j < tlen; j += 2)
printf(" %3d %3d\n",trace[j],trace[j+1]);
for (k = 0; k < tlen; k += 2)
printf(" %3d %3d\n",trace[k],trace[k+1]);
}
}
......
......@@ -80,10 +80,10 @@ int main(int argc, char *argv[])
exit (1);
if (fread(&novl,sizeof(int64),1,input) != 1)
SYSTEM_ERROR
SYSTEM_READ_ERROR
if (fread(&tspace,sizeof(int),1,input) != 1)
SYSTEM_ERROR
if (tspace <= TRACE_XOVR)
SYSTEM_READ_ERROR
if (tspace <= TRACE_XOVR && tspace != 0)
tbytes = sizeof(uint8);
else
tbytes = sizeof(uint16);
......@@ -126,7 +126,7 @@ int main(int argc, char *argv[])
{ if (iptr + ovlsize > itop)
{ int64 remains = itop-iptr;
if (remains > 0)
memcpy(iblock,iptr,remains);
memmove(iblock,iptr,remains);
iptr = iblock;
itop = iblock + remains;
itop += fread(itop,1,bsize-remains,input);
......@@ -161,7 +161,7 @@ int main(int argc, char *argv[])
if (iptr + tsize > itop)
{ int64 remains = itop-iptr;
if (remains > 0)
memcpy(iblock,iptr,remains);
memmove(iblock,iptr,remains);
iptr = iblock;
itop = iblock + remains;
itop += fread(itop,1,bsize-remains,input);
......
......@@ -48,24 +48,6 @@ static char *Usage = "[-va] <merge:las> <parts:las> ...";
else \
bigger = 0;
static void Fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream) {
size_t rc = fwrite(ptr, size, nmemb, stream);
if (rc != nmemb) {
EPRINTF(EPLACE," Error writing %zu elements (of size %zu)\n", nmemb, size);
exit(1);
}
}
static void Fclose(FILE *stream) {
// An error in fclose() could be caused by an earlier failure in fwrite().
// 'man fclose' for details.
int rc = fclose(stream);
if (rc != 0) {
EPRINTF(EPLACE," Error closing stream.\n");
exit(1);
}
}
static void reheap(int s, Overlap **heap, int hsize)
{ int c, l, r;
int bigger;
......@@ -266,18 +248,17 @@ int main(int argc, char *argv[])
input = Fopen(Catenate(pwd,"/",root,".las"),"r");
if (input == NULL)
exit (1);
free(pwd);
free(root);
if (fread(&novl,sizeof(int64),1,input) != 1)
SYSTEM_ERROR
SYSTEM_READ_ERROR
totl += novl;
if (VERBOSE) fprintf(stdout, "In file %s, there are %lld records\n", Catenate(pwd,"/",root,".las"), novl);
free(pwd);
free(root);
if (fread(&mspace,sizeof(int),1,input) != 1)
SYSTEM_ERROR
SYSTEM_READ_ERROR
if (i == 0)
{ tspace = mspace;
if (tspace <= TRACE_XOVR)
if (tspace <= TRACE_XOVR && tspace != 0)
tbytes = sizeof(uint8);
else
tbytes = sizeof(uint16);
......@@ -306,8 +287,10 @@ int main(int argc, char *argv[])
free(pwd);
free(root);
Fwrite(&totl,sizeof(int64),1,output);
Fwrite(&tspace,sizeof(int),1,output);
if (fwrite(&totl,sizeof(int64),1,output) != 1)
SYSTEM_READ_ERROR
if (fwrite(&tspace,sizeof(int),1,output) != 1)
SYSTEM_READ_ERROR
oblock = block+fway*bsize;
optr = oblock;
......@@ -369,13 +352,14 @@ int main(int argc, char *argv[])
if (src->ptr + span > src->top)
ovl_reload(src,bsize);
if (optr + span > otop)
{ Fwrite(oblock,1,optr-oblock,output);
{ if (fwrite(oblock,1,optr-oblock,output) != (size_t) (optr-oblock))
SYSTEM_READ_ERROR
optr = oblock;
}
memcpy(optr,((char *) ov) + psize,osize);
memmove(optr,((char *) ov) + psize,osize);
optr += osize;
memcpy(optr,src->ptr,tsize);
memmove(optr,src->ptr,tsize);
optr += tsize;
src->ptr += tsize;
......@@ -393,8 +377,10 @@ int main(int argc, char *argv[])
// Flush output buffer and wind up
if (optr > oblock)
Fwrite(oblock,1,optr-oblock,output);
Fclose(output);
{ if (fwrite(oblock,1,optr-oblock,output) != (size_t) (optr-oblock))
SYSTEM_READ_ERROR
}
fclose(output);
for (i = 0; i < fway; i++)
fclose(in[i].stream);
......
......@@ -35,8 +35,8 @@ static int ORDER(const void *l, const void *r)
}
int main(int argc, char *argv[])
{ HITS_DB _db1, *db1 = &_db1;
HITS_DB _db2, *db2 = &_db2;
{ DAZZ_DB _db1, *db1 = &_db1;
DAZZ_DB _db2, *db2 = &_db2;
Overlap _ovl, *ovl = &_ovl;
Alignment _aln, *aln = &_aln;
......@@ -284,15 +284,15 @@ int main(int argc, char *argv[])
exit (1);
if (fread(&novl,sizeof(int64),1,input) != 1)
SYSTEM_ERROR
SYSTEM_READ_ERROR
if (fread(&tspace,sizeof(int),1,input) != 1)
SYSTEM_ERROR
if (tspace <= 0)
{ fprintf(stderr,"%s: Garbage .las file, trace spacing <= 0 !\n",Prog_Name);
SYSTEM_READ_ERROR
if (tspace < 0)
{ fprintf(stderr,"%s: Garbage .las file, trace spacing < 0 !\n",Prog_Name);
exit (1);
}
if (tspace <= TRACE_XOVR)
if (tspace <= TRACE_XOVR && tspace != 0)
{ small = 1;
tbytes = sizeof(uint8);
}
......@@ -353,12 +353,18 @@ int main(int argc, char *argv[])
if (db1->maxlen < db2->maxlen)
{ mn_wide = ai_wide;
mx_wide = bi_wide;
if (tspace > 0)
tp_wide = Number_Digits((int64) db1->maxlen/tspace+2);
else
tp_wide = 0;
}
else
{ mn_wide = bi_wide;
mx_wide = ai_wide;
if (tspace > 0)
tp_wide = Number_Digits((int64) db2->maxlen/tspace+2);
else
tp_wide = 0;
}
ar_wide += (ar_wide-1)/3;
br_wide += (br_wide-1)/3;
......@@ -393,6 +399,15 @@ int main(int argc, char *argv[])
ovl->path.trace = (void *) trace;
Read_Trace(input,ovl,tbytes);
if (ovl->aread >= db1->nreads)
{ fprintf(stderr,"%s: A-read is out-of-range of DB %s\n",Prog_Name,argv[1]);
exit (1);
}
if (ovl->bread >= db2->nreads)
{ fprintf(stderr,"%s: B-read is out-of-range of DB %s\n",Prog_Name,argv[1+ISTWO]);
exit (1);
}
// Determine if it should be displayed
ar = ovl->aread+1;
......@@ -514,15 +529,27 @@ int main(int argc, char *argv[])
else
printf("]");
if (!CARTOON)
printf(" ~ %5.2f%% ",(200.*ovl->path.diffs) /
((ovl->path.aepos - ovl->path.abpos) + (ovl->path.bepos - ovl->path.bbpos)) );
printf(" (");
if (FLIP)
{ Print_Number(aln->alen,ai_wide,stdout);
printf(" x ");
Print_Number(aln->blen,bi_wide,stdout);
}
else
{ Print_Number(aln->blen,bi_wide,stdout);
printf(" x ");
Print_Number(aln->alen,ai_wide,stdout);
}
printf(" bps,");
if (CARTOON)
{ printf(" (");
Print_Number(tps,tp_wide,stdout);
{ Print_Number(tps,tp_wide,stdout);
printf(" trace pts)\n\n");
}
else
{ printf(" ~ %4.1f%% (",(200.*ovl->path.diffs) /
((ovl->path.aepos - ovl->path.abpos) + (ovl->path.bepos - ovl->path.bbpos)) );
Print_Number((int64) ovl->path.diffs,mn_wide,stdout);
{ Print_Number((int64) ovl->path.diffs,mn_wide,stdout);
printf(" diffs, ");
Print_Number(tps,tp_wide,stdout);
printf(" trace pts)\n");
......@@ -581,6 +608,9 @@ int main(int argc, char *argv[])
else
aln->bseq = bseq - bmin;
if (tspace == 0)
Compute_Trace_IRR(aln,work,GREEDIEST);
else
Compute_Trace_PTS(aln,work,tspace,GREEDIEST);
if (FLIP)
......
......@@ -25,24 +25,6 @@ static char *Usage = "[-va] <align:las> ...";
static char *IBLOCK;
static void Fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream) {
size_t rc = fwrite(ptr, size, nmemb, stream);
if (rc != nmemb) {
EPRINTF(EPLACE," Error writing %zu elements (of size %zu)\n", nmemb, size);
exit(1);
}
}
static void Fclose(FILE *stream) {
// An error in fclose() could be caused by an earlier failure in fwrite().
// 'man fclose' for details.
int rc = fclose(stream);
if (rc != 0) {
EPRINTF(EPLACE," Error closing stream.\n");
exit(1);
}
}
static int SORT_OVL(const void *x, const void *y)
{ int64 l = *((int64 *) x);
int64 r = *((int64 *) y);
......@@ -67,7 +49,7 @@ static int SORT_OVL(const void *x, const void *y)
return (bl-br);
cl = COMP(ol->flags);
cr = COMP(ol->flags);
cr = COMP(or->flags);
if (cl != cr)
return (cl-cr);
......@@ -178,11 +160,11 @@ int main(int argc, char *argv[])
size = info.st_size;
if (fread(&novl,sizeof(int64),1,input) != 1)
SYSTEM_ERROR
SYSTEM_READ_ERROR
if (fread(&tspace,sizeof(int),1,input) != 1)
SYSTEM_ERROR
SYSTEM_READ_ERROR
if (tspace <= TRACE_XOVR)
if (tspace <= TRACE_XOVR && tspace != 0)
tbytes = sizeof(uint8);
else
tbytes = sizeof(uint16);
......@@ -200,8 +182,10 @@ int main(int argc, char *argv[])
if (foutput == NULL)
exit (1);
Fwrite(&novl,sizeof(int64),1,foutput);
Fwrite(&tspace,sizeof(int),1,foutput);
if (fwrite(&novl,sizeof(int64),1,foutput) != 1)
SYSTEM_READ_ERROR
if (fwrite(&tspace,sizeof(int),1,foutput) != 1)
SYSTEM_READ_ERROR
free(pwd);
free(root);
......@@ -219,7 +203,7 @@ int main(int argc, char *argv[])
size -= (sizeof(int64) + sizeof(int));
if (size > 0)
{ if (fread(iblock,size,1,input) != 1)
SYSTEM_ERROR
SYSTEM_READ_ERROR
}
fclose(input);
iend = iblock + (size - ptrsize);
......@@ -276,23 +260,26 @@ int main(int argc, char *argv[])
{ tsize = w->path.tlen*tbytes;
span = ovlsize + tsize;
if (fptr + span > ftop)
{ Fwrite(fblock,1,fptr-fblock,foutput);
{ if (fwrite(fblock,1,fptr-fblock,foutput) != (size_t) (fptr-fblock))
SYSTEM_READ_ERROR
fptr = fblock;
}
memcpy(fptr,((char *) w)+ptrsize,ovlsize);
memmove(fptr,((char *) w)+ptrsize,ovlsize);
fptr += ovlsize;
memcpy(fptr,(char *) (w+1),tsize);
memmove(fptr,(char *) (w+1),tsize);
fptr += tsize;
w = (Overlap *) (wo += span);
}
while (wo < iend && CHAIN_NEXT(w->flags));
}
if (fptr > fblock)
Fwrite(fblock,1,fptr-fblock,foutput);
{ if (fwrite(fblock,1,fptr-fblock,foutput) != (size_t) (fptr-fblock))
SYSTEM_READ_ERROR
}
}
free(perm);
Fclose(foutput);
fclose(foutput);
}
if (iblock != NULL)
......
......@@ -81,19 +81,19 @@ int main(int argc, char *argv[])
free(root);
if (fscanf(dbvis,DB_NFILE,&nfiles) != 1)
SYSTEM_ERROR
SYSTEM_READ_ERROR
while (nfiles-- > 0)
if (fgets(buffer,2*MAX_NAME+100,dbvis) == NULL)
SYSTEM_ERROR
SYSTEM_READ_ERROR
parts = 0;
if (fscanf(dbvis,DB_NBLOCK,&parts) != 1)
{ fprintf(stderr,"%s: DB %s has not been partitioned\n",Prog_Name,argv[2]);
exit (1);
}
if (fscanf(dbvis,DB_PARAMS,&size,&cutoff,&all) != 3)
SYSTEM_ERROR
SYSTEM_READ_ERROR
if (fscanf(dbvis,DB_BDATA,&olast,&blast) != 2)
SYSTEM_ERROR
SYSTEM_READ_ERROR
}
else
{ dbvis = NULL;
......@@ -128,10 +128,10 @@ int main(int argc, char *argv[])
*root2++ = '\0';
if (fread(&novl,sizeof(int64),1,stdin) != 1)
SYSTEM_ERROR
SYSTEM_READ_ERROR
if (fread(&tspace,sizeof(int),1,stdin) != 1)
SYSTEM_ERROR
if (tspace <= TRACE_XOVR)
SYSTEM_READ_ERROR
if (tspace <= TRACE_XOVR && tspace != 0)
tbytes = sizeof(uint8);
else
tbytes = sizeof(uint16);
......@@ -139,9 +139,9 @@ int main(int argc, char *argv[])
if (VERBOSE)
fprintf(stderr," Distributing %lld la\'s\n",novl);
{ int i, j;
{ int i;
Overlap *w;
int low, hgh, last;
int64 j, low, hgh, last;
int64 tsize, povl;
char *iptr, *itop;
char *optr, *otop;
......@@ -158,7 +158,7 @@ int main(int argc, char *argv[])
low = hgh;
if (dbvis != NULL)
{ if (fscanf(dbvis,DB_BDATA,&olast,&blast) != 2)
SYSTEM_ERROR
SYSTEM_READ_ERROR
last = blast-1;
hgh = 0;
}
......@@ -178,7 +178,7 @@ int main(int argc, char *argv[])
{ if (iptr + ovlsize > itop)
{ int64 remains = itop-iptr;
if (remains > 0)
memcpy(iblock,iptr,remains);
memmove(iblock,iptr,remains);
iptr = iblock;
itop = iblock + remains;
itop += fread(itop,1,bsize-remains,stdin);
......@@ -201,19 +201,19 @@ int main(int argc, char *argv[])
optr = oblock;
}
memcpy(optr,iptr,ovlsize);
memmove(optr,iptr,ovlsize);
optr += ovlsize;
iptr += ovlsize;
if (iptr + tsize > itop)
{ int64 remains = itop-iptr;
if (remains > 0)
memcpy(iblock,iptr,remains);
memmove(iblock,iptr,remains);
iptr = iblock;
itop = iblock + remains;
itop += fread(itop,1,bsize-remains,stdin);
}
memcpy(optr,iptr,tsize);
memmove(optr,iptr,tsize);
optr += tsize;
iptr += tsize;
}
......
......@@ -50,4 +50,4 @@ install:
package:
make clean
tar -zcf daligner.tar.gz README Makefile *.h *.c
tar -zcf daligner.tar.gz README.md Makefile *.h *.c