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

New upstream version 1.0+git20180908.0bd5e07

parent eb6be9a3
Loading
Loading
Loading
Loading
+9 −7
Original line number Diff line number Diff line
@@ -131,6 +131,7 @@ int main(int argc, char *argv[])
    int         nextra;
    int64       extail;

    extra    = NULL;
    anno     = NULL;
    trackoff = 0;
    tracktot = tracksiz = 0;
@@ -144,7 +145,7 @@ int main(int argc, char *argv[])
    while (1)
      { FILE *dfile, *afile;
        char *dfile_name, *afile_name;
        int   i, size, esize, tracklen;
        int   i, apos, size, esize, tracklen;

        afile_name = Strdup(Numbered_Suffix(prefix,nfiles+1,Catenate(".",argv[2],".","anno")),
                            "Allocating .anno file name");
@@ -256,10 +257,11 @@ int main(int argc, char *argv[])
          }

        FSEEKO(afile,0,SEEK_END)
        FTELLO(apos,afile)
        if (dfile != NULL)
          extail = FTELLO(afile) - (esize*(tracklen+1) + 2*sizeof(int)); 
          extail = apos - (esize*(tracklen+1) + 2*sizeof(int)); 
        else
          extail = FTELLO(afile) - (esize*tracklen + 2*sizeof(int)); 
          extail = apos - (esize*tracklen + 2*sizeof(int)); 
        FSEEKO(afile,-extail,SEEK_END)

        if (extail >= 20)
@@ -339,16 +341,16 @@ int main(int argc, char *argv[])
      }
  }

  FCLOSE(aout);
  if (dout != NULL)
    FCLOSE(dout);

  if (nfiles != nblocks)
    { fprintf(stderr,"%s: Did not catenate all tracks of DB (nfiles %d != nblocks %d)\n",
	             Prog_Name, nfiles, nblocks);
      goto error;
    }
  
  FCLOSE(aout);
  if (dout != NULL)
    FCLOSE(dout);

  if (DELETE)
    { int   i;
      char *name;
+209 −5
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@
#include <ctype.h>
#include <unistd.h>
#include <dirent.h>
#include <limits.h>
#include <sys/stat.h>

#include "DB.h"

@@ -599,8 +601,8 @@ error:
//   for the retained reads.

void Trim_DB(DAZZ_DB *db)
{ int         i, j, r;
  int         allflag, cutoff;
{ int         i, j, r, f;
  int         allflag, cutoff, css;
  int64       totlen;
  int         maxlen, nreads;
  DAZZ_TRACK *record;
@@ -676,14 +678,23 @@ void Trim_DB(DAZZ_DB *db)
        record->anno = Realloc(record->anno,record->size*(j+1),NULL);
      }

  css    = 0;
  totlen = maxlen = 0;
  for (j = i = 0; i < nreads; i++)
    { r = reads[i].rlen;
      if ((reads[i].flags & DB_BEST) >= allflag && r >= cutoff)
    { f = reads[i].flags;
      if ((f & DB_CSS) == 0)
        css = 0;
      r = reads[i].rlen;
      if ((f & DB_BEST) >= allflag && r >= cutoff)
        { totlen += r;
          if (r > maxlen)
            maxlen = r;
          reads[j++] = reads[i];
          reads[j] = reads[i];
          if (css)
            reads[j++].flags |= DB_CSS;
          else
            reads[j++].flags &= ~DB_CSS;
          css = 1;
        }
    }
  
@@ -1989,3 +2000,196 @@ void Print_Read(char *s, int width)
      printf("\n");
    }
}


/*******************************************************************************************
 *
 *  COMMAND LINE BLOCK PARSER
 *    Take a command line argument and interpret the '@' block number ranges.
 *    Parse_Block_Arg produces an Block_Looper iterator object that can then
 *    be invoked multiple times to iterate through all the files implied by
 *    the @ pattern/range.
 *
 ********************************************************************************************/

typedef struct
  { int first, last, next;
    char *root, *pwd, *ppnt;
    char *slice;
  } _Block_Looper;

  //  Advance the iterator e_parse to the next file, open it, and return the file pointer
  //   to it.  Return NULL if at the end of the list of files.

int Next_Block_Exists(Block_Looper *e_parse)
{ _Block_Looper *parse = (_Block_Looper *) e_parse;

  char       *disp;
  struct stat sts;

  if (parse->next+1 > parse->last)
    return (0);

  if (parse->next < 0)
    disp  = parse->root;
  else
    disp = Numbered_Suffix(parse->root,parse->next+1,parse->ppnt);

  if (stat(Catenate(parse->pwd,"/",disp,".las"),&sts))
    return (0);
  else
    return (1);
}


FILE *Next_Block_Arg(Block_Looper *e_parse)
{ _Block_Looper *parse = (_Block_Looper *) e_parse;

  char *disp;
  FILE *input;

  parse->next += 1;
  if (parse->next > parse->last)
    return (NULL);

  if (parse->next < 0)
    disp  = parse->root;
  else
    disp = Numbered_Suffix(parse->root,parse->next,parse->ppnt);

  if ((input = fopen(Catenate(parse->pwd,"/",disp,".las"),"r")) == NULL)
    { if (parse->last != INT_MAX)
        { fprintf(stderr,"%s: %s.las is not present\n",Prog_Name,disp);
          exit (1);
        }
      return (NULL);
    }
  return (input);
}

  //  Reset the iterator e_parse to the first file

void Reset_Block_Arg(Block_Looper *e_parse)
{ _Block_Looper *parse = (_Block_Looper *) e_parse;

  parse->next = parse->first - 1;
}

  //  Return a pointer to the path for the current file

char *Block_Arg_Path(Block_Looper *e_parse)
{ _Block_Looper *parse = (_Block_Looper *) e_parse;

  return (parse->pwd);
}

  //  Return a pointer to the root name for the current file

char *Block_Arg_Root(Block_Looper *e_parse)
{ _Block_Looper *parse = (_Block_Looper *) e_parse;

  if (parse->next < 0)
    return (parse->root);
  else
    return (Numbered_Suffix(parse->root,parse->next,parse->ppnt));
}

  //  Free the iterator

void Free_Block_Arg(Block_Looper *e_parse)
{ _Block_Looper *parse = (_Block_Looper *) e_parse;

  free(parse->root);
  free(parse->pwd);
  free(parse->slice);
  free(parse);
}

char *Next_Block_Slice(Block_Looper *e_parse, int slice)
{ _Block_Looper *parse = (_Block_Looper *) e_parse;

  if (parse->slice == NULL)
    { int size = strlen(parse->pwd) + strlen(Block_Arg_Root(parse)) + 30;
      parse->slice =  (char *)  Malloc(size,"Block argument slice");
      if (parse->slice == NULL)
        exit (1);
    }

  if (parse->first < 0)
    sprintf(parse->slice,"%s/%s",parse->pwd,parse->root);
  else
    sprintf(parse->slice,"%s/%s%c%d-%d%s",parse->pwd,parse->root,BLOCK_SYMBOL,parse->next+1,
                                          parse->next+slice,parse->ppnt);
  parse->next += slice;
  return (parse->slice);
}

  //  Parse the command line argument and return an iterator to move through the
  //    file names, setting it up to report the first file.

Block_Looper *Parse_Block_Arg(char *arg)
{ _Block_Looper *parse;
  char *pwd, *root;
  char *ppnt, *cpnt;
  int   first, last;

  parse = (_Block_Looper *) Malloc(sizeof(_Block_Looper),"Allocating parse node");
  pwd   = PathTo(arg);
  root  = Root(arg,".las");
  if (parse == NULL || pwd == NULL || root == NULL)
    exit (1);

  ppnt = index(root,BLOCK_SYMBOL);
  if (ppnt == NULL)
    first = last = -1;
  else
    { if (index(ppnt+1,BLOCK_SYMBOL) != NULL)
        { fprintf(stderr,"%s: Two or more occurences of %c-sign in source name '%s'\n",
                         Prog_Name,BLOCK_SYMBOL,root);
          exit (1);
        }
      *ppnt++ = '\0';
      first = strtol(ppnt,&cpnt,10);
      if (cpnt == ppnt)
        { first = 1;
          last  = INT_MAX;
        }
      else
        { if (first < 0)
            { fprintf(stderr,
                      "%s: Integer following %c-sigan is less than 0 in source name '%s'\n",
                      Prog_Name,BLOCK_SYMBOL,root);
              exit (1);
            }
          if (*cpnt == '-')
            { ppnt = cpnt+1;
              last = strtol(ppnt,&cpnt,10);
              if (cpnt == ppnt)
                { fprintf(stderr,"%s: Second integer must follow - in source name '%s'\n",
                                 Prog_Name,root);
                  exit (1);
                }
              if (last < first)
                { fprintf(stderr,
                          "%s: 2nd integer is less than 1st integer in source name '%s'\n",
                          Prog_Name,root);
                  exit (1);
                }
              ppnt = cpnt;
            }
          else
            { last = INT_MAX;
              ppnt = cpnt;
            }
        }
    }

  parse->pwd   = pwd;
  parse->root  = root;
  parse->ppnt  = ppnt;
  parse->first = first;
  parse->last  = last;
  parse->next  = first-1;
  parse->slice = NULL;
  return ((Block_Looper *) parse);
}
+28 −6
Original line number Diff line number Diff line
@@ -59,6 +59,8 @@ typedef signed long long int64;
typedef float              float32;
typedef double             float64;

#define LAST_READ_SYMBOL '$'
#define BLOCK_SYMBOL     '@'

/*******************************************************************************************
 *
@@ -215,12 +217,11 @@ int Count_Args(char *arg);
      SYSTEM_READ_ERROR		\
  }

#define FTELLO(file)		\
  ( { int x = ftello(file);	\
      if (x < 0)		\
#define FTELLO(val,file)	\
  { val = ftello(file);		\
    if (val < 0)		\
      SYSTEM_READ_ERROR		\
      ; x; 			\
  } )
  }

/*******************************************************************************************
 *
@@ -567,4 +568,25 @@ int Read_All_Sequences(DAZZ_DB *db, int ascii);

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

  //   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
  //   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);

FILE *Next_Block_Arg(Block_Looper *e_parse);
int   Next_Block_Exists(Block_Looper *e_parse);

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

#endif // _DAZZ_DB
+5 −1
Original line number Diff line number Diff line
@@ -94,6 +94,7 @@ static int prof_map[41] =
int main(int argc, char *argv[])
{ DAZZ_DB    _db, *db = &_db;
  int         Quiva_DB, Arrow_DB;
  int         FirstRead;
  FILE       *hdrs      = NULL;
  char       *hdrs_name = NULL;
  int64      *qv_idx    = NULL;
@@ -377,7 +378,10 @@ int main(int argc, char *argv[])
          else if (status == 1)
            MTRACK[i] = Load_Track(db,MASK[i]);
        }
      FirstRead = db->tfirst;
    }
  else
    FirstRead = db->ufirst;

  if (DOIQV)
    { int         status, kind;
@@ -713,7 +717,7 @@ int main(int argc, char *argv[])
            r   = reads + i;
            len = r->rlen;
            if (DORED)
              printf("R %d\n",i+1);
              printf("R %d\n",FirstRead + (i+1));

            flags = r->flags;
            qv    = (flags & DB_QV);
+1 −1
Original line number Diff line number Diff line
@@ -155,7 +155,7 @@ int main(int argc, char *argv[])
        FWRITE(&size,sizeof(int),1,afile)
        FSEEKO(afile,0,SEEK_END)
        FSEEKO(dfile,0,SEEK_END)
        indx = FTELLO(dfile);
        FTELLO(indx,dfile)
      }

    free(pwd);
Loading