Commit f4ac84db authored by Andreas Tille's avatar Andreas Tille
Browse files

New upstream version 1.0+git20190721.efb48c3

parent b7b1dbd1
Loading
Loading
Loading
Loading
+1322 −796

File changed.

Preview size limit exceeded, changes collapsed.

+175 −80
Original line number Diff line number Diff line
@@ -150,7 +150,7 @@ int Count_Args(char *arg);

    //  Output

#define FWRITE(v,s,n,file)			\
#define FFWRITE(v,s,n,file)			\
  { if (fwrite(v,s,n,file) != (size_t) n)	\
      SYSTEM_WRITE_ERROR			\
  }
@@ -179,7 +179,7 @@ int Count_Args(char *arg);

    //  Input

#define FREAD(v,s,n,file)								\
#define FFREAD(v,s,n,file)								\
  { if (fread(v,s,n,file) != (size_t) n)						\
      { if (ferror(file))								\
          SYSTEM_READ_ERROR								\
@@ -261,6 +261,7 @@ void Print_Read(char *s, int width);
void Lower_Read(char *s);     //  Convert read from numbers to lowercase letters (0-3 to acgt)
void Upper_Read(char *s);     //  Convert read from numbers to uppercase letters (0-3 to ACGT)
void Number_Read(char *s);    //  Convert read from letters to numbers
void Change_Read(char *s);    //  Convert read from one case to the other

void Letter_Arrow(char *s);   //  Convert arrow pw's from numbers to uppercase letters (0-3 to 1234)
void Number_Arrow(char *s);   //  Convert arrow pw string from letters to numbers
@@ -273,8 +274,8 @@ void Number_Arrow(char *s); // Convert arrow pw string from letters to number
 ********************************************************************************************/

#define DB_QV   0x03ff   //  Mask for 3-digit quality value
#define DB_CSS  0x0400   //  This is the second or later of a group of reads from a given insert
#define DB_BEST 0x0800   //  This is the longest read of a given insert (may be the only 1)
#define DB_CSS  0x0400   //  This is the second or later of a group of subreads from a given insert
#define DB_BEST 0x0800   //  This is the "best" subread of a given insert (may be the only 1)

#define DB_ARROW 0x2     //  DB is an arrow DB
#define DB_ALL   0x1     //  all wells are in the trimmed DB
@@ -299,13 +300,19 @@ typedef struct
//                                    contains the variable length data
//    data != NULL && size == 8: anno is an array of nreads+1 int64's and data[anno[i]..anno[i+1])
//                                    contains the variable length data
//    if open is set then the data is not loaded if present, rather data is an open file pointer
//        set for reading.

typedef struct _track
  { struct _track *next;   //  Link to next track
    char          *name;   //  Symbolic name of track
    int            size;   //  Size in bytes of anno records
    int            nreads; //  Number of reads in track
    void          *anno;   //  over [0,nreads]: read i annotation: int, int64, or 'size' records 
    void          *data;  //     data[anno[i] .. anno[i+1]-1] is data if data != NULL
    int           *alen;   //  length of track data for read i (if data != NULL)
    void          *data;   //  data[anno[i] .. anno[i]+alen[i[) is data for read i (if data != NULL)
    int            loaded; //  Is track data loaded in memory?
    int64          dmax;   //  Largest read data segment in bytes
  } DAZZ_TRACK;

//  The tailing part of a .anno track file can contain meta-information produced by the
@@ -345,6 +352,19 @@ typedef struct
    FILE          *quiva;   //  the open file pointer to the .qvs file
  } DAZZ_QV;

//  The information for accessing Arrow streams is in a DAZZ_ARW record that is a "pseudo-track"
//    named ".@arw" and is always the first track record in the list (if present).
//    Since normal track names cannot begin with a . (this is enforced), this pseudo-track
//    is never confused with a normal track.

typedef struct
  { struct _track *next;
    char          *name;
    int64         *aoff;    //  offset in file or memory of arrow vector for read i
    void          *arrow;   //  FILE * to the .arw file if not loaded, memory block otherwise 
    int            loaded;  //  Are arrow vectors loaded in memory?
  } DAZZ_ARROW;

//  The DB record holds all information about the current state of an active DB including an
//    array of DAZZ_READS, one per read, and a linked list of DAZZ_TRACKs the first of which
//    is always a DAZZ_QV pseudo-track (if the QVs have been loaded).
@@ -393,7 +413,7 @@ typedef struct
#define DB_NFILE  "files = %9d\n"   //  number of files
#define DB_FDATA  "  %9d %s %s\n"   //  last read index + 1, fasta prolog, file name
#define DB_NBLOCK "blocks = %9d\n"  //  number of blocks
#define DB_PARAMS "size = %10lld cutoff = %9d all = %1d\n"  //  block size, len cutoff, all in well
#define DB_PARAMS "size = %11lld cutoff = %9d all = %1d\n"  //  block size, len cutoff, all in well
#define DB_BDATA  " %9d %9d\n"      //  First read index (untrimmed), first read index (trimmed)


@@ -430,26 +450,104 @@ int Open_DB(char *path, DAZZ_DB *db);

void Trim_DB(DAZZ_DB *db);

  // Return the size in bytes of the given DB

int64 sizeof_DB(DAZZ_DB *db);

  // For the DB or DAM "path" = "prefix/root.[db|dam]", find all the files for that DB, i.e. all
  //   those of the form "prefix/[.]root.part" and call actor with the complete path to each file
  //   pointed at by path, and the suffix of the path by extension.  The . proceeds the root
  //   name if the defined constant HIDE_FILES is set.  Always the first call is with the
  //   path "prefix/root.[db|dam]" and extension "db" or "dam".  There will always be calls for
  //   "prefix/[.]root.idx" and "prefix/[.]root.bps".  All other calls are for *tracks* and
  //   so this routine gives one a way to know all the tracks associated with a given DB.
  //   -1 is returned if the path could not be found, and 1 is returned if an error (reported
  //   to EPLACE) occured and INTERACTIVE is defined.  Otherwise a 0 is returned.

int List_DB_Files(char *path, void actor(char *path, char *extension));

  // Shut down an open 'db' by freeing all associated space, including tracks and QV structures,
  //   and any open file pointers.  The record pointed at by db however remains (the user
  //   supplied it and so should free it).

void Close_DB(DAZZ_DB *db);

  // Return the size in bytes of the given DB

int64 sizeof_DB(DAZZ_DB *db);
/*******************************************************************************************
 *
 *  READ ROUTINES
 *
 ********************************************************************************************/

  // If QV pseudo track is not already in db's track list, then load it and set it up.
  //   The database must not have been trimmed yet.  -1 is returned if a .qvs file is not
  //   present, and 1 is returned if an error (reported to EPLACE) occured and INTERACTIVE
  //   is defined.  Otherwise a 0 is returned.
  // Allocate and return a buffer big enough for the largest read in 'db'.
  // **NB** free(x-1) if x is the value returned as *prefix* and suffix '\0'(4)-byte
  // are needed by the alignment algorithms.  If cannot allocate memory then return NULL
  // if INTERACTIVE is defined, or print error to stderr and exit otherwise.

int Load_QVs(DAZZ_DB *db);
char *New_Read_Buffer(DAZZ_DB *db);

  // Remove the QV pseudo track, all space associated with it, and close the .qvs file.
  // Load into 'read' the i'th read in 'db'.  As a lower case ascii string if ascii is 1, an
  //   upper case ascii string if ascii is 2, and a numeric string over 0(A), 1(C), 2(G), and 3(T)
  //   otherwise.  A '\0' (or 4) is prepended and appended to the string so it has a delimeter
  //   for traversals in either direction.  A non-zero value is returned if an error occured
  //   and INTERACTIVE is defined.

void Close_QVs(DAZZ_DB *db);
int  Load_Read(DAZZ_DB *db, int i, char *read, int ascii);

  // Load into 'read' the subread [beg,end] of the i'th read in 'db' and return a pointer to the
  //   the start of the subinterval (not necessarily = to read !!! ).  As a lower case ascii
  //   string if ascii is 1, an upper case ascii string if ascii is 2, and a numeric string
  //   over 0(A), 1(C), 2(G), and 3(T) otherwise.  A '\0' (or 4) is prepended and appended to
  //   the string holding the substring so it has a delimeter for traversals in either direction.
  //   A NULL pointer is returned if an error occured and INTERACTIVE is defined.

char *Load_Subread(DAZZ_DB *db, int i, int beg, int end, char *read, int ascii);

  // Allocate a block big enough for all the uncompressed read sequences and read and uncompress
  //   the reads into it, reset the 'boff' in each read record to be its in-memory offset,
  //   and set the bases pointer to point at the block after closing the bases file.  Return
  //   with a zero, except when an error occurs and INTERACTIVE is defined in which
  //   case return wtih 1.

int Load_All_Reads(DAZZ_DB *db, int ascii);


/*******************************************************************************************
 *
 *  ARROW ROUTINES
 *
 ********************************************************************************************/

  // If the Arrow pseudo track is not already in db's track list, then load it and set it up.
  //   The database reads must not have been loaded with Load_All_Reads yet.
  //   -1 is returned if a .arw file is not present, and 1 is returned if an error (reported
  //   to EPLACE) occured and INTERACTIVE is defined.  Otherwise a 0 is returned.

int Open_Arrow(DAZZ_DB *db);

  // Exactly the same as Load_Read, save the arrow information is loaded, not the DNA sequence,
  //   and there is only a choice between numeric (0) or ascii (1);

int  Load_Arrow(DAZZ_DB *db, int i, char *read, int ascii);

  // Allocate a block big enough for all the uncompressed Arrow vectors, read them into it,
  //   reset the 'off' in each arrow record to be its in-memory offset, and set the
  //   arrow pointer to point at the block after closing the arrow file.  If ascii is
  //   non-zero then the arrows are converted to 0123 ascii, otherwise the arrows are left
  //   as numeric strings over [0-3].
  
int Load_All_Arrows(DAZZ_DB *db, int ascii);

  // Remove the Arrow pseudo track, all space associated with it, and close the .arw file.

void Close_Arrow(DAZZ_DB *);


/*******************************************************************************************
 *
 *  TRACK ROUTINES
 *
 ********************************************************************************************/

  // Look up the file and header in the file of the indicated track.  Return:
  //     1: Track is for trimmed DB
@@ -466,30 +564,50 @@ void Close_QVs(DAZZ_DB *db);

int Check_Track(DAZZ_DB *db, char *track, int *kind);

  // If track is not already in the db's track list, then allocate all the storage for it,
  //   read it in from the appropriate file, add it to the track list, and return a pointer
  // If track is not already in the db's track list, then allocate all the storage for the anno
  //   index, read it in from the appropriate file, add it to the track list, and return a pointer
  //   to the newly created DAZZ_TRACK record.  If the track does not exist or cannot be
  //   opened for some reason, then NULL is returned if INTERACTIVE is defined.  Otherwise
  //   the routine prints an error message to stderr and exits if an error occurs, and returns
  //   with NULL only if the track does not exist.

DAZZ_TRACK *Load_Track(DAZZ_DB *db, char *track);
DAZZ_TRACK *Open_Track(DAZZ_DB *db, char *track);

  // Assumming file pointer for afile is correctly positioned at the start of a extra item,
  //   and aname is the name of the .anno file, decode the value present and places it in
  // Allocate a data buffer large enough to hold the longest read data block that will occur
  //   in the track.  If cannot allocate memory then return NULL if INTERACTIVE is defined,
  //   or print error to stderr and exit otherwise.

void *New_Track_Buffer(DAZZ_TRACK *track);

  // Load into 'data' the read data block for read i's "track" data.  Return the length of
  //   the data in bytes, unless an error occurs and INTERACTIVE is defined in which case
  //   return wtih -1.

int Load_Track_Data(DAZZ_TRACK *track, int i, void *data);

  // Allocate a block big enough for all the track data and read the data into it,
  //   reset the 'off' in each anno pointer to be its in-memory offset, and set the
  //   data pointer to point at the block after closing the data file.  Return with a
  //   zero, except when an error occurs and INTERACTIVE is defined in which
  //   case return wtih 1.

int Load_All_Track_Data(DAZZ_TRACK *track);

  // Assumming file pointer for afile is correctly positioned at the start of an extra item,
  //   and aname is the name of the .anno file, decode the value present and place it in
  //   extra if extra->nelem == 0, otherwise reduce the value just read into extra according
  //   according the to the directive given by 'accum'.  Leave the read poinrt at the next
  //   according to the directive given by 'accum'.  Leave the read pointer at the next
  //   extra or end-of-file.
  //   Returns:
  //      1 if at the end of file,
  //      0 if item was read and folded correctly,
  //     -1 if there was a system IO or allocation error (if interactive), and
  //     -2 if the new value could not be reduced into the currenct value of extra (interactive)
  //     -2 if the new value could not be reduced into the current value of extra (interactive)

int Read_Extra(FILE *afile, char *aname, DAZZ_EXTRA *extra);

  //  Write extra record to end of file afile and advance write pointer
//  If interactive, then return non-zero on error, if bash, then print
  //  If interactive, then return non-zero on error, if batch, then print
  //  and halt if an error

int Write_Extra(FILE *afile, DAZZ_EXTRA *extra);
@@ -497,36 +615,21 @@ int Write_Extra(FILE *afile, DAZZ_EXTRA *extra);
  // If track is on the db's track list, then it is removed and all storage associated with it
  //   is freed.

void Close_Track(DAZZ_DB *db, char *track);

  // Allocate and return a buffer big enough for the largest read in 'db'.
  // **NB** free(x-1) if x is the value returned as *prefix* and suffix '\0'(4)-byte
  // are needed by the alignment algorithms.  If cannot allocate memory then return NULL
  // if INTERACTIVE is defined, or print error to stderr and exit otherwise.

char *New_Read_Buffer(DAZZ_DB *db);

  // Load into 'read' the i'th read in 'db'.  As a lower case ascii string if ascii is 1, an
  //   upper case ascii string if ascii is 2, and a numeric string over 0(A), 1(C), 2(G), and 3(T)
  //   otherwise.  A '\0' (or 4) is prepended and appended to the string so it has a delimeter
  //   for traversals in either direction.  A non-zero value is returned if an error occured
  //   and INTERACTIVE is defined.
void Close_Track(DAZZ_DB *db, DAZZ_TRACK *track);

int  Load_Read(DAZZ_DB *db, int i, char *read, int ascii);

  // Exactly the same as Load_Read, save the arrow information is loaded, not the DNA sequence,
  //   and there is only a choice between numeric (0) or ascii (1);

int  Load_Arrow(DAZZ_DB *db, int i, char *read, int ascii);
/*******************************************************************************************
 *
 *  QV ROUTINES
 *
 ********************************************************************************************/

  // Load into 'read' the subread [beg,end] of the i'th read in 'db' and return a pointer to the
  //   the start of the subinterval (not necessarily = to read !!! ).  As a lower case ascii
  //   string if ascii is 1, an upper case ascii string if ascii is 2, and a numeric string
  //   over 0(A), 1(C), 2(G), and 3(T) otherwise.  A '\0' (or 4) is prepended and appended to
  //   the string holding the substring so it has a delimeter for traversals in either direction.
  //   A NULL pointer is returned if an error occured and INTERACTIVE is defined.
  // If QV pseudo track is not already in db's track list, then load it and set it up.
  //   The database must not have been trimmed yet.  -1 is returned if a .qvs file is not
  //   present, and 1 is returned if an error (reported to EPLACE) occured and INTERACTIVE
  //   is defined.  Otherwise a 0 is returned.

char *Load_Subread(DAZZ_DB *db, int i, int beg, int end, char *read, int ascii);
int Open_QVs(DAZZ_DB *db);

  // Allocate a set of 5 vectors large enough to hold the longest QV stream that will occur
  //   in the database.  If cannot allocate memory then return NULL if INTERACTIVE is defined,
@@ -546,46 +649,38 @@ char **New_QV_Buffer(DAZZ_DB *db);

int   Load_QVentry(DAZZ_DB *db, int i, char **entry, int ascii);

  // Allocate a block big enough for all the uncompressed sequences, read them into it,
  //   reset the 'off' in each read record to be its in-memory offset, and set the
  //   bases pointer to point at the block after closing the bases file.  If ascii is
  //   1 then the reads are converted to lowercase ascii, if 2 then uppercase ascii, and
  //   otherwise the reads are left as numeric strings over 0(A), 1(C), 2(G), and 3(T).
  //   Return with a zero, except when an error occurs and INTERACTIVE is defined in which
  //   case return wtih 1.
  // Remove the QV pseudo track, all space associated with it, and close the .qvs file.

int Read_All_Sequences(DAZZ_DB *db, int ascii);
void Close_QVs(DAZZ_DB *db);

  // For the DB or DAM "path" = "prefix/root.[db|dam]", find all the files for that DB, i.e. all
  //   those of the form "prefix/[.]root.part" and call actor with the complete path to each file
  //   pointed at by path, and the suffix of the path by extension.  The . proceeds the root
  //   name if the defined constant HIDE_FILES is set.  Always the first call is with the
  //   path "prefix/root.[db|dam]" and extension "db" or "dam".  There will always be calls for
  //   "prefix/[.]root.idx" and "prefix/[.]root.bps".  All other calls are for *tracks* and
  //   so this routine gives one a way to know all the tracks associated with a given DB.
  //   -1 is returned if the path could not be found, and 1 is returned if an error (reported
  //   to EPLACE) occured and INTERACTIVE is defined.  Otherwise a 0 is returned.

int List_DB_Files(char *path, void actor(char *path, char *extension));
/*******************************************************************************************
 *
 *  @-SIGN EXPANSION ROUTINES
 *
 ********************************************************************************************/

  //   Take a command line argument and interpret the '@' block number ranges.
  //   Parse_Block_Arg produces a Block_Looper iterator object that can then
  //   be invoked multiple times to iterate through all the files implied by
  //   Parse_Block_[LAS,DB]_Arg produces a Block_Looper iterator object that can then
  //   be invoked multiple times to iterate through all the file names implied by
  //   the @ pattern/range.  Next_Block_Slice returns a string encoing the next
  //   slice files represented by an @-notation, and advances the iterator by
  //   that many files.

typedef void Block_Looper;

Block_Looper *Parse_Block_Arg(char *arg);
Block_Looper *Parse_Block_LAS_Arg(char *arg);
Block_Looper *Parse_Block_DB_Arg(char *arg);

int   Next_Block_Exists(Block_Looper *e_parse);
FILE *Next_Block_Arg(Block_Looper *e_parse);
void  Reset_Block_Arg(Block_Looper *e_parse);   //  Reset iterator to first file
int   Advance_Block_Arg(Block_Looper *e_parse); //  Advance iterator to next file, 0 if none
void  Free_Block_Arg(Block_Looper *e_parse);    //  Free the iterator

char *Next_Block_Slice(Block_Looper *e_parse,int slice);

void  Reset_Block_Arg(Block_Looper *e_parse);  //  Reset iterator to first file
char *Block_Arg_Path(Block_Looper *e_parse);   //  Path of current file
char *Block_Arg_Root(Block_Looper *e_parse);   //  Root name of current file
void  Free_Block_Arg(Block_Looper *e_parse);   //  Free the iterator
char *Block_Arg_Path(Block_Looper *e_parse);    //  Path of current file, must free
char *Block_Arg_Root(Block_Looper *e_parse);    //  Root name of current file, must free

#endif // _DAZZ_DB
+25 −32
Original line number Diff line number Diff line
@@ -24,17 +24,17 @@
#undef  SLURM  //  define if want a directly executable SLURM script

static char *Usage[] =
  { "[-vbad] [-t<int>] [-w<int(6)>] [-l<int(1000)>] [-s<int(100)] [-M<int>]",
  { "[-vad] [-l<int(1500)>] [-s<int(100)] [-t<int>] [-M<int>]",
    "       [-P<dir(/tmp)>] [-B<int(4)>] [-T<int(4)>] [-f<name>]",
    "      ( [-k<int(14)>] [-h<int(35)>] [-e<double(.70)>] [-H<int>]",
    "        [-k<int(20)>] [-h<int(50)>] [-e<double(.85)>] <ref:db|dam> )",
    "     ( [-k<int(16)>] [-h<int(50)>] [-w<int(6)>] [-e<double(.75)>] [-H<int>]",
    "       [-k<int(20)>] [-h<int(50)>] [-w<int(6)>] [-e<double(.85)>] <ref:db|dam> )",
    "       [-m<track>]+ <reads:db|dam> [<first:int>[-<last:int>]]"
  };

  //  Command Options

static int    BUNIT;
static int    VON, BON, CON, DON;
static int    VON, CON, DON;
static int    WINT, TINT, HGAP, HINT, KINT, SINT, LINT, MINT;
static int    NTHREADS;
static double EREL;
@@ -247,15 +247,13 @@ void daligner_script(int argc, char *argv[])
            fprintf(out,"daligner");
            if (VON)
              fprintf(out," -v");
            if (BON)
              fprintf(out," -b");
            if (CON)
              fprintf(out," -a");
            if (KINT != 14)
            if (KINT != 16)
              fprintf(out," -k%d",KINT);
            if (WINT != 6)
              fprintf(out," -w%d",WINT);
            if (HINT != 35)
            if (HINT != 50)
              fprintf(out," -h%d",HINT);
            if (TINT > 0)
              fprintf(out," -t%d",TINT);
@@ -263,7 +261,7 @@ void daligner_script(int argc, char *argv[])
              fprintf(out," -H%d",HGAP);
            if (EREL > 0.)
              fprintf(out," -e%g",EREL);
            if (LINT != 1000)
            if (LINT != 1500)
              fprintf(out," -l%d",LINT);
            if (SINT != 100)
              fprintf(out," -s%d",SINT);
@@ -286,12 +284,12 @@ void daligner_script(int argc, char *argv[])
              else
                fprintf(out," %s",root);
            hgh = (i*j)/bits + 1;
            for (k = low; k < hgh; k++)

            if (useblock)
              if (usepath)
                  fprintf(out," %s/%s.%d",pwd,root,k);
                fprintf(out," %s/%s.@%d-%d",pwd,root,low,hgh-1);
              else
                  fprintf(out," %s.%d",root,k);
                fprintf(out," %s.@%d-%d",root,low,hgh-1);
            else
              if (usepath)
                fprintf(out," %s/%s",pwd,root);
@@ -495,8 +493,8 @@ void daligner_script(int argc, char *argv[])

        for (i = 1; i <= lblock; i++)
          { if (DON)
              fprintf(out,"cd work%d; ",j);
            printf("rm %s.%d.%s.*.las",root,i,root);
              fprintf(out,"cd work%d; ",i);
            fprintf(out,"rm %s.%d.%s.*.las",root,i,root);
            if (DON)
              fprintf(out,"; cd ..");
            fprintf(out,"\n");
@@ -766,8 +764,6 @@ void mapper_script(int argc, char *argv[])
            fprintf(out,"daligner -A");
            if (VON)
              fprintf(out," -v");
            if (BON)
              fprintf(out," -b");
            if (CON)
              fprintf(out," -a");
            fprintf(out," -k%d",KINT);
@@ -989,7 +985,7 @@ int main(int argc, char *argv[])
  BUNIT = 4;
  TINT  = 0;
  WINT  = 6;
  LINT  = 1000;
  LINT  = 1500;
  SINT  = 100;
  MINT  = -1;
  PDIR  = NULL;
@@ -1008,7 +1004,7 @@ int main(int argc, char *argv[])
    if (argv[i][0] == '-')
      switch (argv[i][1])
      { default:
          ARG_FLAGS("vbadAI");
          ARG_FLAGS("vadAI");
          break;
        case 'e':
          ARG_REAL(EREL)
@@ -1072,7 +1068,6 @@ int main(int argc, char *argv[])
  argc = j;

  VON = flags['v'];
  BON = flags['b'];
  CON = flags['a'];
  DON = flags['d'];

@@ -1099,14 +1094,12 @@ int main(int argc, char *argv[])
      fprintf(stderr,"      -T: Use -T threads.\n");
      fprintf(stderr,"      -P: Do first level sort and merge in directory -P.\n");
      fprintf(stderr,"      -m: Soft mask the blocks with the specified mask.\n");
      fprintf(stderr,"      -b: For AT/GC biased data, compensate k-mer counts (deprecated).\n");
      fprintf(stderr,"\n");
      fprintf(stderr,"     Script control.\n");
      fprintf(stderr,"      -v: Run all commands in script in verbose mode.\n");
      fprintf(stderr,"      -a: Instruct LAsort & LAmerge to sort only on (a,ab).\n");
      fprintf(stderr,"      -d: Put .las files for each target block in a sub-directory\n");
      fprintf(stderr,"      -B: # of block compares per daligner job\n");
      fprintf(stderr,"      -D: # of .las's to merge per LAmerge job\n");
      fprintf(stderr,"      -f: Place script bundles in separate files with prefix <name>\n");
      exit (1);
    }
@@ -1137,9 +1130,9 @@ int main(int argc, char *argv[])
    }
  else
    { if (KINT <= 0)
        KINT = 14;
        KINT = 16;
      if (HINT <= 0)
        HINT = 35;
        HINT = 50;
    }

  for (j = 1; 2*j <= NTHREADS; j *= 2)

LAa2b.c

0 → 100644
+103 −0
Original line number Diff line number Diff line
#include <stdlib.h>
#include <stdio.h>

#include "DB.h"
#include "align.h"

int main(int argc, char *argv[])
{ char   code, which;
  int64  total;
  int    aread, bread;
  char   orient, chain;
  int    alen, blen;
  int    ab, ae, bb, be;
  int    diffs;
  int    len;
  int    tspace, small;
  uint8 *tbuffer = NULL;
  uint16 *sbuffer;

  (void) argv;

  //  Process arguments

  if (argc > 1)
    { fprintf(stderr,"Usage: LAa2b <(ascii) >(binary)\n");
      exit (1);
    }

  while (scanf(" %c",&code) == 1)       //  Header lines
    if (code == '@' || code == '+' || code == '%')
      { scanf(" %c %lld",&which,&total);
        fwrite(&code,sizeof(char),1,stdout);
        fwrite(&which,sizeof(char),1,stdout);
        fwrite(&total,sizeof(int64),1,stdout);
        if (code == '@')
          { tbuffer = (uint8 *) malloc(2*total*sizeof(uint16));
            sbuffer = (uint16 *) tbuffer;
          }
      }
    else
      { ungetc(code,stdin);
        break;
      }
  if (tbuffer != NULL)
    { if (code != 'X')
        { fprintf(stderr,"LAa2b: .las dump has traces but no X-line\n");
          exit (1);
        }
      scanf(" X %d",&tspace);
      small = (tspace <= TRACE_XOVR && tspace != 0);
      fwrite(&code,sizeof(char),1,stdout);
      fwrite(&tspace,sizeof(int),1,stdout);
    }

  while (scanf(" %c",&code) == 1)       //  For each data line do
    { fwrite(&code,sizeof(char),1,stdout);
      switch (code)
      { case 'P':                         //  Alignment pair
          scanf(" %d %d %c %c",&aread,&bread,&orient,&chain);
          fwrite(&aread,sizeof(int),1,stdout);
          fwrite(&bread,sizeof(int),1,stdout);
          fwrite(&orient,sizeof(char),1,stdout);
          fwrite(&chain,sizeof(char),1,stdout);
          break;
        case 'L':                         //  Read lengths
          scanf(" %d %d",&alen,&blen);
          fwrite(&len,sizeof(int),1,stdout);
          fwrite(&blen,sizeof(int),1,stdout);
          break;
        case 'C':                         //  Coordinate intervals
          scanf(" %d %d %d %d",&ab,&ae,&bb,&be);
          fwrite(&ab,sizeof(int),1,stdout);
          fwrite(&ae,sizeof(int),1,stdout);
          fwrite(&bb,sizeof(int),1,stdout);
          fwrite(&be,sizeof(int),1,stdout);
          break;
        case 'D':                         //  Differences
          scanf(" %d",&diffs);
          fwrite(&diffs,sizeof(int),1,stdout);
          break;
        case 'T':                         //  Mask
          if (tbuffer == NULL)
            { fprintf(stderr,"LAa2b: .las dump has traces but no @ T-line\n");
              exit (1);
            }
          scanf(" %d",&len);
          fwrite(&len,sizeof(int),1,stdout);
          len *= 2;
          if (small)
            { for (int i = 0; i < len; i += 2)
                scanf(" %hhd %hhd",tbuffer+i,tbuffer+(i+1));
              fwrite(tbuffer,sizeof(uint8),len,stdout);
            }
          else
            { for (int i = 0; i < len; i += 2)
                scanf(" %hd %hd",sbuffer+i,sbuffer+(i+1));
              fwrite(sbuffer,sizeof(uint16),len,stdout);
            }
      }
    }

  exit (0);
}

LAb2a.c

0 → 100644
+105 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading