annotate source/fastq.c @ 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 "fastq.h"
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
9
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
10 FASTQ_ALL *fastq_create()
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 /* 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
13 * otherwise, return NULL/.
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
14 */
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
15 FASTQ_ALL *fq;
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
16
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
17 if((fq=(FASTQ_ALL *)malloc(sizeof(FASTQ_ALL)))==NULL)
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
18 return NULL;
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 fq->description_1=NULL;
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
21 fq->sequence=NULL;
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
22 fq->description_2=NULL;
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
23 fq->quality=NULL;
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
24
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
25 return fq;
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
26 }
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
27
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
28 int fastq_remove(FASTQ_ALL *fq)
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
29 {
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
30 /* 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
31 */
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
32 if(fq==NULL)
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
33 return 1;
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 if(fq->description_1!=NULL)
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
36 free(fq->description_1);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
37 if(fq->sequence!=NULL)
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
38 free(fq->sequence);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
39 if(fq->description_2!=NULL)
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
40 free(fq->description_2);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
41 if(fq->quality!=NULL)
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
42 free(fq->quality);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
43
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
44 free(fq);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
45
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
46 return 0;
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
47 }
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
48
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
49 int fastq_clear(FASTQ_ALL *fq)
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
50 {
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
51 /* 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
52 */
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
53 if(fq==NULL)
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
54 return 1;
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
55
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
56 if(fq->description_1!=NULL)
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
57 {
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
58 free(fq->description_1);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
59 fq->description_1=NULL;
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 if(fq->sequence!=NULL)
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
62 {
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
63 free(fq->sequence);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
64 fq->sequence=NULL;
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
65 }
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
66 if(fq->description_2!=NULL)
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
67 {
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
68 free(fq->description_2);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
69 fq->description_2=NULL;
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
70 }
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
71 if(fq->quality!=NULL)
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
72 {
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
73 free(fq->quality);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
74 fq->quality=NULL;
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
75 }
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
76
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
77 return 0;
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
78 }
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
79
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
80 long fastq_get_serial(FASTQ_ALL *fq)
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
81 {
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
82 /* 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
83 * 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
84 */
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
85 long serial;
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
86
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
87 if(fq==NULL || fq->description_1==NULL || fq->description_1[0]=='\0')
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
88 return -1;
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
89
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
90 if((sscanf(fq->description_1, "@%ld", &serial))!=1)
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
91 return -1;
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
92
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
93 return serial;
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
94 }
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
95
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
96 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
97 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
98 {
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
99 /* 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
100 * 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
101 * (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
102 * and return 1.
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
103 */
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
104 char description_1[FASTQ_DESCRIPTION_MAX_LENGTH], sequence[FASTQ_SEQUENCE_MAX_LENGTH];
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
105 char description_2[FASTQ_DESCRIPTION_MAX_LENGTH], quality[FASTQ_SEQUENCE_MAX_LENGTH];
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
106
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
107 char *p_description_1, *p_sequence, *p_description_2, *p_quality;
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
108
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
109 if(fp_in==NULL || fq==NULL)
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
110 return 1;
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
111
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
112 fastq_clear(fq);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
113
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
114 /* read the FASTQ sequence */
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
115 fgets(description_1, FASTQ_DESCRIPTION_MAX_LENGTH, fp_in);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
116 fgets(sequence, FASTQ_SEQUENCE_MAX_LENGTH, fp_in);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
117 fgets(description_2, FASTQ_DESCRIPTION_MAX_LENGTH, fp_in);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
118 fgets(quality, FASTQ_SEQUENCE_MAX_LENGTH, fp_in);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
119
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
120 /* check whether integrity of the FASTQ sequence */
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
121 if(description_1[0]=='\0' || sequence[0]=='\0' || description_2[0]=='\0' ||
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
122 quality[0]=='\0' || description_1[0]!='@'|| description_2[0]!='+' ||
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
123 description_1[strlen(description_1)-1]!='\n' ||
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
124 sequence[strlen(sequence)-1]!='\n' ||
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
125 description_2[strlen(description_2)-1]!='\n')
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
126 return 1;
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
127
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
128 /* remove return character at the end */
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
129 if(description_1[strlen(description_1)-1]=='\n')
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
130 description_1[strlen(description_1)-1]='\0';
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
131 if(sequence[strlen(sequence)-1]=='\n')
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
132 sequence[strlen(sequence)-1]='\0';
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
133 if(description_2[strlen(description_2)-1]=='\n')
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
134 description_2[strlen(description_2)-1]='\0';
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
135 if(quality[strlen(quality)-1]=='\n')
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
136 quality[strlen(quality)-1]='\0';
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
137
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
138 /* append the sequence information to fq */
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
139 if((p_sequence=(char *)malloc(strlen(sequence)+1))==NULL)
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
140 return 1;
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
141 strcpy(p_sequence, sequence);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
142 fq->sequence=p_sequence;
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
143
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
144 if(whether_append_quality==1)
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
145 {
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
146 if((p_quality=(char *)malloc(strlen(quality)+1))==NULL)
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
147 {
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
148 fastq_clear(fq);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
149 return 1;
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
150 }
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
151 strcpy(p_quality, quality);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
152 fq->quality=p_quality;
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
153 }
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
154 if(whether_append_description==1)
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
155 {
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
156 if((p_description_1=(char *)malloc(strlen(description_1)+1))==NULL)
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
157 {
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
158 fastq_clear(fq);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
159 return 1;
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
160 }
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
161 strcpy(p_description_1, description_1);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
162 fq->description_1=p_description_1;
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
163
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
164 if((p_description_2=(char *)malloc(strlen(description_2)+1))==NULL)
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
165 {
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
166 fastq_clear(fq);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
167 return 1;
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
168 }
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
169 strcpy(p_description_2, description_2);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
170 fq->description_2=p_description_2;
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
171 }
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
172
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
173 return 0;
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
174 }
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
175
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
176 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
177 {
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
178 /* 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
179 * 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
180 * If successful, return 0, otherwise return 1.
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
181 */
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
182 if(fp_out==NULL || fq==NULL)
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
183 return 1;
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
184
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
185 if(strcmp(format, "fq")==0) /* output in FASTQ format */
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
186 {
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
187 if(serial==-1)
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
188 {
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
189 if(fq->description_1!=NULL)
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
190 {
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
191 fputs(fq->description_1, fp_out);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
192 fputc('\n', fp_out);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
193 fputs(fq->sequence, fp_out);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
194 fputc('\n', fp_out);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
195 fputs(fq->description_2, fp_out);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
196 fputc('\n', fp_out);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
197 fputs(fq->quality, fp_out);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
198 fputc('\n', fp_out);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
199 }
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
200 else
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
201 {
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
202 fputc('@', fp_out);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
203 fputc('\n', fp_out);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
204 fputs(fq->sequence, fp_out);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
205 fputc('\n', fp_out);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
206 fputc('+', fp_out);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
207 fputc('\n', fp_out);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
208 fputs(fq->quality, fp_out);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
209 fputc('\n', fp_out);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
210 }
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
211 }
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
212 else
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
213 {
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
214 fprintf(fp_out, "@%ld\n", serial);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
215 fputs(fq->sequence, fp_out);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
216 fputc('\n', fp_out);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
217 fprintf(fp_out, "+%ld\n", serial);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
218 fputs(fq->quality, fp_out);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
219 fputc('\n', fp_out);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
220 }
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
221 }
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
222 else if(strcmp(format, "fa")==0) /* output in FASTQ format */
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
223 {
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
224 if(serial==-1)
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
225 {
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
226 if(fq->description_1!=NULL)
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
227 {
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
228 fputc('>', fp_out);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
229 fputs(&(fq->description_1[1]), fp_out);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
230 fputc('\n', fp_out);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
231 fputs(fq->sequence, fp_out);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
232 fputc('\n', fp_out);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
233 }
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
234 else
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
235 {
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
236 fputc('>', fp_out);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
237 fputc('\n', fp_out);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
238 fputs(fq->sequence, fp_out);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
239 fputc('\n', fp_out);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
240 }
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
241 }
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
242 else
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
243 {
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
244 fprintf(fp_out, ">%ld\n", serial);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
245 fputs(fq->sequence, fp_out);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
246 fputc('\n', fp_out);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
247 }
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
248 }
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
249 else
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
250 return 1;
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
251
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
252 return 0;
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
253 }
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
254
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
255 long fastq_get_length(FASTQ_ALL *fq)
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
256 {
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
257 /* return the length of FASTQ sequence, is any error, return -1
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
258 */
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
259
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
260 if(fq==NULL)
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
261 return -1;
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
262 if(fq->sequence==NULL)
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
263 return 0;
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
264 return strlen(fq->sequence);
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
265 }
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
266
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
267
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
268
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
269
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
270
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
271
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
272
816cb55b5a2d planemo upload for repository https://github.com/portiahollyoak/Tools commit c4769fd68ad9583d4b9dbdf212e4ecb5968cef1c-dirty
portiahollyoak
parents:
diff changeset
273