Mercurial > repos > portiahollyoak > fastuniq
annotate source/fastq.h @ 0:816cb55b5a2d draft default tip
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
author | portiahollyoak |
---|---|
date | Thu, 02 Jun 2016 11:34:51 -0400 |
parents | |
children |
rev | line source |
---|---|
0
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
1 /**************************************************************************** |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
2 * The 'FASTQ_ALL' structure group was used to store nucleotide sequence in |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
3 * fastq format, including basic operation function as well. |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
4 * |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
5 * This file was written by Haibin Xu, December 2011. |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
6 ****************************************************************************/ |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
7 |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
8 #include <stdio.h> |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
9 #include <stdlib.h> |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
10 #include <string.h> |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
11 |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
12 #ifndef FASTQ_DESCRIPTION_MAX_LENGTH |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
13 #define FASTQ_DESCRIPTION_MAX_LENGTH 1000 |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
14 #endif |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
15 |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
16 #ifndef FASTQ_SEQUENCE_MAX_LENGTH |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
17 #define FASTQ_SEQUENCE_MAX_LENGTH 2000 |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
18 #endif |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
19 |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
20 #ifndef _FASTQ_ALL |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
21 typedef struct fastq_all |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
22 { |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
23 char *description_1; /* the 1st description line */ |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
24 char *sequence; /* the sequence*/ |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
25 char *description_2; /* the 2nd description line */ |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
26 char *quality; /* the quality */ |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
27 } FASTQ_ALL; |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
28 #define _FASTQ_ALL |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
29 #endif |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
30 |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
31 /* create a FASTQ_ALL sequence. If successful, return the point to it, |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
32 * otherwise, return NULL. */ |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
33 FASTQ_ALL *fastq_create(); |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
34 |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
35 /* free the FASTQ sequence. If successful, return 0, otherwise return 1. */ |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
36 int fastq_remove(FASTQ_ALL *fq); |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
37 |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
38 /* clear the FASTQ sequence. If successful, return 0, otherwise return 1. */ |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
39 int fastq_clear(FASTQ_ALL *fq); |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
40 |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
41 /* get sequence serial from FASTQ description in format '@serial_number'. |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
42 * If successful return the serial, otherwise return -1. */ |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
43 long fastq_get_serial(FASTQ_ALL *fq); |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
44 |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
45 /* read a FASTQ sequence from input file, including description (whether_append_description=1) |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
46 * or not (whether_append_description=0), including quality (whether_append_quality=1) or not |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
47 * (whether_append_quality=0). If successful, return 0, otherwise, clear fq |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
48 * and return 1. */ |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
49 int fastq_scanf(FASTQ_ALL *fq, FILE *fp_in, |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
50 int whether_append_description, int whether_append_quality); |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
51 |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
52 /* write sequence into output file in FASTQ format(format='fq') or FASTA format(format='fa') |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
53 * using the original description (serial=-1) or the new serial. |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
54 * If successful, return 0, otherwise return 1. */ |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
55 int fastq_printf(FASTQ_ALL *fq, FILE *fp_out, char *format, long serial); |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
56 |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
57 /* return the length of FASTQ sequence, if any error, return -1. */ |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
58 long fastq_get_length(FASTQ_ALL *fq); |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
59 |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
60 |
816cb55b5a2d
planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff
changeset
|
61 |