~ubuntu-branches/ubuntu/utopic/ffindex/utopic

« back to all changes in this revision

Viewing changes to src/ffindex_from_fasta.c

  • Committer: Package Import Robot
  • Author(s): Laszlo Kajan
  • Date: 2013-11-25 20:01:02 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20131125200102-quenacnokvrc76ij
Tags: 0.9.9.3-1
* New upstream release.
* Up-to-date standards-version.
* Vcs fields updated.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * FFindex
3
 
 * written by Andy Hauser <hauser@genzentrum.lmu.de>.
 
3
 * written by Andreas Hauser <andy@splashground.de>.
4
4
 * Please add your name here if you distribute modified versions.
5
5
 * 
6
6
 * FFindex is provided under the Create Commons license "Attribution-ShareAlike
35
35
                    "\t-s\tsort index file\n"
36
36
                    "ENVIRONMENT\n"
37
37
                    "\tFFINDEX_MAX_INDEX_ENTRIES - allocate memory for this number of entries\n"
38
 
                    "\nDesigned and implemented by Andreas W. Hauser <hauser@genzentrum.lmu.de>.\n", basename(program_name));
 
38
                    FFINDEX_COPYRIGHT,
 
39
                    basename(program_name));
39
40
}
40
41
 
41
42
int main(int argn, char **argv)
76
77
  char *index_filename = argv[optind++];
77
78
  char *fasta_filename = argv[optind++];
78
79
  FILE *data_file, *index_file, *fasta_file;
79
 
 
80
 
  struct stat st;
81
 
 
82
 
  if(stat(data_filename, &st) == 0) { errno = EEXIST; perror(data_filename); return EXIT_FAILURE; }
83
 
  data_file  = fopen(data_filename, "w");
84
 
  if( data_file == NULL) { perror(data_filename); return EXIT_FAILURE; }
85
 
 
86
 
  if(stat(index_filename, &st) == 0) { errno = EEXIST; perror(index_filename); return EXIT_FAILURE; }
87
 
  index_file = fopen(index_filename, "w+");
88
 
  if(index_file == NULL) { perror(index_filename); return EXIT_FAILURE; }
 
80
  size_t offset = 0;
 
81
 
 
82
  /* open ffindex */
 
83
  err = ffindex_index_open(data_filename, index_filename, "w", &data_file, &index_file, &offset);
 
84
  if(err != EXIT_SUCCESS)
 
85
    return err;
89
86
 
90
87
  fasta_file = fopen(fasta_filename, "r");
91
88
  if(fasta_file == NULL) { perror(fasta_filename); return EXIT_FAILURE; }
92
89
 
93
90
  size_t fasta_size;
94
91
  char *fasta_data = ffindex_mmap_data(fasta_file, &fasta_size);
95
 
  size_t offset = 0;
96
92
  size_t from_length = 0;
97
93
  char name[FFINDEX_MAX_ENTRY_NAME_LENTH];
98
94
  int seq_id = 1;