diff --git a/recipes/bcftools-gtc2vcf-plugin/1.9/affy2vcf.c.patch b/recipes/bcftools-gtc2vcf-plugin/1.9/affy2vcf.c.patch new file mode 100644 index 0000000000000..ec89a7b984274 --- /dev/null +++ b/recipes/bcftools-gtc2vcf-plugin/1.9/affy2vcf.c.patch @@ -0,0 +1,119 @@ +--- gtc2vcf-b890909/affy2vcf.c.orig 2018-10-11 10:20:20.163766095 -0400 ++++ gtc2vcf-b890909/affy2vcf.c 2018-10-11 10:22:47.924639141 -0400 +@@ -192,7 +192,8 @@ + + int moff = 0, *off = NULL; + int ncols = ksplit_core(str.s, ',', &moff, &off); +- for (int i=0; iprobeset_id); +- for (int i=0; in_records; i++) ++ int i; ++ for (i=0; in_records; i++) + { + free(annot->records[i].probe_set); + free(annot->records[i].dbsnp); +@@ -297,7 +299,8 @@ + + static void report_destroy(report_t *report) + { +- for (int i=0; in_samples; i++) free(report->cel_files[i]); ++ int i; ++ for (i=0; in_samples; i++) free(report->cel_files[i]); + free(report->genders); + } + +@@ -309,7 +312,8 @@ + { + bcf_hdr_t *hdr = bcf_hdr_init("w"); + int n = faidx_nseq(fai); +- for (int i=0; iab_delta ) + { +@@ -393,7 +398,8 @@ + ncols = ksplit_core(str.s, '\t', &moff, &off); + if ( strcmp(&str.s[off[0]], "probeset_id") ) error("Malformed first line from summary file: %s\n%s\n", summary_fn, str.s); + +- for (int i=1; in_samples; i++) fprintf(sex_fh, "%s\t%d\n", report->cel_files[i], report->genders[i]); ++ int i; ++ for (i=0; in_samples; i++) fprintf(sex_fh, "%s\t%d\n", report->cel_files[i], report->genders[i]); + fclose(sex_fh); + report_destroy(report); + } +@@ -650,4 +658,4 @@ + bcf_hdr_destroy(hdr); + hts_close(out_fh); + return 0; +-} +\ No newline at end of file ++} diff --git a/recipes/bcftools-gtc2vcf-plugin/1.9/build.sh b/recipes/bcftools-gtc2vcf-plugin/1.9/build.sh new file mode 100644 index 0000000000000..4b4b793ce661c --- /dev/null +++ b/recipes/bcftools-gtc2vcf-plugin/1.9/build.sh @@ -0,0 +1,35 @@ +#!/bin/sh + +export VERSION=1.9 +export C_INCLUDE_PATH=${PREFIX}/include +export CPP_INCLUDE_PATH=${PREFIX}/include +export CXX_INCLUDE_PATH=${PREFIX}/include +export CPLUS_INCLUDE_PATH=${PREFIX}/include +export LIBRARY_PATH=${PREFIX}/lib +export CPPFLAGS="$CPPFLAGS -I$PREFIX/include" +export LDFLAGS="$LDFLAGS -L$PREFIX/lib" +export CFLAGS="$CFLAGS -I$PREFIX/include" + +mkdir -p $PREFIX/bin +mkdir -p $PREFIX/libexec/bcftools + +# Copy plugin source to the bcftools plugin directory. +cp gtc2vcf-b890909/affy2vcf.c bcftools-$VERSION/plugins/ +cp gtc2vcf-b890909/gtc2vcf.c bcftools-$VERSION/plugins/ + +# Compile htslib and bcftools with affy2vcf and gtc2vcf plugins. +pushd htslib-$VERSION +autoheader +(autoconf || autoconf) +./configure --disable-bz2 --disable-lzma --prefix=$PREFIX +make +popd + +pushd bcftools-$VERSION +make +popd + +# Move custom bcftools plugins to the ~/libexec/bcftools directory. +mv bcftools-$VERSION/plugins/affy2vcf.so $PREFIX/libexec/bcftools/ +mv bcftools-$VERSION/plugins/fixref.so $PREFIX/libexec/bcftools/ +mv bcftools-$VERSION/plugins/gtc2vcf.so $PREFIX/libexec/bcftools/ diff --git a/recipes/bcftools-gtc2vcf-plugin/1.9/fixref.c.patch b/recipes/bcftools-gtc2vcf-plugin/1.9/fixref.c.patch new file mode 100644 index 0000000000000..473e19023a8c0 --- /dev/null +++ b/recipes/bcftools-gtc2vcf-plugin/1.9/fixref.c.patch @@ -0,0 +1,107 @@ +--- bcftools-1.9/plugins/fixref.c.orig 2018-06-30 03:48:02.000000000 -0400 ++++ bcftools-1.9/plugins/fixref.c 2018-10-03 09:03:07.270160080 -0400 +@@ -90,6 +90,7 @@ + #define MODE_TOP2FWD 2 + #define MODE_FLIP2FWD 3 + #define MODE_USE_ID 4 ++#define MODE_SWAP 6 + + typedef struct + { +@@ -104,12 +105,14 @@ + typedef struct + { + char *dbsnp_fname; +- int mode, discard; ++ int mode, discard, flip_baf; + bcf_hdr_t *hdr; + faidx_t *fai; + int rid, skip_rid; + i2m_t *i2m; + int32_t *gts, ngts, pos; ++ float *bafs; ++ int32_t nbafs; + uint32_t nsite,nok,nflip,nunresolved,nswap,nflip_swap,nonSNP,nonACGT,nonbiallelic; + uint32_t count[4][4], npos_err, unsorted; + } +@@ -130,6 +133,7 @@ + " Currently the following modes are recognised:\n" + " flip .. flips non-ambiguous SNPs and ignores the rest\n" + " id .. swap REF/ALT and GTs using the ID column to determine the REF allele\n" ++ " swap .. swap REF/ALT columns and GTs and ignore the rest\n" + " stats .. collect and print stats\n" + " top .. converts from Illumina TOP strand to fwd\n" + "\n" +@@ -148,7 +152,8 @@ + " -i, --use-id Swap REF/ALT using the ID column to determine the REF allele, implies -m id.\n" + " Download the dbSNP file from\n" + " https://www.ncbi.nlm.nih.gov/variation/docs/human_variation_vcf\n" +- " -m, --mode Collect stats (\"stats\") or convert (\"flip\", \"id\", \"top\") [stats]\n" ++ " -m, --mode Collect stats (\"stats\") or convert (\"flip\", \"id\", \"swap\", \"top\") [stats]\n" ++ " -b --flip-baf Flip BAF when swapping genotypes\n" + "\n" + "Examples:\n" + " # run stats\n" +@@ -178,10 +183,11 @@ + {"discard",no_argument,NULL,'d'}, + {"fasta-ref",required_argument,NULL,'f'}, + {"use-id",required_argument,NULL,'i'}, ++ {"flip-baf",no_argument,NULL,'b'}, + {NULL,0,NULL,0} + }; + int c; +- while ((c = getopt_long(argc, argv, "?hf:m:di:",loptions,NULL)) >= 0) ++ while ((c = getopt_long(argc, argv, "?hf:m:di:b:",loptions,NULL)) >= 0) + { + switch (c) + { +@@ -190,11 +196,13 @@ + else if ( !strcasecmp(optarg,"flip") ) args.mode = MODE_FLIP2FWD; + else if ( !strcasecmp(optarg,"id") ) args.mode = MODE_USE_ID; + else if ( !strcasecmp(optarg,"stats") ) args.mode = MODE_STATS; ++ else if ( !strcasecmp(optarg,"swap") ) args.mode = MODE_SWAP; + else error("The source strand convention not recognised: %s\n", optarg); + break; + case 'i': args.dbsnp_fname = optarg; args.mode = MODE_USE_ID; break; + case 'd': args.discard = 1; break; + case 'f': ref_fname = optarg; break; ++ case 'b': args.flip_baf = 1; break; + case 'h': + case '?': + default: error("%s", usage()); break; +@@ -231,6 +239,13 @@ + } + } + bcf_update_genotypes(args->hdr,rec,args->gts,args->ngts); ++ ++ if (args->flip_baf && bcf_get_format_float(args->hdr, rec, "BAF", &args->bafs, &args->nbafs) >= 0) ++ { ++ float *ptr = args->bafs; ++ for (i=0; inbafs; i++, ptr++) *ptr = 1 - *ptr; ++ bcf_update_format_float(args->hdr, rec, "BAF", args->bafs, args->nbafs); ++ } + + return rec; + } +@@ -430,6 +445,13 @@ + if ( ir==revint(ib) ) { args.nflip_swap++; return set_ref_alt(&args,rec,int2nt(revint(ib)),int2nt(revint(ia)),1); } + error("FIXME: this should not happen %s:%d\n", bcf_seqname(args.hdr,rec),rec->pos+1); + } ++ else if ( args.mode==MODE_SWAP ) ++ { ++ if ( ir==ia ) return ret; ++ if ( ir==ib ) { args.nswap++; return set_ref_alt(&args,rec,int2nt(ib),int2nt(ia),1); } ++ args.nunresolved++; ++ return args.discard ? NULL : ret; ++ } + else if ( args.mode==MODE_TOP2FWD ) + { + int pair = 1 << ia | 1 << ib; +@@ -567,6 +589,7 @@ + fprintf(stderr,"NS\tnon-biallelic\t%u\n", args.nonbiallelic); + + free(args.gts); ++ free(args.bafs); + if ( args.fai ) fai_destroy(args.fai); + if ( args.i2m ) kh_destroy(i2m, args.i2m); + } diff --git a/recipes/bcftools-gtc2vcf-plugin/1.9/gtc2vcf.c.patch b/recipes/bcftools-gtc2vcf-plugin/1.9/gtc2vcf.c.patch new file mode 100644 index 0000000000000..fd43df0fc62b6 --- /dev/null +++ b/recipes/bcftools-gtc2vcf-plugin/1.9/gtc2vcf.c.patch @@ -0,0 +1,410 @@ +--- gtc2vcf-b890909/gtc2vcf.c.orig 2018-10-11 10:31:54.875895471 -0400 ++++ gtc2vcf-b890909/gtc2vcf.c 2018-10-11 10:55:39.935944745 -0400 +@@ -66,7 +66,8 @@ + else + { + int c = 0; +- for (int i=0; ifp, (void *)&idat->m_run_infos, sizeof(int32_t)); + idat->run_infos = (RunInfo *)malloc(idat->m_run_infos * sizeof(RunInfo)); +- for (int i=0; im_run_infos; i++) ++ for (i=0; im_run_infos; i++) + { + read_pfx_string(idat->fp, &idat->run_infos[i].run_time, NULL); + read_pfx_string(idat->fp, &idat->run_infos[i].block_type, NULL); +@@ -329,13 +331,14 @@ + read_bytes(idat->fp, (void *)&idat->number_toc_entries, sizeof(int32_t)); + idat->id = (uint16_t *)malloc(idat->number_toc_entries * sizeof(uint16_t)); + idat->toc = (int64_t *)malloc(idat->number_toc_entries * sizeof(int64_t)); +- for (int i=0; inumber_toc_entries; i++) ++ int i; ++ for (i=0; inumber_toc_entries; i++) + { + read_bytes(idat->fp, (void *)&idat->id[i], sizeof(uint16_t)); + read_bytes(idat->fp, (void *)&idat->toc[i], sizeof(int64_t)); + } + +- for (int i=0; inumber_toc_entries; i++) idat_read(idat, idat->id[i]); ++ for (i=0; inumber_toc_entries; i++) idat_read(idat, idat->id[i]); + + return idat; + } +@@ -358,7 +361,8 @@ + free(idat->unknown5); + free(idat->unknown6); + free(idat->unknown7); +- for (int i=0; im_run_infos; i++) ++ int i; ++ for (i=0; im_run_infos; i++) + { + free(idat->run_infos[i].run_time); + free(idat->run_infos[i].block_type); +@@ -402,7 +406,8 @@ + fprintf(stream, "Mid Blocks Count ,%d\n", idat->mid_block->item_num); + fprintf(stream, "[Assay]\n"); + fprintf(stream, "IlmnID,Sd,Mean,Nbeads\n"); +- for (int i=0; inum_snps; i++) ++ int i; ++ for (i=0; inum_snps; i++) + { + int32_t ilmn_id; + get_element(idat->ilmn_id, (void *)&ilmn_id, i); +@@ -415,14 +420,14 @@ + fprintf(stream, "%d,%d,%d,%d\n", ilmn_id, sd, mean, nbeads); + } + fprintf(stream, "[Mid Blocks]\n"); +- for (int i=0; imid_block->item_num; i++) ++ for (i=0; imid_block->item_num; i++) + { + int8_t mid_block; + get_element(idat->mid_block, (void *)&mid_block, i); + fprintf(stream, "%d\n", mid_block); + } + fprintf(stream, "[Run Infos]\n"); +- for (int i=0; im_run_infos; i++) ++ for (i=0; im_run_infos; i++) + { + fprintf(stream, "%s\t%s\t%s\t%s\t%s\n", idat->run_infos[i].run_time, idat->run_infos[i].block_type, + idat->run_infos[i].block_pars, idat->run_infos[i].block_code, idat->run_infos[i].code_version); +@@ -546,17 +551,18 @@ + static uint8_t *bpm_norm_lookups(bpm_t *bpm) + { + uint8_t sorted_norm_ids[256]; +- for (int i=0; i<256; i++) sorted_norm_ids[i] = 0xFF; +- for (int i=0; inum_loci; i++) ++ int i; ++ for (i=0; i<256; i++) sorted_norm_ids[i] = 0xFF; ++ for (i=0; inum_loci; i++) + { + int norm_id = bpm->locus_entries[i].norm_id; + sorted_norm_ids[norm_id] = norm_id; + } + int j=0; +- for (int i=0; i<256; i++) if ( sorted_norm_ids[i] != 0xFF ) sorted_norm_ids[j++] = sorted_norm_ids[i]; ++ for (i=0; i<256; i++) if ( sorted_norm_ids[i] != 0xFF ) sorted_norm_ids[j++] = sorted_norm_ids[i]; + uint8_t *norm_lookups = (uint8_t *)malloc(256 * sizeof(uint8_t *)); + memset((void *)norm_lookups, 0xFF, 256 * sizeof(uint8_t *)); +- for (int i=0; ifp, (void *)&bpm->num_loci, sizeof(int32_t)); + read_array(bpm->fp, (void **)&bpm->indexes, NULL, bpm->num_loci, sizeof(int32_t), 0); + bpm->names = (char **)malloc(bpm->num_loci * sizeof(char *)); +- for (int i=0; inum_loci; i++) read_pfx_string(bpm->fp, &bpm->names[i], NULL); ++ int i; ++ for (i=0; inum_loci; i++) read_pfx_string(bpm->fp, &bpm->names[i], NULL); + read_array(bpm->fp, (void **)&bpm->norm_ids, NULL, bpm->num_loci, sizeof(uint8_t), 0); + + bpm->locus_entries = (LocusEntry *)malloc(bpm->num_loci * sizeof(LocusEntry)); + LocusEntry locus_entry; +- for (int i=0; inum_loci; i++) ++ for (i=0; inum_loci; i++) + { + memset(&locus_entry, 0, sizeof(LocusEntry)); + locusentry_read(&locus_entry, bpm->fp); +@@ -599,14 +606,14 @@ + memcpy(&bpm->locus_entries[ idx ], &locus_entry, sizeof(LocusEntry)); + } + bpm->norm_lookups = bpm_norm_lookups(bpm); +- for (int i=0; inum_loci; i++) ++ for (i=0; inum_loci; i++) + { + if ( i != bpm->locus_entries[i].index - 1 ) error("Manifest format error: read invalid number of assay entries\n"); + } + + read_bytes(bpm->fp, (void *)&bpm->m_header, sizeof(int32_t)); + bpm->header = (char **)malloc(bpm->m_header * sizeof(char *)); +- for (int i=0; im_header; i++) read_pfx_string(bpm->fp, &bpm->header[i], NULL); ++ for (i=0; im_header; i++) read_pfx_string(bpm->fp, &bpm->header[i], NULL); + + if ( !heof(bpm->fp) ) error("BPM reader did not reach the end of file %s at position %ld\n", bpm->fn, htell(bpm->fp)); + +@@ -621,13 +628,14 @@ + free(bpm->manifest_name); + free(bpm->control_config); + free(bpm->indexes); ++ int i; + if ( bpm->names ) + { +- for (int i=0; inum_loci; i++) free(bpm->names[i]); ++ for (i=0; inum_loci; i++) free(bpm->names[i]); + free(bpm->names); + } + free(bpm->norm_ids); +- for (int i=0; inum_loci; i++) ++ for (i=0; inum_loci; i++) + { + free(bpm->locus_entries[i].ilmn_id); + free(bpm->locus_entries[i].name); +@@ -650,7 +658,7 @@ + } + free(bpm->locus_entries); + free(bpm->norm_lookups); +- for (int i=0; im_header; i++) free(bpm->header[i]); ++ for (i=0; im_header; i++) free(bpm->header[i]); + free(bpm->header); + free(bpm); + } +@@ -664,9 +672,10 @@ + + static void bpm_to_csv(const bpm_t *bpm, FILE *stream) + { +- for (int i=0; im_header; i++) fprintf(stream, "%s\n", bpm->header[i]); ++ int i; ++ for (i=0; im_header; i++) fprintf(stream, "%s\n", bpm->header[i]); + fprintf(stream, "Index,NormID,IlmnID,Name,IlmnStrand,SNP,AddressA_ID,AlleleA_ProbeSeq,AddressB_ID,AlleleB_ProbeSeq,GenomeBuild,Chr,MapInfo,Ploidy,Species,Source,SourceVersion,SourceStrand,SourceSeq,TopGenomicSeq,BeadSetID,Exp_Clusters,Intensity_Only,Assay_Type,Frac A,Frac C,Frac G,Frac T,RefStrand\n"); +- for (int i=0; inum_loci; i++) ++ for (i=0; inum_loci; i++) + { + LocusEntry *locus_entry = &bpm->locus_entries[i]; + fprintf(stream, "%d,%d,%s,%s,%s,%s,%010d,,%010d,,%s,%s,%s,%s,%s,%s,,%s,,,,%d,%d,%d,%f,%f,%f,%f,%s\n", +@@ -813,7 +822,8 @@ + int moff = 0, *off = NULL; + bpm->m_header = ksplit_core(str.s, '\n', &moff, &off); + bpm->header = (char **)malloc(bpm->m_header * sizeof(char *)); +- for (int i=0; im_header; i++) bpm->header[i] = strdup(&str.s[off[i]]); ++ int i; ++ for (i=0; im_header; i++) bpm->header[i] = strdup(&str.s[off[i]]); + free(off); + + str.l = 0; +@@ -851,7 +861,7 @@ + tsv_register(tsv, "RefStrand", tsv_read_string, &locus_entry.ref_strand); + + bpm->locus_entries = (LocusEntry *)malloc(bpm->num_loci * sizeof(LocusEntry)); +- for (int i=0; inum_loci; i++) ++ for (i=0; inum_loci; i++) + { + memset(&locus_entry, 0, sizeof(LocusEntry)); + locus_entry.norm_id = 0xFF; +@@ -959,6 +969,7 @@ + egt_t *egt = (egt_t *)calloc(1, sizeof(egt_t)); + egt->fn = strdup(fn); + egt->fp = hopen(egt->fn, "rb"); ++ int i; + if ( egt->fp == NULL ) error("Could not open %s\n", egt->fn); + if ( is_gzip(egt->fp) ) error("File %s is gzip compressed and currently cannot be seeked\n", egt->fn); + +@@ -982,21 +993,21 @@ + + read_bytes(egt->fp, (void *)&egt->num_records, sizeof(int32_t)); + egt->cluster_records = (ClusterRecord *)malloc(egt->num_records * sizeof(ClusterRecord)); +- for (int i=0; inum_records; i++) clusterrecord_read(&egt->cluster_records[i], egt->fp); +- for (int i=0; inum_records; i++) clusterscore_read(&egt->cluster_records[i].cluster_score, egt->fp); ++ for (i=0; inum_records; i++) clusterrecord_read(&egt->cluster_records[i], egt->fp); ++ for (i=0; inum_records; i++) clusterscore_read(&egt->cluster_records[i].cluster_score, egt->fp); + + // toss useless strings such as aa_ab_bb/aa_ab/aa_bb/ab_bb +- for (int i=0; inum_records; i++) read_pfx_string(egt->fp, NULL, NULL); ++ for (i=0; inum_records; i++) read_pfx_string(egt->fp, NULL, NULL); + + egt->loci_names = (char **)malloc(egt->num_records * sizeof(char *)); +- for (int i=0; inum_records; i++) ++ for (i=0; inum_records; i++) + { + read_pfx_string(egt->fp, &egt->loci_names[i], NULL); + } +- for (int i=0; inum_records; i++) read_bytes(egt->fp, (void *)&egt->cluster_records[i].address, sizeof(int32_t)); ++ for (i=0; inum_records; i++) read_bytes(egt->fp, (void *)&egt->cluster_records[i].address, sizeof(int32_t)); + + int32_t aa_n, ab_n, bb_n; +- for (int i=0; inum_records; i++) ++ for (i=0; inum_records; i++) + { + read_bytes(egt->fp, (void *)&aa_n, sizeof(int32_t)); + read_bytes(egt->fp, (void *)&ab_n, sizeof(int32_t)); +@@ -1025,7 +1036,8 @@ + free(egt->date_created); + free(egt->manifest_name); + free(egt->cluster_records); +- for (int i=0; inum_records; i++) free(egt->loci_names[i]); ++ int i; ++ for (i=0; inum_records; i++) free(egt->loci_names[i]); + free(egt->loci_names); + free(egt); + } +@@ -1056,7 +1068,8 @@ + fprintf(stream, "Records Count ,%d\n", egt->num_records); + fprintf(stream, "[Assay]\n"); + fprintf(stream, "Name,AA.N,AA.R_dev,AA.R_mean,AA.Theta_dev,AA.Theta_mean,AB.N,AB.R_dev,AB.R_mean,AB.Theta_dev,AB.Theta_mean,BB.N,BB.R_dev,BB.R_mean,BB.Theta_dev,BB.Theta_mean,Intensity Threshold,Cluster Separation,GenTrain Score,Original Score,Edited,Address\n"); +- for (int i=0; inum_records; i++) ++ int i; ++ for (i=0; inum_records; i++) + { + ClusterRecord *cluster_record = &egt->cluster_records[i]; + fprintf(stream, "%s,%d,%f,%f,%f,%f,%d,%f,%f,%f,%f,%d,%f,%f,%f,%f,%f,%f,%f,%f,%d,%d\n", +@@ -1341,17 +1354,18 @@ + read_bytes(gtc->fp, (void *)>c->number_toc_entries, sizeof(int32_t)); + gtc->id = (uint16_t *)malloc(gtc->number_toc_entries * sizeof(uint16_t)); + gtc->toc = (int32_t *)malloc(gtc->number_toc_entries * sizeof(int32_t)); +- for (int i=0; inumber_toc_entries; i++) ++ int i; ++ for (i=0; inumber_toc_entries; i++) + { + read_bytes(gtc->fp, (void *)>c->id[i], sizeof(uint16_t)); + read_bytes(gtc->fp, (void *)>c->toc[i], sizeof(int32_t)); + } + +- for (int i=0; inumber_toc_entries; i++) gtc_read(gtc, gtc->id[i]); ++ for (i=0; inumber_toc_entries; i++) gtc_read(gtc, gtc->id[i]); + + gtc->sin_theta = (float *)malloc(gtc->m_normalization_transforms * sizeof(float)); + gtc->cos_theta = (float *)malloc(gtc->m_normalization_transforms * sizeof(float)); +- for (int i=0; im_normalization_transforms; i++) ++ for (i=0; im_normalization_transforms; i++) + { + gtc->sin_theta[i] = sinf(gtc->normalization_transforms[i].theta); + gtc->cos_theta[i] = cosf(gtc->normalization_transforms[i].theta); +@@ -1450,7 +1464,8 @@ + fprintf(stream, "SNP Count ,%d\n", gtc->num_snps); + fprintf(stream, "[Assay]\n"); + fprintf(stream, "Raw X,Raw Y,GType,Top Alleles,Score,B Allele Freq,Log R Ratio\n"); +- for (int i=0; inum_snps; i++) ++ int i; ++ for (i=0; inum_snps; i++) + { + uint16_t raw_x = 0, raw_y = 0; + get_element(gtc->raw_x, (void *)&raw_x, i); +@@ -1468,7 +1483,7 @@ + } + fprintf(stream, "[Normalization Transforms]\n"); + fprintf(stream, "Version,Offset X,Offset Y,Scale X,Scale Y,Shear,Theta\n"); +- for (int i=0; im_normalization_transforms; i++) ++ for (i=0; im_normalization_transforms; i++) + { + fprintf(stream, "%d,%f,%f,%f,%f,%f,%f\n", + gtc->normalization_transforms[i].version, +@@ -1595,11 +1610,13 @@ + { + // print header + fprintf(stream, "Index\tName\tAddress\tChr\tPosition\tGenTrain Score\tFrac A\tFrac C\tFrac G\tFrac T"); +- for (int i=0; isample_name, gtc[i]->sample_name, gtc[i]->sample_name, gtc[i]->sample_name, gtc[i]->sample_name, gtc[i]->sample_name, gtc[i]->sample_name, gtc[i]->sample_name); ++ int i; ++ for (i=0; isample_name, gtc[i]->sample_name, gtc[i]->sample_name, gtc[i]->sample_name, gtc[i]->sample_name, gtc[i]->sample_name, gtc[i]->sample_name, gtc[i]->sample_name); + fprintf(stream, "\n"); + + // print loci +- for (int j=0; jnum_loci; j++) ++ int j; ++ for (j=0; jnum_loci; j++) + { + fprintf(stream, "%d\t%s\t%d\t%s\t%s\t%f\t%f\t%f\t%f\t%f", bpm->indexes[j], + bpm->names[j], +@@ -1611,7 +1628,7 @@ + bpm->locus_entries[j].frac_c, + bpm->locus_entries[j].frac_g, + bpm->locus_entries[j].frac_t); +- for (int i=0; igenotypes, (void *)&genotype, j); +@@ -1663,7 +1680,8 @@ + { + bcf_hdr_t *hdr = bcf_hdr_init("w"); + int n = faidx_nseq(fai); +- for (int i=0; inum_loci; j++) ++ int j; ++ for (j=0; jnum_loci; j++) + { + bcf_clear(rec); + rec->rid = bcf_hdr_name2id_flexible(hdr, bpm->locus_entries[j].chrom); +@@ -1721,7 +1740,8 @@ + b_top[0] = revnt(b_top[0]); + } + bcf_update_alleles(hdr, rec, alleles, 2); +- for (int i=0; igenotypes, (void *)&genotype, j); +@@ -1927,7 +1947,8 @@ + int moff = 0, *off = NULL, ncols = ksplit_core(line.s, '\t', &moff, &off); + kstring_t str = {0, 0, NULL}; + int *col2sample = (int *) malloc(sizeof(int)*ncols); +- for (int i=0; i0 ) ksprintf(&str, ","); +@@ -2144,7 +2165,8 @@ + { + int flags = 0, n; + char **tags = hts_readlist(str, 0, &n); +- for (int i=0; ifn, '/'); + char *str = ptr ? ptr+1 : gtc[i]->fn; +@@ -2376,10 +2399,10 @@ + bpm_destroy(bpm); + if ( gtc_list ) + { +- for (int i=0; i