/* See dm_seq_bank.h */
/* Last edited on 2008-03-29 14:43:14 by stolfi */ 

#include <vec.h>
#include <dm_basic.h>
#include <dm_seq.h>
#include <dm_seq_bank.h>

vec_typeimpl(dm_seq_vec_t,dm_seq_vec,dm_seq_t);

#define dm_gdb_format "2006-02-18"

dm_seq_bank_t dm_seq_bank_read(char *dbName, char *seqDir)
  { dm_seq_bank_t db;
    
    FILE *dbf = dm_open_read(dbName, ".gdb");
    
    filefmt_read_header(dbf, "gdb", dm_gdb_format);
    int nseq = nget_int(dbf, "nseqs"); fget_eol(dbf);
    db.r = 0;
    db.seq = dm_seq_vec_new(nseq);
    int i;
    for (i = 0; i < nseq; i++) 
      { char *seqName = fget_string(dbf);
        db.seq.e[i] = dm_read_sequence(seqName, seqDir);
        free(seqName);
      }
    filefmt_read_footer(dbf, "gdb");
    fclose(dbf);
    return db;
  }
