+ small changes
[qpalma.git] / tools / data_tools / filterReads.c
1 ////////////////////////////////////////////////////////////
2 // The purpose of this program is to read a gff and a
3 // solexa reads file and create a data set used by QPalma.
4 //
5 //
6 //
7 ////////////////////////////////////////////////////////////
8
9 #include <sys/mman.h>
10 #include <sys/stat.h>
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <string.h>
14 #include <unistd.h>
15 #include <math.h>
16
17 #include "datastructures.h"
18
19 #define _FILE_OFFSET_BITS == 64
20
21 int compare_gene_struct(struct gene* a, struct gene* b) {
22 return a->stop - b->start;
23 }
24
25 int parse_gff(char* filename,FILE* fid,struct gene*** allGenes);
26
27 void sort_genes(struct gene*** allGenes, int numGenes);
28
29 void process_reads(FILE* reads_fs,struct gene*** allGenes,int numGenes,FILE* out_fs);
30
31 void combine_info(int exon_stop, int exon_start, void** upstream, int up_size, void** downstream, int down_size, FILE* out_fs,const char* gene_id);
32
33 //int fitting(char* up_prb, char* up_prb_end, char* down_prb, char* down_prb_end);
34 int fitting(char* up_prb, char* down_prb);
35
36 void remove_ambiguities(char * old_seq, int old_seq_size, char* new_seq);
37
38 static char *info = "Usage is:\n./filterReads gff reads output";
39
40 const int read_size = 36;
41
42 int combined_reads = 0;
43 int main(int argc, char* argv[]) {
44
45 if(argc != 4) {
46 printf("%s\n",info);
47 exit(EXIT_FAILURE);
48 }
49
50 int status;
51 int filenameSize = 256;
52 char* gff_filename = malloc(sizeof(char)*filenameSize);
53 char* reads_filename = malloc(sizeof(char)*filenameSize);
54 char* output_filename = malloc(sizeof(char)*filenameSize);
55
56 strncpy(gff_filename,argv[1],filenameSize);
57 strncpy(reads_filename,argv[2],filenameSize);
58 strncpy(output_filename,argv[3],filenameSize);
59
60 FILE *gff_fs = fopen(gff_filename,"r");
61 FILE *reads_fs = fopen(reads_filename,"r");
62 FILE *out_fs = fopen(output_filename,"w");
63
64 if(gff_fs == NULL) {
65 printf("Error: Could not open file: %s",gff_filename);
66 exit(EXIT_FAILURE);
67 }
68
69 if(reads_fs == NULL) {
70 printf("Error: Could not open file: %s",reads_filename);
71 exit(EXIT_FAILURE);
72 }
73
74 if(out_fs == NULL) {
75 printf("Error: Could not open file: %s",output_filename);
76 exit(EXIT_FAILURE);
77 }
78
79 struct gene** allGenes;
80 int numGenes = parse_gff(gff_filename,gff_fs,&allGenes);
81 status = fclose(gff_fs);
82 free(gff_filename);
83 if(status != 0)
84 printf("closing of gff filestream failed!\n");
85
86 printf("Successfully parsed gff file! Found %d genes.\n",numGenes);
87
88 // some entries in the gff files are not in a sorted order
89 //printf("Sorting genes...\n");
90 //sort_genes(&allGenes,numGenes);
91 //qsort(allGenes,numGenes,sizeof(struct gene*),compare_gene_struct);
92 ///printf("Genes were sorted!\n");
93
94 int gidx, eidx;
95 int exon_cov = 0;
96 for(gidx=0;gidx<numGenes;gidx++) {
97 for(eidx=0;eidx<allGenes[gidx]->num_exons;eidx++) {
98 exon_cov += allGenes[gidx]->exon_stops[eidx] - allGenes[gidx]->exon_starts[eidx];
99 }}
100 printf("Exon coverage is %f\n",(double)exon_cov/30432563);
101
102 process_reads(reads_fs,&allGenes,numGenes,out_fs);
103
104 status = fclose(reads_fs);
105 status = fclose(out_fs);
106 if(status != 0)
107 perror("fclose");
108
109 free(reads_filename);
110 free(output_filename);
111 return 0;
112 }
113
114 void process_reads(FILE* reads_fs,struct gene*** allGenes,int numGenes, FILE* out_fs) {
115 int status;
116
117 int buffer_size= 64;
118 int chr = 0;
119 int pos = 0;
120 char* seq = malloc(sizeof(char)*buffer_size);
121 unsigned long id = 0;
122 char strand = ' ';
123 int mismatch = 0;
124 int occurrence = 0;
125 int size = 0;
126 int cut = 0;
127 char* prb = malloc(sizeof(char)*buffer_size);
128 char* cal_prb = malloc(sizeof(char)*buffer_size);
129 char* chastity = malloc(sizeof(char)*buffer_size);
130
131 int reads_fid = fileno(reads_fs);
132 struct stat reads_stat;
133 if ( fstat(reads_fid,&reads_stat) == -1) {
134 perror("fstat");
135 exit(EXIT_FAILURE);
136 }
137 off_t reads_filesize = reads_stat.st_size;
138 printf("Reads file is of size %lu bytes\n",(unsigned long) reads_filesize);
139 int numReads = reads_filesize / 178.0;
140
141 void *reads_area = mmap (NULL,reads_filesize,PROT_READ|PROT_WRITE,MAP_PRIVATE,reads_fid,0);
142 if (reads_area == MAP_FAILED) {
143 perror("mmap");
144 exit(EXIT_FAILURE);
145 }
146 close(reads_fid);
147 printf("Successfully mapped %lu bytes of reads file into memory\n",(unsigned long)reads_filesize);
148
149 void* linePtr = reads_area;
150 char* current_line = malloc(sizeof(char)*256);
151
152 int SIZE = 500;
153 // initialize boundary arrays
154 void** upstream_end = malloc(sizeof(void*)*SIZE);
155 void** upstream_overlap = malloc(sizeof(void*)*SIZE);
156 void** downstream_start = malloc(sizeof(void*)*SIZE);
157 void** downstream_overlap= malloc(sizeof(void*)*SIZE);
158 int ue,uo,ds,dov;
159 ue = uo = ds = dov = 0;
160
161 int skippedLinesCounter = 0;
162
163 int prev_exon_start = -1;
164 int prev_exon_stop = -1;
165 int cur_exon_start = -1;
166
167 current_line = strncpy(current_line,linePtr,256);
168 int gene_idx = 0;
169 int exon_idx = 1;
170 struct gene* currentGene = (*allGenes)[gene_idx];
171 char* gene_id = currentGene->id;
172
173 char* disamb_seq = malloc(sizeof(char)*read_size);
174
175 int skippedReadCtr = 0;
176 int uselessReadCtr = 0;
177 int exonicReadCtr = 0;
178 int endPrevCtr = 0;
179 int prevOverlapCtr = 0;
180 int currentStartCtr = 0;
181 int currentOverlapCtr = 0;
182 int multioccurReadCtr = 0;
183
184 int readCtr = 0;
185 // start of the parsing loop
186 while(1) {
187 if (gene_idx == numGenes || strcmp(current_line,"") == 0)
188 break;
189
190 gene_id = currentGene->id;
191
192 if (readCtr != 0 && readCtr % 1000000 == 0)
193 printf("Processed %d/%d genes and %d/%d reads.\n",gene_idx,numGenes,readCtr,numReads);
194
195 //if (gene_idx >= 1833)
196 // printf("currentGene start/stop: %d/%d. Positions is %d\n",currentGene->start,currentGene->stop,pos);
197
198 status = sscanf(current_line,"%d\t%d\t%s\t%lu\t%c\t%d\t%d\t%d\t%d\t%s\t%s\t%s\n",
199 &chr,&pos,seq,&id,&strand,&mismatch,&occurrence,&size,&cut,prb,cal_prb,chastity);
200 if (status < 12) {
201 skippedLinesCounter++;
202 goto next_read;
203 }
204
205 // if the read is occurring several times elsewhere then get rid of it
206 //if(!(occurrence >= 1 && occurrence <= 25)) {
207 if ( occurrence != 1 ) {
208 multioccurReadCtr++;
209 goto next_read;
210 }
211
212 if (!(currentGene->start <= pos && (pos + read_size-1) <= currentGene->stop)) { // read is not within gene borders
213
214 if ( currentGene->stop < (pos + read_size-1) ) { // go to next gene
215 gene_idx++;
216 exon_idx = 1;
217 currentGene = (*allGenes)[gene_idx];
218 //printf("currentGene->start / currentGene->stop %d/%d pos is %d\n",currentGene->start,currentGene->stop,pos);
219 ue = uo = ds = dov = 0;
220 continue;
221 }
222
223 if ( pos < currentGene->start ) { // go to next read
224 skippedReadCtr++;
225
226 next_read:
227
228 while (*(char*)linePtr != '\n') linePtr++;
229 linePtr++;
230 readCtr += 1;
231 current_line = strncpy(current_line,linePtr,256);
232 continue;
233 }
234
235 } else { // read IS within gene borders
236
237 exon_label:
238
239 if (exon_idx == currentGene->num_exons) {
240 gene_idx++;
241 exon_idx = 1;
242 currentGene = (*allGenes)[gene_idx];
243 continue;
244 }
245
246 prev_exon_start = currentGene->exon_starts[exon_idx-1];
247 prev_exon_stop = currentGene->exon_stops[exon_idx-1];
248 cur_exon_start = currentGene->exon_starts[exon_idx];
249
250 //printf("exon %d %d inton til %d pos %d\n",prev_exon_start,prev_exon_stop,cur_exon_start,pos);
251
252 if (cur_exon_start - prev_exon_stop < 6 || cur_exon_start < pos ) { // go to next exon
253 exon_idx++;
254
255 if (ue != 0 && dov != 0)
256 combine_info(prev_exon_stop,cur_exon_start,upstream_end,ue,downstream_overlap,dov,out_fs,gene_id);
257
258 if (uo != 0 && ds != 0)
259 combine_info(prev_exon_stop,cur_exon_start,upstream_overlap,uo,downstream_start,ds,out_fs,gene_id);
260
261 ue = uo = ds = dov = 0;
262 goto exon_label;
263 }
264
265 if ( prev_exon_start < pos && (pos+read_size) < prev_exon_stop ) { // read is inside previous exon
266 exonicReadCtr++;
267
268 // Removed exonic reads
269
270 //remove_ambiguities(seq,strlen(seq),disamb_seq);
271 //fprintf(out_fs,"%d\t%c\t%s\t%d\t%s\t%s\t%s\n",chr,strand,disamb_seq,read_size,prb,cal_prb,chastity);
272
273 goto next_read;
274 }
275
276 if ( pos + (read_size-1) < prev_exon_stop ) // go to next read
277 goto next_read;
278
279 // if this position is reached the read is somehow overlapping or
280 // exactly on the exon boundary. now determine where exactly:
281 if (pos + (read_size-1) == prev_exon_stop) { // read ends at previous exon end
282 endPrevCtr++;
283 upstream_end[ue] = linePtr;
284 ue++;
285 goto next_read;
286 }
287
288 if ( (prev_exon_stop - pos) >= 6 && (prev_exon_stop - pos) <= 30) { // read overlaps with previous exon boundary
289 prevOverlapCtr++;
290 upstream_overlap[uo] = linePtr;
291 uo++;
292 goto next_read;
293 }
294
295 if ( pos == cur_exon_start ) { // read starts at current exon start
296 currentStartCtr++;
297 downstream_start[ds] = linePtr;
298 ds++;
299 goto next_read;
300 }
301
302 if ( (cur_exon_start - pos) >= 6 && (cur_exon_start - pos) <= 30 ) { // read overlaps with current exon boundary
303 currentOverlapCtr++;
304 downstream_overlap[dov] = linePtr;
305 dov++;
306 goto next_read;
307 }
308
309 uselessReadCtr++;
310 goto next_read; // read was not useful i.e. not overlapping/starting at exon boundaries
311 }
312 }
313
314 combine_info(prev_exon_stop,cur_exon_start,upstream_end,ue,downstream_overlap,dov,out_fs,gene_id);
315 combine_info(prev_exon_stop,cur_exon_start,upstream_overlap,uo,downstream_start,ds,out_fs,gene_id);
316
317 free(upstream_end);
318 free(upstream_overlap);
319 free(downstream_start);
320 free(downstream_overlap);
321
322 printf("Processed %d reads in total while %d reads where skipped.\n",readCtr,skippedLinesCounter);
323 printf("%d were totally intronic. %d were outside of genes and %d were occurring on several positions.\n",uselessReadCtr,skippedReadCtr,multioccurReadCtr);
324 printf("%d reads were useless in total\n",uselessReadCtr+skippedReadCtr+multioccurReadCtr);
325 printf("%d reads were totally exonic\n",exonicReadCtr);
326 printf("%d reads overlap with prev. exon. %d reads overlap with current exon\n",prevOverlapCtr,currentOverlapCtr);
327 printf("%d reads where newly combined from two original reads\n",combined_reads);
328 printf("Total used reads: %d\n",exonicReadCtr+endPrevCtr+prevOverlapCtr+currentStartCtr+currentOverlapCtr);
329
330 status = munmap(reads_area,reads_filesize);
331 if(status != 0)
332 perror("munmap");
333
334 //free(current_line);
335 free(seq);
336 free(prb);
337 free(cal_prb);
338 free(chastity);
339 }
340
341 void combine_info(int exon_stop, int exon_start, void** upstream, int up_size, void** downstream, int down_size,FILE* out_fs,const char* gene_id) {
342 //printf("up/down size is %d/%d\n",up_size,down_size);
343
344 int up_idx, down_idx, status;
345 char* upstream_line = malloc(sizeof(char)*256);
346 char* downstream_line = malloc(sizeof(char)*256);
347
348 int buffer_size= 64;
349
350 int up_chr = 0;
351 int up_pos = 0;
352 char* up_seq = malloc(sizeof(char)*buffer_size);
353 int up_id = 0;
354 char up_strand = ' ';
355 int up_mismatch = 0;
356 int up_occurrence = 0;
357 int up_sz = 0;
358 int up_cut = 0;
359 char* up_prb = malloc(sizeof(char)*buffer_size);
360 char* up_cal_prb = malloc(sizeof(char)*buffer_size);
361 char* up_chastity = malloc(sizeof(char)*buffer_size);
362
363 int down_chr = 0;
364 int down_pos = 0;
365 char* down_seq = malloc(sizeof(char)*buffer_size);
366 int down_id = 0;
367 char down_strand = ' ';
368 int down_mismatch = 0;
369 int down_occurrence = 0;
370 int down_sz = 0;
371 int down_cut = 0;
372 char* down_prb = malloc(sizeof(char)*buffer_size);
373 char* down_cal_prb = malloc(sizeof(char)*buffer_size);
374 char* down_chastity = malloc(sizeof(char)*buffer_size);
375
376 int new_chr = 0;
377 char* new_seq = malloc(sizeof(char)*buffer_size);
378 char new_strand = ' ';
379 char* new_prb = malloc(sizeof(char)*buffer_size);
380 char* new_cal_prb = malloc(sizeof(char)*buffer_size);
381 char* new_chastity = malloc(sizeof(char)*buffer_size);
382 char* new_up_seq = malloc(sizeof(char)*read_size);
383 char* new_down_seq = malloc(sizeof(char)*read_size);
384
385 int overlap;
386 int fit;
387
388 char* used_flag = calloc(down_size,sizeof(char));
389
390 for(up_idx=0;up_idx<up_size;up_idx++) {
391 strncpy(upstream_line,upstream[up_idx],256);
392 status = sscanf(upstream_line,"%d\t%d\t%s\t%d\t%c\t%d\t%d\t%d\t%d\t%s\t%s\t%s\n",
393 &up_chr,&up_pos,up_seq,&up_id,&up_strand,&up_mismatch,&up_occurrence,&up_sz,
394 &up_cut,up_prb,up_cal_prb,up_chastity);
395
396 remove_ambiguities(up_seq,strlen(up_seq),new_up_seq);
397
398 overlap = exon_stop - up_pos;
399
400 for(down_idx=0;down_idx<down_size;down_idx++) {
401 if( used_flag[down_idx] == 1)
402 continue;
403
404 strncpy(downstream_line,downstream[down_idx],256);
405 status = sscanf(downstream_line,"%d\t%d\t%s\t%d\t%c\t%d\t%d\t%d\t%d\t%s\t%s\t%s\n",
406 &down_chr,&down_pos,down_seq,&down_id,&down_strand,&down_mismatch,&down_occurrence,&down_sz,
407 &down_cut,down_prb,down_cal_prb,down_chastity);
408
409 remove_ambiguities(down_seq,strlen(down_seq),new_down_seq);
410
411 new_seq[0] = '\0';
412 new_prb[0] = '\0';
413 new_cal_prb[0] = '\0';
414 new_chastity[0] = '\0';
415 int splitpos = 0;
416
417 fit = fitting(up_prb+(36-overlap),down_prb);
418 if (fit == -1)
419 continue;
420
421 if (! (fit < overlap ))
422 continue;
423
424 new_chr = up_chr;
425 new_strand = up_strand;
426
427 strncat(new_seq,new_up_seq,overlap);
428 strncat(new_prb,up_prb,overlap);
429 strncat(new_cal_prb,up_cal_prb,overlap);
430 strncat(new_chastity,up_chastity,overlap);
431
432 strncat(new_seq,new_down_seq+fit,read_size-overlap);
433 strncat(new_prb,down_prb+fit,read_size-overlap);
434 strncat(new_cal_prb,down_cal_prb+fit,read_size-overlap);
435 strncat(new_chastity,down_chastity+fit,read_size-overlap);
436
437 fprintf(out_fs,"%d\t%c\t%s\t%d\t%d\t%s\t%s\t%s\t%s\n",
438 new_chr,new_strand,new_seq,splitpos,read_size,new_prb,new_cal_prb,new_chastity,gene_id);
439
440 combined_reads++;
441 used_flag[down_idx] = 1;
442 }
443 }
444
445 free(upstream_line);
446 free(downstream_line);
447
448 free(new_up_seq);
449 free(new_down_seq);
450
451 free(up_seq);
452 free(up_prb);
453 free(up_cal_prb);
454 free(up_chastity);
455
456 free(down_seq);
457 free(down_prb);
458 free(down_cal_prb);
459 free(down_chastity);
460
461 free(new_seq);
462 free(new_prb);
463 free(new_cal_prb);
464 free(new_chastity);
465 }
466
467
468
469
470 /*
471 int fitting(char* up_prb, char* up_prb_end, char* down_prb, char* down_prb_end) {
472 double epsilon_mean = 15.0;
473 double epsilon_var = 10.0;
474 double mean_up = 0;
475 double variance_up = 0;
476 double mean_down = 0;
477 double variance_down = 0;
478
479 char *up_ptr = up_prb;
480 char *down_ptr = down_prb;
481
482 int w_size = 0;
483 while(up_ptr != up_prb_end) {
484 mean_up += (*up_ptr)-50;
485 mean_down += (*down_ptr)-50;
486 w_size++;
487 up_ptr++;
488 down_ptr++;
489 }
490 mean_up /= w_size;
491 mean_down /= w_size;
492
493
494 up_ptr = up_prb;
495 down_ptr = down_prb;
496 w_size = 0;
497 while(up_ptr != up_prb_end) {
498 variance_up += pow((*up_prb)-50 - mean_up,2);
499 variance_down += pow((*down_prb)-50 - mean_down,2);
500 w_size++;
501 up_ptr++;
502 down_ptr++;
503 }
504 variance_up /= (w_size-1);
505 variance_down /= (w_size-1);
506
507 //printf("means: %f %f, variances: %f %f\n",mean_up,mean_down,variance_up,variance_down);
508
509 if ( abs(mean_up - mean_down) < epsilon_mean && abs(variance_up - variance_down) < epsilon_var )
510 return 1;
511
512 return 0;
513 }
514 */
515
516 int fitting(char* up_prb, char* down_prb) {
517 double epsilon_mean = 30.0;
518 double epsilon_var = 30.0;
519 int w_size = 6;
520
521 double current_mean_up = 0;
522 double current_variance_up = 0;
523 double current_mean_down = 0;
524 double current_variance_down = 0;
525
526 double* mean_up = malloc(sizeof(double)*read_size-2*w_size);
527 double* variance_up = malloc(sizeof(double)*read_size-2*w_size);
528 double* mean_down = malloc(sizeof(double)*read_size-2*w_size);
529 double* variance_down = malloc(sizeof(double)*read_size-2*w_size);
530
531 int iidx = -1;
532 int uidx;
533 int didx;
534
535 for(uidx=iidx-w_size;uidx<iidx;uidx++) {
536 didx = uidx+w_size;
537 current_mean_up += up_prb[uidx]-50;
538 current_mean_down += up_prb[didx]-50;
539
540 }
541 current_mean_up /= w_size;
542 current_mean_down /= w_size;
543
544 for(uidx=iidx-w_size;uidx<iidx;uidx++) {
545 didx = uidx+w_size;
546 current_variance_up += pow(up_prb[uidx]-50 - current_mean_up,2);
547 current_variance_down += pow(up_prb[didx]-50 - current_mean_up,2);
548
549 }
550 current_variance_up /= (w_size-1);
551 current_variance_down /= (w_size-1);
552
553 for(iidx=w_size;iidx<30;iidx++) {
554 for(uidx=iidx-w_size;uidx<iidx;uidx++) {
555 didx = uidx+w_size;
556 mean_up[iidx-w_size] += down_prb[uidx]-50;
557 mean_down[iidx-w_size] += down_prb[didx]-50;
558
559 }
560 mean_up[iidx-w_size] /= w_size;
561 mean_down[iidx-w_size] /= w_size;
562
563 for(uidx=iidx-w_size;uidx<iidx;uidx++) {
564 didx = uidx+w_size;
565 variance_up[iidx-w_size] += pow(down_prb[uidx]-50 - mean_up[iidx-w_size],2);
566 variance_down[iidx-w_size] += pow(down_prb[didx]-50 - mean_down[iidx-w_size],2);
567 }
568 variance_up[iidx-w_size] /= (w_size-1);
569 variance_down[iidx-w_size] /= (w_size-1);
570
571 //printf("means: %f %f %f %f, variances: %f %f %f %f\n",current_mean_up,current_mean_down,mean_up,mean_down,current_variance_up,current_variance_down,variance_up,variance_down);
572 //if ( abs(current_mean_up - mean_up) < epsilon_mean && abs(current_variance_up - variance_up) < epsilon_var
573 //&& abs(current_mean_down - mean_down) < epsilon_mean && abs(current_variance_down - variance_down) < epsilon_var )
574 // return iidx;
575 }
576
577 int bidx;
578 int bestIdx = -1;
579 double min = 1000.0;
580 for(bidx=0;bidx<read_size-2*w_size;bidx++) {
581 if ( abs(current_mean_up - mean_up[bidx]) < epsilon_mean && abs(current_variance_up - variance_up[bidx]) < epsilon_var
582 && abs(current_mean_down - mean_down[bidx]) < epsilon_mean && abs(current_variance_down - variance_down[bidx]) < epsilon_var ) {
583 if ( abs(current_mean_up - mean_up[bidx]) + abs(current_variance_up - variance_up[bidx]) + abs(current_mean_down - mean_down[bidx]) + abs(current_variance_down - variance_down[bidx])) {
584 min = abs(current_mean_up - mean_up[bidx]) + abs(current_variance_up - variance_up[bidx]) + abs(current_mean_down - mean_down[bidx]) + abs(current_variance_down - variance_down[bidx]);
585 bestIdx = bidx;
586 }
587 }
588 }
589
590 free(mean_up);
591 free(variance_up);
592 free(mean_down);
593 free(variance_down);
594
595 return bestIdx;
596 }
597
598 void remove_ambiguities(char * old_seq, int old_seq_size, char* new_seq) {
599 int idx=0;
600 int new_idx = 0;
601
602 while(idx<old_seq_size) {
603 //printf("Current elem %c pos %d %d\n",old_seq[idx],idx,new_idx);
604 if (old_seq[idx] == ']' || old_seq[idx] == '-' ) {
605 idx++;
606 continue;
607 }
608
609 if (old_seq[idx] == '[') {
610 idx += 2;
611 //printf("%c %c\n",old_seq[idx-2],old_seq[idx]);
612 continue;
613 }
614
615 new_seq[new_idx] = old_seq[idx];
616 idx++;
617 new_idx++;
618 }
619
620 if (new_idx != 36) {
621 printf("Error: Sequence is not of length 36!\n");
622 printf("old seq: %s\n",old_seq);
623 printf("new seq: %s\n",new_seq);
624 exit(EXIT_FAILURE);
625 }
626 }
627
628 /*
629 * TODO:
630 * - Check strand -> done simple (only if equal)
631 * - check for [AC] and similar entries -> done simple (see function
632 * - remove_ambiguities (exchanges [XY] by the second entry)
633 */