diff --git a/README b/README new file mode 100644 index 0000000..6459c8c --- /dev/null +++ b/README @@ -0,0 +1,248 @@ +Sequence to Medical Phenotypes (STMP) is a pipeline featuring variant annotation, prioritization, pharmacogenomics, and tools for analyzing genomic trios (mother, father, child). + +**Release versions can be downloaded from https://github.com/AshleyLab/stmp/releases.** + +The toolkit currently uses an SQLite database for added portability. + +External Dependencies (to be placed in the "third_party" folder -- see instructions below): +- ANNOVAR version 2015-03-22 15:29:59 (Sun, 22 Mar 2015) +- snpEFF version 4.1e (build 2015-05-02) + +Other versions of the above tools may also work but are not currently supported. + +Other dependencies (these must be in the user or system PATH before running STMP) +- bcftools version 1.2 +- bedtools version 2.17.0 + +Python dependencies +- Pyyaml version 3.11 + +----------------------------------------------------------- +Installation Instructions + +Downloading software and dependencies +- Download the STMP release from here (https://github.com/AshleyLab/stmp/releases). +- Download ANNOVAR (http://annovar.openbioinformatics.org/en/latest/user-guide/download/) and snpEFF (http://sourceforge.net/projects/snpeff/files/snpEff_latest_core.zip/download) and make sure they are copied/symlinked in a folder called "annovar" and "snpeff" within the third_party folder. + E.g. ANNOVAR would be linked/copied to third_party/annovar (this folder should contain all files from the ANNOVAR download, including annotate_variation.pl and table_annovar.pl) + E.g. snpeff would be linked/copied as third_party/snpeff/snpEff (this folder should include files such as snpEff.jar) +- Ensure Pyyaml is installed (via pip install, etc.) +- Ensure bedtools version 2.17.0 and bcftools are installed and in the user/system PATH. These can be either downloaded directly from the corresponding websites or installed via a program such as bcbio. +- Run the appropriate ANNOVAR command to download the datasets specified in Appendix 1 (e.g. "annotate_variation.pl -buildver hg19 -downdb -webfrom annovar refGene humandb/" from within third_party/annovar to download the refGene dataset). + +- If you would like to run trio tools: + - Copy stable/code/trio/annovar/summarize_annovarRDv2.pl to third_party/annovar + - Run the appropriate ANNOVAR command to download the datasets specified in Appendix 2 (e.g. "annotate_variation.pl -buildver hg19 -downdb -webfrom annovar refGene humandb/" from within third_party/annovar to download the refGene dataset). + + +Setting up STMP +- Run "python stmp.py --db_update". This will create a SQLite database file in the db folder and download and import the core datasets required for annotation and tiering. + + +----------------------------------------------------------- +Running STMP +- To run STMP on an input VCF: +python stmp.py --vcf=(path to input VCF) --output_dir=(output directory) + +Example (cd to the unzipped STMP release folder you downloaded): +python stable/code/stmp.py --vcf=sample_input_data/genome_in_a_bottle/subset.rs.vcf --output_dir=sample_outputs/genome_in_a_bottle_output + +This will run three different modules: annotation, tiering, and pharmacogenomics (pgx). + +1) Annotation +This module annotates the input VCF with information from each of the above datasets. It outputs a TSV (tab-separated values) file with each annotation as a separate column (after the standard VCF columns). Annotation includes point annotation, functional annotation (using ANNOVAR and SnpEff), and region (range) annotation using bedtools. Intermediate outputs of specific annotations (e.g. point annotations) are available in the scratch folder within the output directory. The final output (each of these three annotation types joined into a single file) is written as a .tsv file in the specified output directory. + +2) Tiering +This module takes the annotated TSV from the previous step and prioritizes the variants into different tiers (below). In addition to outputting a text file with tiering metrics (tiering_allvars.metrics), it outputs text files for each tier (tiering_allvars.tier0.txt, tiering_allvars.tier1.txt, etc.). + +Tier 0: Variants classified as pathogenic or likely pathogenic according to ClinVar. + +Tier 1: Loss of function variants (splice dinucleotide disrupting, nonsense, nonstop, and frameshift indels. + +Tier 2: All rare variants cataloged in HGMD, regardless of functional annotation. Rarity is defined as minor allele frequency (MAF) no greater than 1% by default or according to use-defined criteria in any of the following population genetic surveys: ethnically- matched population in HapMap 2 and 3, the 1000 genomes phase 1 data33 from an ethnically-matched super population, and global allele frequency, the 1000 genomes pilot 1 project global allele frequency, 69 publicly available genomes released by Complete Genomics, and the NHLBI Grand Opportunity exome sequencing project global allele frequency. + +Tier 3: All non-rare missense and non-frameshift indels. + +Tier 4: All variants not meeting criteria for tiers 1-3. + + +3) Pharmacogenomics (pgx) +This module takes in a VCF file and outputs several text files summarizing variants with known pharmacogenomic effects. These include effects on drug dosage, efficacy, toxicity, and other interactions, as well as whether any variants in the input file match known "star" alleles associated with clinical drug response for 6 genes (CYP2C19, CYP2C9, CYP2D6, SLCO1B1, TPMT, VKORC1). Each of these files is output in the specified output directory. + +For additional options, run "python stmp.py -h". For example, one can use the "--annotate_only" flag to run only the annotation module, the "--tiering_only" flag to run just the tiering module, or the "--pgx_only" flag to run just the pgx module. Note that tiering depends on the annotated output file, so annotation must be run before tiering. + + +4) Trio (separate script) +This module analyzes genome sequence data from a father, mother, and child. It takes as input a single VCF with different sample IDs for mother, father, and child. + +Usage: +python trio/trioPipeline.py input output path_to_annovar path_to_matrix offspringID fatherID motherID + +Example: +(Note: as the combined file is large, you must download the HG002, HG003, and HG004 VCFs from this site (ftp://ftp-trace.ncbi.nlm.nih.gov/giab/ftp/data/AshkenazimTrio/analysis/NIST_CallsIn2Technologies_05182015/) and manually combine them into a single VCF file using bcftools or similar. The sample command below assumes you have placed the combined file in the sample_input_data/genome_in_a_bottle/trio directory and called it trio.combined.vcf.) + +python stable/code/trio/trioPipeline.py sample_input_data/genome_in_a_bottle/trio/trio.combined.vcf sample_outputs/trio_output/ third_party/annovar/ stable/code/trio/ HG002 HG003 HG004 + + +----------------------------------------------------------- +Customization +- Different datasets can be imported and used for annotation. To import additional datasets, modify stable/code/config/datasets.yml to add information about the desired datasets. It is recommended that you make a backup copy of this file before modifying. Alternately, you can copy this file to a different location and use the --config flag to run stmp with it (e.g. python stmp.py --config=(path to YAML file)). For more information and examples regarding how to specify dataset information, see the specification file at stable/code/config/datasets_spec.yml and the existing datasets in stable/code/config/datasets.yml. + + +----------------------------------------------------------- +Acknowledgement + +When using this tool in published works, please cite the below publication: + +Dewey, F., et al. "Sequence to medical phenotypes: a framework for interpretation of human whole genome DNA sequence data." PLOS Genetics, 2015. + + +----------------------------------------------------------- +Appendices + + +Appendix 1: List of ANNOVAR datasets to download for functional annotation +GRCh37_MT_ensGeneMrna.fa +GRCh37_MT_ensGene.txt +hg19_example_db_generic.txt +hg19_example_db_gff3.txt +hg19_kgXref.txt +hg19_knownGeneMrna.fa +hg19_knownGene.txt +hg19_MT_ensGeneMrna.fa +hg19_MT_ensGene.txt +hg19_refGeneMrna.fa +hg19_refGene.txt +hg19_wgEncodeGencodeBasicV19Mrna.fa +hg19_wgEncodeGencodeBasicV19.txt + + + +Appendix 2: List of ANNOVAR datasets to download for trio tools +decipher_chr.txt +decipher_copy_edit10.txt +decipher_gff.txt +ex1.human.log +galaxy_gff3.txt +gff3test.txt +gt_gff_test.txt +hapmap_3.3.hg19_all.sites.txt +hg18_cytoBand.txt +hg18_example_db_generic.txt +hg18_example_db_gff3.txt +hg18_refGeneMrna.fa +hg18_refGene.txt +hg18_refLink.txt +hg19_AFR.sites.2012_04.txt +hg19_AFR.sites.2012_04.txt.idx +hg19_ALL.sites.2010_11.txt +hg19_ALL.sites.2011_05.txt +hg19_ALL.sites.2011_05.txt.idx +hg19_ALL.sites.2012_02.txt +hg19_ALL.sites.2012_02.txt.idx +hg19_ALL.sites.2012_04.txt +hg19_ALL.sites.2012_04.txt.idx +hg19_AMR.sites.2012_04.txt +hg19_AMR.sites.2012_04.txt.idx +hg19_ASN.sites.2012_04.txt +hg19_ASN.sites.2012_04.txt.idx +hg19_avsift.txt +hg19_avsift.txt.idx +hg19_cg46.txt +hg19_cg46.txt.idx +hg19_cg69.txt +hg19_cg69.txt.idx +hg19.clinvar.2.18.13.txt +hg19_clinvarRegion.txt +hg19_clinvarUrl.txt +hg19_cosmic61.txt +hg19_cosmic61.txt.idx +hg19_cpgIslandExt.txt +hg19_dgv.txt +hg19_ensemblPseudogene.txt +hg19_ensGeneMrna.fa +hg19_ensGene.txt +hg19_esp5400_aa.txt +hg19_esp5400_aa.txt.idx +hg19_esp5400_all.txt +hg19_esp5400_all.txt.idx +hg19_esp5400_ea.txt +hg19_esp5400_ea.txt.idx +hg19_esp6500_aa.txt +hg19_esp6500_aa.txt.idx +hg19_esp6500_all.txt +hg19_esp6500_all.txt.idx +hg19_esp6500_ea.txt +hg19_esp6500_ea.txt.idx +hg19_esp6500si_aa.txt +hg19_esp6500si_aa.txt.idx +hg19_esp6500si_all.txt +hg19_esp6500si_all.txt.idx +hg19_esp6500si_ea.txt +hg19_esp6500si_ea.txt.idx +hg19_EUR.sites.2012_04.txt +hg19_EUR.sites.2012_04.txt.idx +hg19_evofold.txt +hg19_geneReviews.txt +hg19_genomicSuperDups.txt +hg19_gerp++gt2.txt +hg19_gerp++gt2.txt.idx +hg19_gwasCatalog.txt +hg19.hapmap2and3_ASW.txt +hg19.hapmap2and3_CEU.txt +hg19.hapmap2and3_CHB.txt +hg19.hapmap2and3_CHD.txt +hg19.hapmap2and3_GIH.txt +hg19.hapmap2and3_JPT.txt +hg19.hapmap2and3_LWK.txt +hg19.hapmap2and3_MEX.txt +hg19.hapmap2and3_MKK.txt +hg19.hapmap2and3_TSI.txt +hg19.hapmap2and3_YRI.txt +hg19_kgXref.txt +hg19_knownBiocyc.txt +hg19_knownGeneCEU.fa +hg19_knownGeneMrna.fa +hg19_knownGene.txt +hg19_knownGene.txt.fa +hg19_knownKegg.txt +hg19_ljb_all.txt +hg19_ljb_all.txt.idx +hg19_omimGene.txt +hg19_pgkbAnnot.txt +hg19_pgkbUrl.txt +hg19_phastConsElements46way.txt +hg19_pseudogeneYale70.txt +hg19_refGeneMrna.fa +hg19_refGene.txt +hg19_refLink.txt +hg19.regulome.cat1.txt +hg19_regulomeCat1.txt +hg19_rmsk.txt +hg19_snp130.txt +hg19_snp130.txt.idx +hg19_snp132.txt +hg19_snp135.txt +hg19_snp135.txt.idx +hg19_snp137.txt +hg19_targetScanS.txt +hg19_tfbsConsSites.txt +hg19_ucscGenePfam.txt +hg19_wgEncodeBroadHistoneGm12878H3k27acStdSig.txt +hg19_wgEncodeBroadHistoneGm12878H3k4me1StdSig.txt +hg19_wgEncodeBroadHistoneGm12878H3k4me3StdSig.txt +hg19_wgEncodeBroadHmmGm12878HMM.txt +hg19_wgEncodeBroadHmmH1hescHMM.txt +hg19_wgEncodeBroadHmmHmecHMM.txt +hg19_wgEncodeBroadHmmHsmmHMM.txt +hg19_wgEncodeBroadHmmHuvecHMM.txt +hg19_wgEncodeBroadHmmNhekHMM.txt +hg19_wgEncodeBroadHmmNhlfHMM.txt +hg19_wgEncodeGencodeCompV14Mrna.fa +hg19_wgEncodeGencodeCompV14.txt +hg19_wgEncodeGencodeManualV4.txt +hg19_wgEncodeRegDnaseClustered.txt +hg19_wgEncodeRegDnaseClusteredV2.txt +hg19_wgEncodeRegTfbsClustered.txt +hg19_wgEncodeRegTfbsClusteredV2.txt +hg19_wgRna.txt + diff --git a/README.md b/README.md deleted file mode 100644 index 9ce3eb5..0000000 --- a/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# Sequence to Medical Phenotypes (STMP) -Release versions can be downloaded from https://github.com/AshleyLab/stmp/releases. diff --git a/code/annovar/summarize_annovarRDv2.pl b/code/annovar/summarize_annovarRDv2.pl new file mode 100644 index 0000000..d8b71bd --- /dev/null +++ b/code/annovar/summarize_annovarRDv2.pl @@ -0,0 +1,993 @@ +#modified by Rick Dewey 7/31/12 to produce tab delimited output, and annotate ESP6500, HapMapII+III and all versions of 1000g available in annovar format +#!/usr/bin/perl +use warnings; +use strict; +use Pod::Usage; +use Getopt::Long; + +our $VERSION = '$Revision: 504 $'; +our $LAST_CHANGED_DATE = '$LastChangedDate: 2012-05-15 18:05:33 -0700 (Tue, 15 May 2012) $'; + +our ($verbose, $help, $man); +our ($queryfile, $dbloc); +our ($outfile, $buildver, $step, $checkfile, $remove, $verdbsnp, $ver1000g, $genetype); + +GetOptions('verbose|v'=>\$verbose, 'help|h'=>\$help, 'man|m'=>\$man, 'outfile=s'=>\$outfile, 'buildver=s'=>\$buildver, 'step=s'=>\$step, + 'checkfile!'=>\$checkfile, 'remove'=>\$remove, 'verdbsnp=i'=>\$verdbsnp, 'ver1000g=s'=>\$ver1000g, 'genetype=s'=>\$genetype,) or pod2usage (); + +$help and pod2usage (-verbose=>1, -exitval=>1, -output=>\*STDOUT); +$man and pod2usage (-verbose=>2, -exitval=>1, -output=>\*STDOUT); +@ARGV or pod2usage (-verbose=>0, -exitval=>1, -output=>\*STDOUT); +@ARGV == 2 or pod2usage ("Syntax error"); + +my $path = $0; +$path =~ s/[^\\\/]+$//; +$path and $ENV{PATH} = "$path:$ENV{PATH}"; #set up the system executable path to include the path where this program is located in + +($queryfile, $dbloc) = @ARGV; + +$outfile ||= $queryfile; +$buildver ||= 'hg18'; +$buildver eq 'hg18' or $buildver eq 'hg19' or pod2usage ("Error in argument: the --buildver argument can be 'hg18' and 'hg19' only"); +not defined $checkfile and $checkfile = 1; + +defined $verdbsnp or $verdbsnp = 130; +$genetype ||= 'refgene'; +$genetype =~ m/^refgene|knowngene|ensgene|gencodegene$/i or $genetype =~ m/wgEncodeGencode\w+$/ or pod2usage ("Error in argument: the --genetype can be 'refgene', 'knowngene', 'ensgene' or 'gencodegene' only"); + +my ($file1000g); +if (not defined $ver1000g) { + if ($buildver eq 'hg18') { + print STDERR "NOTICE: the --ver1000g argument is set as '1000g' by default\n"; + $ver1000g = '1000g'; + } elsif ($buildver eq 'hg19') { + print STDERR "NOTICE: the --ver1000g argument is set as '1000g2010nov' by default\n"; + $ver1000g = '1000g2010nov'; + } +} + +if ($genetype eq 'gencodegene') { + if ($buildver eq 'hg18') { + $genetype = 'wgEncodeGencodeManualV3'; + } elsif ($buildver eq 'hg19') { + $genetype = 'wgEncodeGencodeManualV4'; + } +} + +if ($ver1000g eq '1000g') { + $file1000g = '2009_04'; + $buildver eq 'hg18' or pod2usage ("Error in argument: the --ver1000g $ver1000g is supported only for --buildver hg18"); +} elsif ($ver1000g eq '1000g2010') { + $file1000g = '2010_03'; + $buildver eq 'hg18' or pod2usage ("Error in argument: the --ver1000g $ver1000g is supported only for --buildver hg18"); +} elsif ($ver1000g eq '1000g2010jul') { + $file1000g = '2010_07'; + $buildver eq 'hg18' or pod2usage ("Error in argument: the --ver1000g $ver1000g is supported only for --buildver hg18"); +} elsif ($ver1000g eq '1000g2010nov') { + $file1000g = '2010_11'; + $buildver eq 'hg19' or pod2usage ("Error in argument: the --ver1000g $ver1000g is supported only for --buildver hg19"); +} elsif ($ver1000g eq '1000g2011may') { + $file1000g = '2011_05'; + $buildver eq 'hg19' or pod2usage ("Error in argument: the --ver1000g $ver1000g is supported only for --buildver hg19"); +} elsif ($ver1000g eq '1000g2012feb') { + $file1000g = '2012_02'; + $buildver eq 'hg19' or pod2usage ("Error in argument: the --ver1000g $ver1000g is supported only for --buildver hg19"); +} elsif ($ver1000g =~ m/^1000g(20\d\d)([a-z]{3})_([a-z]+)$/) { + my %monthhash = ('jan'=>'01', 'feb'=>'02', 'mar'=>'03', 'apr'=>'04', 'may'=>'05', 'jun'=>'06', 'jul'=>'07', 'aug'=>'08', 'sep'=>'09', 'oct'=>'10', 'nov'=>'11', 'dec'=>'12'); + $file1000g = $1 . '_' . $monthhash{$2}; +} else { + pod2usage ("Error in argument: the --ver1000g $ver1000g is not yet supported by this program"); +} + +my %valistep; +if ($step) { + my @step = split (/,/, $step); + for my $i (0 .. @step-1) { + if ($step[$i] =~ m/^(\d+)-(\d+)$/) { + for my $nextstep ($1 .. $2) { + $valistep{$nextstep}++; + } + } elsif ($step[$i] =~ m/^(\d+)$/) { + $valistep{$1}++; + } else { + pod2usage ("Error: invalid -step argument ($step) is specified. Please use comma-separated number only (dash line such as 1-5 is accepted)"); + } + } +} else { + for my $nextstep (1..35) { + $valistep{$nextstep}++; + } +} + +$checkfile and checkFileExistence (); + + +my $sc; + +#run step 1 +if ($valistep{1}) { + $sc = "perl $path/annotate_variation.pl -geneanno -buildver $buildver -dbtype $genetype -outfile $outfile -exonsort $queryfile $dbloc"; + print STDERR "\nNOTICE: Running step 1 with system command <$sc>\n"; + system ($sc) and die "Error running system command: <$sc>\n"; +} + +#run step2 +if ($valistep{2}) { + if ($buildver eq 'hg18') { + $sc = "perl $path/annotate_variation.pl -regionanno -dbtype mce44way -buildver $buildver -outfile $outfile $queryfile $dbloc"; + print STDERR "\nNOTICE: Running step 2 with system command <$sc>\n"; + system ($sc) and die "Error running system command: <$sc>\n"; + } elsif ($buildver eq 'hg19') { + $sc = "perl $path/annotate_variation.pl -regionanno -dbtype mce46way -buildver $buildver -outfile $outfile $queryfile $dbloc"; + print STDERR "\nNOTICE: Running system command <$sc>\n"; + system ($sc) and die "Error running system command: <$sc>\n"; + } + +} + +#run step3 +if ($valistep{3}) { + $sc = "perl $path/annotate_variation.pl -regionanno -dbtype segdup -buildver $buildver -outfile $outfile $queryfile $dbloc"; + print STDERR "\nNOTICE: Running step 3 with system command <$sc>\n"; + system ($sc) and die "Error running system command: <$sc>\n"; +} + + +if ($buildver eq 'hg19') { + #run step4 + if ($valistep{4}) { + $sc = "perl $path/annotate_variation.pl -filter -dbtype generic -genericdbfile hg19.hapmap2and3_ASW.txt -buildver $buildver -outfile $outfile.hg19.hapmap_asw $queryfile $dbloc"; + print STDERR "\nNOTICE: Running step 4 with system command <$sc>\n"; + system ($sc) and die "Error running system command: <$sc>\n"; + } + + if ($valistep{5}) { + $sc = "perl $path/annotate_variation.pl -filter -dbtype generic -genericdbfile hg19.hapmap2and3_CEU.txt -buildver $buildver -outfile $outfile.hg19.hapmap_ceu $queryfile $dbloc"; + print STDERR "\nNOTICE: Running step 5 with system command <$sc>\n"; + system ($sc) and die "Error running system command: <$sc>\n"; + } + + if ($valistep{6}) { + $sc = "perl $path/annotate_variation.pl -filter -dbtype generic -genericdbfile hg19.hapmap2and3_CHB.txt -buildver $buildver -outfile $outfile.hg19.hapmap_chb $queryfile $dbloc"; + print STDERR "\nNOTICE: Running step 6 with system command <$sc>\n"; + system ($sc) and die "Error running system command: <$sc>\n"; + } + + if ($valistep{7}) { + $sc = "perl $path/annotate_variation.pl -filter -dbtype generic -genericdbfile hg19.hapmap2and3_CHD.txt -buildver $buildver -outfile $outfile.hg19.hapmap_chd $queryfile $dbloc"; + print STDERR "\nNOTICE: Running step 7 with system command <$sc>\n"; + system ($sc) and die "Error running system command: <$sc>\n"; + } + + if ($valistep{8}) { + $sc = "perl $path/annotate_variation.pl -filter -dbtype generic -genericdbfile hg19.hapmap2and3_GIH.txt -buildver $buildver -outfile $outfile.hg19.hapmap_gih $queryfile $dbloc"; + print STDERR "\nNOTICE: Running step 8 with system command <$sc>\n"; + system ($sc) and die "Error running system command: <$sc>\n"; + } + + if ($valistep{9}) { + $sc = "perl $path/annotate_variation.pl -filter -dbtype generic -genericdbfile hg19.hapmap2and3_JPT.txt -buildver $buildver -outfile $outfile.hg19.hapmap_jpt $queryfile $dbloc"; + print STDERR "\nNOTICE: Running step 9 with system command <$sc>\n"; + system ($sc) and die "Error running system command: <$sc>\n"; + } + + if ($valistep{10}) { + $sc = "perl $path/annotate_variation.pl -filter -dbtype generic -genericdbfile hg19.hapmap2and3_LWK.txt -buildver $buildver -outfile $outfile.hg19.hapmap_lwk $queryfile $dbloc"; + print STDERR "\nNOTICE: Running step 10 with system command <$sc>\n"; + system ($sc) and die "Error running system command: <$sc>\n"; + } + + if ($valistep{11}) { + $sc = "perl $path/annotate_variation.pl -filter -dbtype generic -genericdbfile hg19.hapmap2and3_MEX.txt -buildver $buildver -outfile $outfile.hg19.hapmap_mex $queryfile $dbloc"; + print STDERR "\nNOTICE: Running step 11 with system command <$sc>\n"; + system ($sc) and die "Error running system command: <$sc>\n"; + } + + if ($valistep{12}) { + $sc = "perl $path/annotate_variation.pl -filter -dbtype generic -genericdbfile hg19.hapmap2and3_MKK.txt -buildver $buildver -outfile $outfile.hg19.hapmap_mkk $queryfile $dbloc"; + print STDERR "\nNOTICE: Running step 12 with system command <$sc>\n"; + system ($sc) and die "Error running system command: <$sc>\n"; + } + + if ($valistep{13}) { + $sc = "perl $path/annotate_variation.pl -filter -dbtype generic -genericdbfile hg19.hapmap2and3_TSI.txt -buildver $buildver -outfile $outfile.hg19.hapmap_tsi $queryfile $dbloc"; + print STDERR "\nNOTICE: Running step 13 with system command <$sc>\n"; + system ($sc) and die "Error running system command: <$sc>\n"; + } + + if ($valistep{14}) { + $sc = "perl $path/annotate_variation.pl -filter -dbtype generic -genericdbfile hg19.hapmap2and3_YRI.txt -buildver $buildver -outfile $outfile.hg19.hapmap_yri $queryfile $dbloc"; + print STDERR "\nNOTICE: Running step 14 with system command <$sc>\n"; + system ($sc) and die "Error running system command: <$sc>\n"; + } + + #run step15 + if ($valistep{15}) { + $sc = "perl $path/annotate_variation.pl -filter -dbtype 1000g2010nov_all -buildver $buildver -outfile $outfile $queryfile $dbloc"; + print STDERR "\nNOTICE: Running step 15 with system command <$sc>\n"; + system ($sc) and die "Error running system command: <$sc>\n"; + } + + #run step16 + if ($valistep{16}) { + $sc = "perl $path/annotate_variation.pl -filter -dbtype 1000g2011may_all -buildver $buildver -outfile $outfile $queryfile $dbloc"; + print STDERR "\nNOTICE: Running step 16 with system command <$sc>\n"; + system ($sc) and die "Error running system command: <$sc>\n"; + } + + #run step17 + if ($valistep{17}) { + $sc = "perl $path/annotate_variation.pl -filter -dbtype 1000g2012feb_all -buildver $buildver -outfile $outfile $queryfile $dbloc"; + print STDERR "\nNOTICE: Running step 17 with system command <$sc>\n"; + system ($sc) and die "Error running system command: <$sc>\n"; + } + + #run step18 + if ($valistep{18}) { + $sc = "perl $path/annotate_variation.pl -filter -dbtype 1000g2012apr_all -buildver $buildver -outfile $outfile $queryfile $dbloc"; + print STDERR "\nNOTICE: Running step 18 with system command <$sc>\n"; + system ($sc) and die "Error running system command: <$sc>\n"; + } + + #run step19 + if ($valistep{19}) { + $sc = "perl $path/annotate_variation.pl -filter -dbtype 1000g2012apr_eur -buildver $buildver -outfile $outfile $queryfile $dbloc"; + print STDERR "\nNOTICE: Running step 19 with system command <$sc>\n"; + system ($sc) and die "Error running system command: <$sc>\n"; + } + + #run step20 + if ($valistep{20}) { + $sc = "perl $path/annotate_variation.pl -filter -dbtype 1000g2012apr_afr -buildver $buildver -outfile $outfile $queryfile $dbloc"; + print STDERR "\nNOTICE: Running step 20 with system command <$sc>\n"; + system ($sc) and die "Error running system command: <$sc>\n"; + } + + #run step21 + if ($valistep{21}) { + $sc = "perl $path/annotate_variation.pl -filter -dbtype 1000g2012apr_amr -buildver $buildver -outfile $outfile $queryfile $dbloc"; + print STDERR "\nNOTICE: Running step 21 with system command <$sc>\n"; + system ($sc) and die "Error running system command: <$sc>\n"; + } + + #run step22 + if ($valistep{22}) { + $sc = "perl $path/annotate_variation.pl -filter -dbtype 1000g2012apr_asn -buildver $buildver -outfile $outfile $queryfile $dbloc"; + print STDERR "\nNOTICE: Running step 22 with system command <$sc>\n"; + system ($sc) and die "Error running system command: <$sc>\n"; + } + + #run step23 + if ($valistep{23}) { + $sc = "perl $path/annotate_variation.pl -filter -dbtype cg46 -buildver $buildver -outfile $outfile $queryfile $dbloc"; + print STDERR "\nNOTICE: Running step 23 with system command <$sc>\n"; + system ($sc) and die "Error running system command: <$sc>\n"; + } + + #run step24 + if ($valistep{24}) { + $sc = "perl $path/annotate_variation.pl -filter -dbtype cg69 -buildver $buildver -outfile $outfile $queryfile $dbloc"; + print STDERR "\nNOTICE: Running step 24 with system command <$sc>\n"; + system ($sc) and die "Error running system command: <$sc>\n"; + } +} + +#run step25 +if ($valistep{25}) { + $sc = "perl $path/annotate_variation.pl -filter -dbtype snp$verdbsnp -buildver $buildver -outfile $outfile $queryfile $dbloc"; + print STDERR "\nNOTICE: Running step 25 with system command <$sc>\n"; + system ($sc) and die "Error running system command: <$sc>\n"; +} + +#run step26 +if ($valistep{26}) { + $sc = "perl $path/annotate_variation.pl -filter -dbtype avsift -buildver $buildver -sift 0 -outfile $outfile $queryfile $dbloc"; + print STDERR "\nNOTICE: Running step 26 with system command <$sc>\n"; + system ($sc) and die "Error running system command: <$sc>\n"; +} + +#run step27 to step31 +if ($valistep{27} or $valistep{28} or $valistep{29} or $valistep{30} or $valistep{31}) { + $sc = "perl $path/annotate_variation.pl -filter -dbtype ljb_all -buildver $buildver -outfile $outfile $queryfile $dbloc -otherinfo"; + print STDERR "\nNOTICE: Running step 27-31 with system command <$sc>\n"; + system ($sc) and die "Error running system command: <$sc>\n"; +} + +#run step32 +if ($valistep{32}) { + $sc = "perl $path/annotate_variation.pl -filter -dbtype esp6500_all -buildver $buildver -outfile $outfile $queryfile $dbloc"; + print STDERR "\nNOTICE: Running step 32 with system command <$sc>\n"; + system ($sc) and die "Error running system command: <$sc>\n"; +} + +#run step33 +if ($valistep{33}) { + $sc = "perl $path/annotate_variation.pl -filter -dbtype esp6500_ea -buildver $buildver -outfile $outfile $queryfile $dbloc"; + print STDERR "\nNOTICE: Running step 33 with system command <$sc>\n"; + system ($sc) and die "Error running system command: <$sc>\n"; +} + +#run step34 +if ($valistep{34}) { + $sc = "perl $path/annotate_variation.pl -filter -dbtype esp6500_aa -buildver $buildver -outfile $outfile $queryfile $dbloc"; + print STDERR "\nNOTICE: Running step 34 with system command <$sc>\n"; + system ($sc) and die "Error running system command: <$sc>\n"; +} + +open (FUNCTION, "$outfile.variant_function") or die "Error: cannot read from variant function file: $!\n"; + +if ($valistep{1}) { + open (STEP1, "$outfile.exonic_variant_function") or die "Error: cannot read from exonic variant function file: $!\n"; +} + +if ($valistep{2}) { + if ($buildver eq 'hg18') { + open (STEP2, "$outfile.hg18_phastConsElements44way") or die "Error: cannot read from mce file: $!\n"; + } + elsif ($buildver eq 'hg19') { + open (STEP2, "$outfile.hg19_phastConsElements46way") or die "Error: cannot read from mce file: $!\n"; + } +} + +if ($valistep{3}) { + open (STEP3, "$outfile.${buildver}_genomicSuperDups") or die "Error: cannot read from segdup file: $!\n"; +} + +if ($buildver eq 'hg19') { + if ($valistep{4}) { + open (STEP4, "$outfile.hg19.hapmap_asw.hg19_generic_dropped") or die "Error: cannot read from drop file $outfile.hg19.hapmap_asw.hg19_generic_dropped: $!\n"; + } + if ($valistep{5}) { + open (STEP5, "$outfile.hg19.hapmap_ceu.hg19_generic_dropped") or die "Error: cannot read from drop file $outfile.hg19.hapmap_ceu.hg19_generic_dropped: $!\n"; + } + if ($valistep{6}) { + open (STEP6, "$outfile.hg19.hapmap_chb.hg19_generic_dropped") or die "Error: cannot read from drop file $outfile.hg19.hapmap_chb.hg19_generic_dropped: $!\n"; + } + if ($valistep{7}) { + open (STEP7, "$outfile.hg19.hapmap_chd.hg19_generic_dropped") or die "Error: cannot read from drop file $outfile.hg19.hapmap_chd.hg19_generic_dropped: $!\n"; + } + if ($valistep{8}) { + open (STEP8, "$outfile.hg19.hapmap_gih.hg19_generic_dropped") or die "Error: cannot read from drop file $outfile.hg19.hapmap_gih.hg19_generic_dropped: $!\n"; + } + if ($valistep{9}) { + open (STEP9, "$outfile.hg19.hapmap_jpt.hg19_generic_dropped") or die "Error: cannot read from drop file $outfile.hg19.hapmap_jpt.hg19_generic_dropped: $!\n"; + } + if ($valistep{10}) { + open (STEP10, "$outfile.hg19.hapmap_lwk.hg19_generic_dropped") or die "Error: cannot read from drop file $outfile.hg19.hapmap_lwk.hg19_generic_dropped: $!\n"; + } + if ($valistep{11}) { + open (STEP11, "$outfile.hg19.hapmap_mex.hg19_generic_dropped") or die "Error: cannot read from drop file $outfile.hg19.hapmap_mex.hg19_generic_dropped: $!\n"; + } + if ($valistep{12}) { + open (STEP12, "$outfile.hg19.hapmap_mkk.hg19_generic_dropped") or die "Error: cannot read from drop file $outfile.hg19.hapmap_mkk.hg19_generic_dropped: $!\n"; + } + if ($valistep{13}) { + open (STEP13, "$outfile.hg19.hapmap_tsi.hg19_generic_dropped") or die "Error: cannot read from drop file $outfile.hg19.hapmap_tsi.hg19_generic_dropped: $!\n"; + } + if ($valistep{14}) { + open (STEP14, "$outfile.hg19.hapmap_yri.hg19_generic_dropped") or die "Error: cannot read from drop file $outfile.hg19.hapmap_yri.hg19_generic_dropped: $!\n"; + } + if ($valistep{15}) { + open (STEP15, "$outfile.hg19_ALL.sites.2010_11_dropped") or die "Error: cannot read from drop file $outfile.hg19_ALL.sites.2010_11_dropped: $!\n"; + } + if ($valistep{16}) { + open (STEP16, "$outfile.hg19_ALL.sites.2011_05_dropped") or die "Error: cannot read from drop file $outfile.hg19_ALL.sites.2011_05_dropped: $!\n"; + } + if ($valistep{17}) { + open (STEP17, "$outfile.hg19_ALL.sites.2012_02_dropped") or die "Error: cannot read from drop file $outfile.hg19_ALL.sites.2012_02_dropped: $!\n"; + } + if ($valistep{18}) { + open (STEP18, "$outfile.hg19_ALL.sites.2012_04_dropped") or die "Error: cannot read from drop file $outfile.hg19_ALL.sites.2012_04_dropped: $!\n"; + } + if ($valistep{19}) { + open (STEP19, "$outfile.hg19_EUR.sites.2012_04_dropped") or die "Error: cannot read from drop file $outfile.hg19_EUR.sites.2012_04_dropped: $!\n"; + } + if ($valistep{20}) { + open (STEP20, "$outfile.hg19_AFR.sites.2012_04_dropped") or die "Error: cannot read from drop file $outfile.hg19_AFR.sites.2012_04_dropped: $!\n"; + } + if ($valistep{21}) { + open (STEP21, "$outfile.hg19_AMR.sites.2012_04_dropped") or die "Error: cannot read from drop file $outfile.hg19_AMR.sites.2012_04_dropped: $!\n"; + } + if ($valistep{22}) { + open (STEP22, "$outfile.hg19_ASN.sites.2012_04_dropped") or die "Error: cannot read from drop file $outfile.hg19_ASN.sites.2012_04_dropped: $!\n"; + } + if ($valistep{23}) { + open (STEP23, "$outfile.hg19_cg46_dropped") or die "Error: cannot read from drop file $outfile.hg19_cg46_dropped: $!\n"; + } + if ($valistep{24}) { + open (STEP24, "$outfile.hg19_cg69_dropped") or die "Error: cannot read from drop file $outfile.hg19_cg69_dropped: $!\n"; + } +} +else { + if ($valistep{4}) { + open (STEP4, "$outfile.hg18_CEU.sites.${file1000g}_dropped") or die "Error: cannot read from drop file $outfile.hg18_CEU.sites.${file1000g}_dropped: $!\n"; + } + if ($valistep{5}) { + open (STEP5, "$outfile.hg18_YRI.sites.${file1000g}_dropped") or die "Error: cannot read from drop file $outfile.hg18_YRI.sites.${file1000g}_dropped: $!\n"; + } + if ($valistep{6}) { + open (STEP6, "$outfile.hg18_JPTCHB.sites.${file1000g}_dropped") or die "Error: cannot read from drop file $outfile.hg18_JPTCHB.sites.${file1000g}_dropped: $!\n"; + } +} + +if ($valistep{25}) { + open (STEP25, "$outfile.${buildver}_snp${verdbsnp}_dropped") or die "Error: cannot read from snp$verdbsnp drop file: $!\n"; +} + +if ($valistep{26}) { + open (STEP26, "$outfile.${buildver}_avsift_dropped") or die "Error: cannot read from avsift drop file: $!\n"; +} + +if ($valistep{27} or $valistep{28} or $valistep{29} or $valistep{30} or $valistep{31}) { + open (STEP27, "$outfile.${buildver}_ljb_all_dropped") or die "Error: cannot read from ljb_all drop file: $!\n"; +} + +if ($valistep{32}) { + open (STEP32, "$outfile.${buildver}_esp6500_all_dropped") or die "Error: cannot read from esp6500_all drop file: $!\n"; +} + +if ($valistep{33}) { + open (STEP33, "$outfile.${buildver}_esp6500_ea_dropped") or die "Error: cannot read from esp6500_ea drop file: $!\n"; +} + +if ($valistep{34}) { + open (STEP34, "$outfile.${buildver}_esp6500_aa_dropped") or die "Error: cannot read from esp6500_aa drop file: $!\n"; +} + +=head1 +if ($valistep{11}) { + open (STEP11, "$outfile.${buildver}_ljb_pp2_dropped") or die "Error: cannot read from ljb_pp2 drop file: $!\n"; +} + +if ($valistep{12}) { + open (STEP12, "$outfile.${buildver}_ljb_phylop_dropped") or die "Error: cannot read from ljb_phylop drop file: $!\n"; +} + +if ($valistep{13}) { + open (STEP13, "$outfile.${buildver}_ljb_mt_dropped") or die "Error: cannot read from ljb_mt drop file: $!\n"; +} + +if ($valistep{14}) { + open (STEP14, "$outfile.${buildver}_ljb_lrt_dropped") or die "Error: cannot read from ljb_lrt drop file: $!\n"; +} + +if ($valistep{15}) { + open (STEP15, "$outfile.${buildver}_ljb_gerp++_dropped") or die "Error: cannot read from ljb_gerp++ drop file: $!\n"; +} +=cut + + + +my (@allstep); +for my $i (1 .. 3) { + $allstep[$i] = []; +} + +if ($buildver eq 'hg19') { + if ($valistep{4}) { + while () { + m/^generic\t(\S+)\t(\S+\s+\S+\s+\S+\s+\S+\s+\S+)/ or die "Error: invalid record found in annovar outputfile 4 : <$_>\n"; + $allstep[4]->{$2} = ($1>0.01)?sprintf("%.2f", $1):$1; + } + } + if ($valistep{5}) { + while () { + m/^generic\t(\S+)\t(\S+\s+\S+\s+\S+\s+\S+\s+\S+)/ or die "Error: invalid record found in annovar outputfile 5 : <$_>\n"; + $allstep[5]->{$2} = ($1>0.01)?sprintf("%.2f", $1):$1; + } + } + if ($valistep{6}) { + while () { + m/^generic\t(\S+)\t(\S+\s+\S+\s+\S+\s+\S+\s+\S+)/ or die "Error: invalid record found in annovar outputfile 6 : <$_>\n"; + $allstep[6]->{$2} = ($1>0.01)?sprintf("%.2f", $1):$1; + } + } + if ($valistep{7}) { + while () { + m/^generic\t(\S+)\t(\S+\s+\S+\s+\S+\s+\S+\s+\S+)/ or die "Error: invalid record found in annovar outputfile 7 : <$_>\n"; + $allstep[7]->{$2} = ($1>0.01)?sprintf("%.2f", $1):$1; + } + } + if ($valistep{8}) { + while () { + m/^generic\t(\S+)\t(\S+\s+\S+\s+\S+\s+\S+\s+\S+)/ or die "Error: invalid record found in annovar outputfile 8 : <$_>\n"; + $allstep[8]->{$2} = ($1>0.01)?sprintf("%.2f", $1):$1; + } + } + if ($valistep{9}) { + while () { + m/^generic\t(\S+)\t(\S+\s+\S+\s+\S+\s+\S+\s+\S+)/ or die "Error: invalid record found in annovar outputfile 9 : <$_>\n"; + $allstep[9]->{$2} = ($1>0.01)?sprintf("%.2f", $1):$1; + } + } + if ($valistep{10}) { + while () { + m/^generic\t(\S+)\t(\S+\s+\S+\s+\S+\s+\S+\s+\S+)/ or die "Error: invalid record found in annovar outputfile 10 : <$_>\n"; + $allstep[10]->{$2} = ($1>0.01)?sprintf("%.2f", $1):$1; + } + } + if ($valistep{11}) { + while () { + m/^generic\t(\S+)\t(\S+\s+\S+\s+\S+\s+\S+\s+\S+)/ or die "Error: invalid record found in annovar outputfile 11 : <$_>\n"; + $allstep[11]->{$2} = ($1>0.01)?sprintf("%.2f", $1):$1; + } + } + if ($valistep{12}) { + while () { + m/^generic\t(\S+)\t(\S+\s+\S+\s+\S+\s+\S+\s+\S+)/ or die "Error: invalid record found in annovar outputfile 12 : <$_>\n"; + $allstep[12]->{$2} = ($1>0.01)?sprintf("%.2f", $1):$1; + } + } + if ($valistep{13}) { + while () { + m/^generic\t(\S+)\t(\S+\s+\S+\s+\S+\s+\S+\s+\S+)/ or die "Error: invalid record found in annovar outputfile 13 : <$_>\n"; + $allstep[13]->{$2} = ($1>0.01)?sprintf("%.2f", $1):$1; + } + } + if ($valistep{14}) { + while () { + m/^generic\t(\S+)\t(\S+\s+\S+\s+\S+\s+\S+\s+\S+)/ or die "Error: invalid record found in annovar outputfile 14 : <$_>\n"; + $allstep[14]->{$2} = ($1>0.01)?sprintf("%.2f", $1):$1; + } + } + if ($valistep{15}) { + while () { + m/^1000g2010nov_all\t(\S+)\t(\S+\s+\S+\s+\S+\s+\S+\s+\S+)/ or die "Error: invalid record found in annovar outputfile 15 : <$_>\n"; + $allstep[15]->{$2} = ($1>0.01)?sprintf("%.2f", $1):$1; + } + } + if ($valistep{16}) { + while () { + m/^1000g2011may_all\t(\S+)\t(\S+\s+\S+\s+\S+\s+\S+\s+\S+)/ or die "Error: invalid record found in annovar outputfile 16 : <$_>\n"; + $allstep[16]->{$2} = ($1>0.01)?sprintf("%.2f", $1):$1; + } + } + if ($valistep{17}) { + while () { + m/^1000g2012feb_all\t(\S+)\t(\S+\s+\S+\s+\S+\s+\S+\s+\S+)/ or die "Error: invalid record found in annovar outputfile 17 : <$_>\n"; + $allstep[17]->{$2} = ($1>0.01)?sprintf("%.2f", $1):$1; + } + } + if ($valistep{18}) { + while () { + m/^1000g2012apr_all\t(\S+)\t(\S+\s+\S+\s+\S+\s+\S+\s+\S+)/ or die "Error: invalid record found in annovar outputfile 18 : <$_>\n"; + $allstep[18]->{$2} = ($1>0.01)?sprintf("%.2f", $1):$1; + } + } + if ($valistep{19}) { + while () { + m/^1000g2012apr_eur\t(\S+)\t(\S+\s+\S+\s+\S+\s+\S+\s+\S+)/ or die "Error: invalid record found in annovar outputfile 19 : <$_>\n"; + $allstep[19]->{$2} = ($1>0.01)?sprintf("%.2f", $1):$1; + } + } + if ($valistep{20}) { + while () { + m/^1000g2012apr_afr\t(\S+)\t(\S+\s+\S+\s+\S+\s+\S+\s+\S+)/ or die "Error: invalid record found in annovar outputfile 20 : <$_>\n"; + $allstep[20]->{$2} = ($1>0.01)?sprintf("%.2f", $1):$1; + } + } + if ($valistep{21}) { + while () { + m/^1000g2012apr_amr\t(\S+)\t(\S+\s+\S+\s+\S+\s+\S+\s+\S+)/ or die "Error: invalid record found in annovar outputfile 21 : <$_>\n"; + $allstep[21]->{$2} = ($1>0.01)?sprintf("%.2f", $1):$1; + } + } + if ($valistep{22}) { + while () { + m/^1000g2012apr_asn\t(\S+)\t(\S+\s+\S+\s+\S+\s+\S+\s+\S+)/ or die "Error: invalid record found in annovar outputfile 22 : <$_>\n"; + $allstep[22]->{$2} = ($1>0.01)?sprintf("%.2f", $1):$1; + } + } + if ($valistep{23}) { + while () { + m/^cg46\t(\S+)\t(\S+\s+\S+\s+\S+\s+\S+\s+\S+)/ or die "Error: invalid record found in annovar outputfile 23 : <$_>\n"; + $allstep[23]->{$2} = ($1>0.01)?sprintf("%.2f", $1):$1; + } + } + if ($valistep{24}) { + while () { + m/^cg69\t(\S+)\t(\S+\s+\S+\s+\S+\s+\S+\s+\S+)/ or die "Error: invalid record found in annovar outputfile 24 : <$_>\n"; + $allstep[24]->{$2} = ($1>0.01)?sprintf("%.2f", $1):$1; + } + } +} +else { + if ($valistep{4}) { + while () { + m/^1000g\w*_ceu\t(\S+)\t(\S+\s+\S+\s+\S+\s+\S+\s+\S+)/ or die "Error: invalid record found in annovar outputfile 4 : <$_>\n"; + $allstep[4]->{$2} = ($1>0.01)?sprintf("%.2f", $1):$1; + } + } + + if ($valistep{5}) { + while () { + m/^1000g\w*_yri\t(\S+)\t(\S+\s+\S+\s+\S+\s+\S+\s+\S+)/ or die "Error: invalid record found in annovar outputfile 5 : <$_>\n"; + $allstep[5]->{$2} = ($1>0.01)?sprintf("%.2f", $1):$1; + } + } + + if ($valistep{6}) { + while () { + m/^1000g\w*_jptchb\t(\S+)\t(\S+\s+\S+\s+\S+\s+\S+\s+\S+)/ or die "Error: invalid record found in annovar outputfile 6 : <$_>\n"; + $allstep[6]->{$2} = ($1>0.01)?sprintf("%.2f", $1):$1; + } + } +} + +if ($valistep{25}) { + while () { + m/^snp\d+\t(\S+)\t(\S+\s+\S+\s+\S+\s+\S+\s+\S+)/ or die "Error: invalid record found in annovar outputfile 25 : <$_>\n"; + $allstep[25]->{$2} = $1; + } +} + +if ($valistep{26}) { + while () { + m/^avsift\t(\S+)\t(\S+\s+\S+\s+\S+\s+\S+\s+\S+)/ or die "Error: invalid record found in annovar outputfile 26 : <$_>\n"; + $allstep[26]->{$2} = $1; + } +} + +if ($valistep{27} or $valistep{28} or $valistep{29} or $valistep{30} or $valistep{31}) { + while () { + m/^ljb_all\t(\S+)\t(\S+\s+\S+\s+\S+\s+\S+\s+\S+)/ or die "Error: invalid record found in annovar outputfile 27 : <$_>\n"; + $allstep[27]->{$2} = $1; + } +} + +if ($valistep{32}) { + while () { + m/^esp6500_all\t(\S+)\t(\S+\s+\S+\s+\S+\s+\S+\s+\S+)/ or die "Error: invalid record found in annovar outputfile 32 : <$_>\n"; + $allstep[32]->{$2} = ($1>0.01)?sprintf("%.2f", $1):$1; + } +} + +if ($valistep{33}) { + while () { + m/^esp6500_ea\t(\S+)\t(\S+\s+\S+\s+\S+\s+\S+\s+\S+)/ or die "Error: invalid record found in annovar outputfile 33 : <$_>\n"; + $allstep[33]->{$2} = ($1>0.01)?sprintf("%.2f", $1):$1; + } +} + +if ($valistep{34}) { + while () { + m/^esp6500_aa\t(\S+)\t(\S+\s+\S+\s+\S+\s+\S+\s+\S+)/ or die "Error: invalid record found in annovar outputfile 34 : <$_>\n"; + $allstep[34]->{$2} = ($1>0.01)?sprintf("%.2f", $1):$1; + } +} + +=head1 +if ($valistep{11}) { + while () { + m/^ljb_pp2\t(\S+)\t(\S+\s+\S+\s+\S+\s+\S+\s+\S+)/ or die "Error: invalid record found in annovar outputfile 11 : <$_>\n"; + $allstep[11]->{$2} = $1; + } +} + +if ($valistep{12}) { + while () { + m/^ljb_phylop\t(\S+)\t(\S+\s+\S+\s+\S+\s+\S+\s+\S+)/ or die "Error: invalid record found in annovar outputfile 12 : <$_>\n"; + $allstep[12]->{$2} = $1; + } +} + +if ($valistep{13}) { + while () { + m/^ljb_mt\t(\S+)\t(\S+\s+\S+\s+\S+\s+\S+\s+\S+)/ or die "Error: invalid record found in annovar outputfile 13 : <$_>\n"; + $allstep[13]->{$2} = $1; + } +} + +if ($valistep{14}) { + while () { + m/^ljb_lrt\t(\S+)\t(\S+\s+\S+\s+\S+\s+\S+\s+\S+)/ or die "Error: invalid record found in annovar outputfile 14 : <$_>\n"; + $allstep[14]->{$2} = $1; + } +} + +if ($valistep{15}) { + while () { + m/^ljb_gerp\+\+\t(\S+)\t(\S+\s+\S+\s+\S+\s+\S+\s+\S+)/ or die "Error: invalid record found in annovar outputfile 15 : <$_>\n"; + $allstep[15]->{$2} = $1; + } +} +=cut + +print STDERR "NOTICE: Finished loading filterstep database file\n"; + +open (OUT, ">$outfile.genome_summary.txt") or die "Error: cannot write to output file: $!\n"; +open (OUTE, ">$outfile.exome_summary.txt") or die "Error: cannot write to output file: $!\n"; + +if ($buildver eq 'hg19') { + print OUT join ("\t", qw/Func Gene ExonicFunc AAChange Conserved SegDup/, "ESP6500_ALL", "ESP6500_EA", "ESP6500_AA", "hapmap2and3_ASW", "hapmap2and3_CEU", "hapmap2and3_CHB", "hapmap2and3_CHD", "hapmap2and3_GIH", "hapmap2and3_JPT", "hapmap2and3_LWK", "hapmap2and3_MEX", "hapmap2and3_MKK", "hapmap2and3_TSI", "hapmap2and3_YRI", "1000g2010nov_ALL", "1000g2011may_ALL", "1000g2012feb_ALL", "1000g2012apr_ALL", "1000g2012apr_EUR", "1000g2012apr_AFR", "1000g2012apr_AMR", "1000g2012apr_ASN", "cg46", "cg69", "dbSNP$verdbsnp", qw/AVSIFT LJB_PhyloP LJB_PhyloP_Pred LJB_SIFT LJB_SIFT_Pred LJB_PolyPhen2 LJB_PolyPhen2_Pred LJB_LRT LJB_LRT_Pred LJB_MutationTaster LJB_MutationTaster_Pred LJB_GERP++ Chr Start End Ref Obs Otherinfo/), "\n"; + print OUTE join ("\t", qw/Func Gene ExonicFunc AAChange Conserved SegDup/, "ESP6500_ALL", "ESP6500_EA", "ESP6500_AA", "hapmap2and3_ASW", "hapmap2and3_CEU", "hapmap2and3_CHB", "hapmap2and3_CHD", "hapmap2and3_GIH", "hapmap2and3_JPT", "hapmap2and3_LWK", "hapmap2and3_MEX", "hapmap2and3_MKK", "hapmap2and3_TSI", "hapmap2and3_YRI", "1000g2010nov_ALL", "1000g2011may_ALL", "1000g2012feb_ALL", "1000g2012apr_ALL", "1000g2012apr_EUR", "1000g2012apr_AFR", "1000g2012apr_AMR", "1000g2012apr_ASN", "cg46", "cg69", "dbSNP$verdbsnp", qw/AVSIFT LJB_PhyloP LJB_PhyloP_Pred LJB_SIFT LJB_SIFT_Pred LJB_PolyPhen2 LJB_PolyPhen2_Pred LJB_LRT LJB_LRT_Pred LJB_MutationTaster LJB_MutationTaster_Pred LJB_GERP++ Chr Start End Ref Obs Otherinfo/), "\n"; +} else { + print OUT join ("\t", qw/Func Gene ExonicFunc AAChange Conserved SegDup/, "ESP6500_ALL", "${ver1000g}_CEU,${ver1000g}_YRI,${ver1000g}_JPTCHB", "dbSNP$verdbsnp", qw/AVSIFT LJB_PhyloP LJB_PhyloP_Pred LJB_SIFT LJB_SIFT_Pred LJB_PolyPhen2 LJB_PolyPhen2_Pred LJB_LRT LJB_LRT_Pred LJB_MutationTaster LJB_MutationTaster_Pred LJB_GERP++ Chr Start End Ref Obs Otherinfo/), "\n"; + print OUTE join ("\t", qw/Func Gene ExonicFunc AAChange Conserved SegDup/, "ESP6500_ALL", "${ver1000g}_CEU,${ver1000g}_YRI,${ver1000g}_JPTCHB", "dbSNP$verdbsnp", qw/AVSIFT LJB_PhyloP LJB_PhyloP_Pred LJB_SIFT LJB_SIFT_Pred LJB_PolyPhen2 LJB_PolyPhen2_Pred LJB_LRT LJB_LRT_Pred LJB_MutationTaster LJB_MutationTaster_Pred LJB_GERP++ Chr Start End Ref Obs Otherinfo/), "\n"; +} + +while () { + s/[\r\n]+$//; + m/^(\S+)\t([^\t]+)\t(\S+\s+\S+\s+\S+\s+\S+\s+\S+)(.*)/ or die "Error: invalid record found in annovar outputfile: <$_>\n"; + my ($function, $gene, $varstring, $otherinfo) = ($1, $2, $3, $4||''); + my $exonic; + if ($function =~ m/\bsplicing\b/ or $function =~ m/\bexonic\b/) { + $exonic = 1; + } + print OUT "$function"."\t"."$gene"; + $exonic and print OUTE "$function"."\t"."$gene"; + + if (not @{$allstep[1]}) { + if ($valistep{1}) { + if (defined ($_ = )) { + m/^line\d+\t([^\t]+)\t(\S+)\t(\S+\s+\S+\s+\S+\s+\S+\s+\S+)/ or die "Error: invalid record found in annovar outputfile 2: <$_>\n"; + my ($efun, $aachange, $varstring) = ($1, $2, $3); + my @aachange = split (/:|,/, $aachange); + if (@aachange >= 5) { + push @{$allstep[1]}, $varstring, $efun, "$aachange[1]:$aachange[3]:$aachange[4]"; + } else { + push @{$allstep[1]}, $varstring, $efun, $aachange; #aachange could be "UNKNOWN" + } + } + } + } + + if (not @{$allstep[2]}) { + if ($valistep{2}) { + if (defined ($_ = )) { + m/^mce\d+way\tScore=(\S+)\t(\S+\s+\S+\s+\S+\s+\S+\s+\S+)/ or die "Error: invalid record found in annovar outputfile 2: <$_>\n"; + push @{$allstep[2]}, $2, $1; + } + } + } + + if (not @{$allstep[3]}) { + if ($valistep{3}) { + if (defined ($_ = )) { + m/^segdup\tScore=(\S+);\S+\t(\S+\s+\S+\s+\S+\s+\S+\s+\S+)/ or die "Error: invalid record found in annovar outputfile 3 : <$_>\n"; + push @{$allstep[3]}, $2, ($1>0.01)?sprintf("%.2f", $1):$1; + } + } + } + + for my $i (1 .. 3) { + my $curstep = $allstep[$i]; + if (@$curstep and $curstep->[0] eq $varstring) { + if ($i == 1) { + print OUT "\t"."$curstep->[1]"."\t"."$curstep->[2]"; + $exonic and print OUTE "\t"."$curstep->[1]"."\t"."$curstep->[2]"; + } else { + print OUT "\t"."$curstep->[1]"; + $exonic and print OUTE "\t"."$curstep->[1]"; + } + @$curstep = (); + } + else { + if ($i == 1) { + print OUT "\t"."\t"; + $exonic and print OUTE "\t"."\t"; + } else { + print OUT "\t"; + $exonic and print OUTE "\t"; + } + } + } + + if (defined $allstep[32]->{$varstring}) { + print OUT "\t"."$allstep[32]->{$varstring}"; + $exonic and print OUTE "\t"."$allstep[32]->{$varstring}"; + } else { + print OUT "\t"; + $exonic and print OUTE "\t"; + } + + if (defined $allstep[33]->{$varstring}) { + print OUT "\t"."$allstep[33]->{$varstring}"; + $exonic and print OUTE "\t"."$allstep[33]->{$varstring}"; + } else { + print OUT "\t"; + $exonic and print OUTE "\t"; + } + + if (defined $allstep[34]->{$varstring}) { + print OUT "\t"."$allstep[34]->{$varstring}"; + $exonic and print OUTE "\t"."$allstep[34]->{$varstring}"; + } else { + print OUT "\t"; + $exonic and print OUTE "\t"; + } + + for my $i (4 .. 26) { + if (defined $allstep[$i]->{$varstring}) { + print OUT "\t"."$allstep[$i]->{$varstring}"; + $exonic and print OUTE "\t"."$allstep[$i]->{$varstring}"; + } else { + print OUT "\t"; + $exonic and print OUTE "\t"; + } + } + + #step27 already includes step 27 through step 31 + if (defined $allstep[27]->{$varstring}) { + print OUT "\t", join("\t", split(/,/, $allstep[27]->{$varstring})); + $exonic and print OUTE "\t", join("\t", split(/,/, $allstep[27]->{$varstring})); + } else { + print OUT "\t"."\t"."\t"."\t"."\t"."\t"."\t"."\t"."\t"."\t"."\t"; + $exonic and print OUTE "\t"."\t"."\t"."\t"."\t"."\t"."\t"."\t"."\t"."\t"."\t"; + } + + my @varstring = split (/\s+/, $varstring); + $otherinfo =~ s/^\s+//; + my @otherinfo = split (/\t/, $otherinfo); + for my $i (0 .. @otherinfo-1) { + $otherinfo[$i] = "$otherinfo[$i]"; + } + + print OUT "\t", join ("\t", @varstring), "\t", join ("\t", @otherinfo), "\n"; + $exonic and print OUTE "\t", join ("\t", @varstring), "\t", join ("\t", @otherinfo), "\n"; +} + +print STDERR "NOTICE: Final whole-genome summary was written to $outfile.genome_summary.txt file\n"; +print STDERR "NOTICE: Final whole-exome summary was written to $outfile.exome_summary.txt file\n"; + +if ($remove) { + unlink ("$outfile.variant_function", "$outfile.exonic_variant_function", "$outfile.hg18_phastConsElements44way", "$outfile.hg19_phastConsElements46way", + "$outfile.hg19_genomicSuperDups", + "$outfile.hg19_esp6500_all_dropped", + "$outfile.hg19_esp6500_ea_dropped", + "$outfile.hg19_esp6500_aa_dropped", + "$outfile.hg19_hapmap2and3_asw.hg19_generic_dropped", + "$outfile.hg19_hapmap2and3_ceu.hg19_generic_dropped", + "$outfile.hg19_hapmap2and3_chb.hg19_generic_dropped", + "$outfile.hg19_hapmap2and3_chd.hg19_generic_dropped", + "$outfile.hg19_hapmap2and3_gih.hg19_generic_dropped", + "$outfile.hg19_hapmap2and3_jpt.hg19_generic_dropped", + "$outfile.hg19_hapmap2and3_lwk.hg19_generic_dropped", + "$outfile.hg19_hapmap2and3_mex.hg19_generic_dropped", + "$outfile.hg19_hapmap2and3_mkk.hg19_generic_dropped", + "$outfile.hg19_hapmap2and3_tsi.hg19_generic_dropped", + "$outfile.hg19_hapmap2and3_yri.hg19_generic_dropped", + "$outfile.hg19_ALL.sites.2010_11_dropped", + "$outfile.hg19_ALL.sites.2011_05_dropped", + "$outfile.hg19_ALL.sites.2012_02_dropped", + "$outfile.hg19_ALL.sites.2012_04_dropped", + "$outfile.hg19_EUR.sites.2012_04_dropped", + "$outfile.hg19_AFR.sites.2012_04_dropped", + "$outfile.hg19_AMR.sites.2012_04_dropped", + "$outfile.hg19_ASN.sites.2012_04_dropped", + "$outfile.hg19_esp6500_all_dropped", + "$outfile.hg19_esp6500_ea_dropped", + "$outfile.hg19_esp6500_aa_dropped", + "$outfile.hg19_hapmap2and3_asw.hg19_generic_filtered", + "$outfile.hg19_hapmap2and3_ceu.hg19_generic_filtered", + "$outfile.hg19_hapmap2and3_chb.hg19_generic_filtered", + "$outfile.hg19_hapmap2and3_chd.hg19_generic_filtered", + "$outfile.hg19_hapmap2and3_gih.hg19_generic_filtered", + "$outfile.hg19_hapmap2and3_jpt.hg19_generic_filtered", + "$outfile.hg19_hapmap2and3_lwk.hg19_generic_filtered", + "$outfile.hg19_hapmap2and3_mex.hg19_generic_filtered", + "$outfile.hg19_hapmap2and3_mkk.hg19_generic_filtered", + "$outfile.hg19_hapmap2and3_tsi.hg19_generic_filtered", + "$outfile.hg19_hapmap2and3_yri.hg19_generic_filtered", + "$outfile.hg19_ALL.sites.2010_11_filtered", + "$outfile.hg19_ALL.sites.2011_05_filtered", + "$outfile.hg19_ALL.sites.2012_02_filtered", + "$outfile.hg19_ALL.sites.2012_04_filtered", + "$outfile.hg19_EUR.sites.2012_04_filtered", + "$outfile.hg19_AFR.sites.2012_04_filtered", + "$outfile.hg19_AMR.sites.2012_04_filtered", + "$outfile.hg19_ASN.sites.2012_04_filtered", + "$outfile.hg19_esp6500_all_filtered", + "$outfile.hg19_esp6500_ea_filtered", + "$outfile.hg19_esp6500_aa_filtered", + "$outfile.hg18_CEU.sites.${file1000g}_dropped", "$outfile.hg18_YRI.sites.${file1000g}_dropped", "$outfile.hg18_JPTCHB.sites.${file1000g}_dropped", + "$outfile.${buildver}_snp${verdbsnp}_dropped", "$outfile.${buildver}_avsift_dropped", "$outfile.${buildver}_ljb_all_dropped"); +} + +sub checkFileExistence { + my @file = ("${buildver}_refGene.txt", "${buildver}_refLink.txt", "${buildver}_refGeneMrna.fa", "${buildver}_genomicSuperDups.txt", + "${buildver}_snp$verdbsnp.txt", "${buildver}_avsift.txt", "${buildver}_ljb_all.txt", "${buildver}_esp6500_all.txt"); + if ($buildver eq 'hg18') { + push @file, "${buildver}_phastConsElements44way.txt"; + push @file, "${buildver}_CEU.sites.${file1000g}.txt", "${buildver}_YRI.sites.${file1000g}.txt", "${buildver}_JPTCHB.sites.${file1000g}.txt"; + } elsif ($buildver eq 'hg19') { + push @file, "${buildver}_phastConsElements46way.txt"; + push @file, "${buildver}_ALL.sites.2012_04.txt", "${buildver}_EUR.sites.2012_04.txt", "${buildver}_AFR.sites.2012_04.txt", "${buildver}_AMR.sites.2012_04.txt", "${buildver}_ASN.sites.2012_04.txt"; + } + for my $i (0 .. @file-1) { + my $dbfile = File::Spec->catfile ($dbloc, $file[$i]); + -f $dbfile or die "Error: the required database file $dbfile does not exist. Please download it via -downdb argument by annotate_variation.pl.\n"; + } +} + +=head1 SYNOPSIS + + summarize_annovar.pl [arguments] + + Optional arguments: + -h, --help print help message + -m, --man print complete documentation + -v, --verbose use verbose output + --outfile output file name prefix + --buildver genome build version (default: hg18) + --remove remove all temporary files + --verdbsnp dbSNP version to use (default: 130) + --ver1000g 1000G version (default: 1000g2010nov) + --genetype gene definition can be refgene (default), knowngene, ensgene + --checkfile check existence of database file (default: ON) + + Function: automatically run a pipeline on a list of variants and summarize + their functional effects in a comma-delimited file, to be opened by Excel for + manual filtering + + Example: summarize_annovar.pl ex2.human humandb/ + + Version: $LastChangedDate: 2012-05-15 18:05:33 -0700 (Tue, 15 May 2012) $ + +=head1 OPTIONS + +=over 8 + +=item B<--help> + +print a brief usage message and detailed explanation of options. + +=item B<--man> + +print the complete manual of the program. + +=item B<--verbose> + +use verbose output. + +=item B<--outfile> + +the prefix of output file names + +=item B<--buildver> + +specify the genome build version + +=item B<--remove> + +remove all temporary files. By default, all temporary files will be kept for +user inspection, but this will easily clutter the directory. + +=item B<--verdbsnp> + +version of dbSNP to use in annotation. By default, 130 is used. + +=item B<--ver1000g> + +version of 1000 Genomes Project dataset to use in annotation. By default, 1000g2010nov is used. + +=item B<--genetype> + +gene definition systems to use, including refgene (default), knowngene, ensgene + +=item B<--checkfile> + +check to make sure that database files exist, before executing the current +program. + +=back + +=head1 DESCRIPTION + +ANNOVAR is a software tool that can be used to functionally annotate a list of +genetic variants, possibly generated from next-generation sequencing +experiments. For example, given a whole-genome resequencing data set for a human +with specific diseases, typically around 3 million SNPs and around half million +insertions/deletions will be identified. Given this massive amounts of data (and +candidate disease- causing variants), it is necessary to have a fast algorithm +that scans the data and identify a prioritized subset of variants that are most +likely functional for follow-up Sanger sequencing studies and functional assays. + +summarize_annovar is a script that automate some routines in ANNOVAR and +generates an Excel-compatible file for users to manually browse and filter. + +ANNOVAR is freely available to the community for non-commercial use. For +questions or comments, please contact kai@openbioinformatics.org. + + +=cut diff --git a/code/condense_intersectBed_output.py b/code/condense_intersectBed_output.py new file mode 100755 index 0000000..82790d1 --- /dev/null +++ b/code/condense_intersectBed_output.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python +''' +Author: Eli Moss elimoss@stanford.edu + + +Purpose: + + Modify the output of bedtools' intersectbed utility in order to contain only one instance of each genomic locus. + +Explanation: + + The left outer join functionality of intersectbed will output one line per match between its two inputs, whereas we really want only one line + per genomic locus. The purpose of this script then is to take the output of intersectbed and, when a locus appears more than once + with multiple annotations, produce one line for that locus with the annotations joined with commas. + +Example: + + 1 241320 rs79974410 A G 3.22 PASS DP 70 13_Heterochrom/lo + 1 241320 rs79974410 A G 3.22 PASS DP 70 11_Weak_Txn + + becomes + + 1 241320 rs79974410 A G 3.22 PASS DP 70 13_Heterochrom/lo,11_Weak_Txn + +The script does in a streaming fashion from stdin. +''' + +from __future__ import print_function +import sys + + +# prevline = [''] * 12 +annotations = [] + +firstTime = True + +for line in sys.stdin: + # print 'Line: ' + line.rstrip() + s = line.rstrip('\n').split("\t") + if firstTime: + prevline = [''] * len(s) +# firstTime = False +# print ('number of entries: ' + str(len(s)), file=sys.stderr) #debug +# print ('s[1] ' + s[1] + ' pl[1] ' + prevline[1] + ' s2 ' + s[2] + ' pl2 ' + prevline[2] +# + ' s3 ' + s[3] + ' pl3 ' + prevline[3], file=sys.stderr) #debug + if not firstTime and (line.startswith('#') or s[0] != prevline[0] or s[1] != prevline[1] or s[2] != prevline[2] or s[3] != prevline[3] or s[4] != prevline[4]): # line doesn't match previous, or it's a header. in either case, trigger output. + print('\t'.join(prevline[0:12] + [','.join(annotations)])) + annotations = [] + else: # it's a duplicate! Start/continue annotation collection. + annotations.append(s[-1]) + firstTime = False + + prevline = s + +# print out any remaining annotations +if len(annotations) > 0: + print('\t'.join(prevline[0:12] + [','.join(annotations)])) + diff --git a/code/config/datasets.yml b/code/config/datasets.yml new file mode 100644 index 0000000..00b0e7b --- /dev/null +++ b/code/config/datasets.yml @@ -0,0 +1,129 @@ +default: + Build: GRCh37 + Dataset_Path: '../db/datasets/' # where datasets will be downloaded before loading into our database (path is relative to the location of stmp.py) +# Delimiters_for_multiple_matches: ['||'] # currently unused but may be used in a future release + +# pharmgkb requires a license to download. Uncomment the below lines and add the path to the downloaded file under Source if you would like to import and annotate with this dataset. +#pharmgkb: +# License: +# Type: Academic +# URL: https://www.pharmgkb.org/downloads/ +# Annotation: hg19_pgkb +# Source: # requires license to download. Add the path to the downloaded file if you have such a license and would like to use this dataset. +## Class: #TBD +# AnnotationType: region +# Description: pharmGKB basic clinical annotation (drug, class of association, evidence +# level)_ Description of evidence level:http://www_pharmgkb_org/page/clinAnnLevels +# Comment: +# ColumnHeaders: ['', 'chr', 'start', 'stop', 'drugInfo'] +# DataType: ['', varchar(10), int, int, varchar(255)] + +refseq: + Annotation: refseq + Source: 'http://hgdownload.soe.ucsc.edu/goldenPath/hg38/database/refFlat.txt.gz' +# Class: ['function'] # for now + AnnotationType: region + Description: + Comment: '' + ColumnHeaders: ['geneName', 'name', 'chrom', 'strand', 'start', 'end', 'cdsStart', 'cdsEnd', 'exonCount', 'exonStarts', 'exonEnds'] # here start = txStart and end = txEnd, as these encompass a larger region. We leave cdsStart and cdsEnd as they are. + DataType: [string, string, string, varchar(1), int, int, int, int, int, int, int] + +# Core datasets required for tiering +clinvar: + Annotation: clinvar + Source: 'ftp://ftp.ncbi.nlm.nih.gov/pub/clinvar/vcf_GRCh37/clinvar.vcf.gz' +# Class: ['pgx'] # for now + AnnotationType: point + Description: + - TODO: variant classification according to clinvar vcf in dbvar (can add the appropriate info tag and type to the ColumnHeaders and DataType fields below if desired) + - variant disease annotation according to clinvar vcf in dbvar + - variant disease review status in clinvar vcf in dbvar + - TODO: variant accessionID according to clinvar vcf in dbvar (see above) + - TODO: variant data source according to clinvar vcf in dbvar (see above) + - TODO: variant data source ID according to clinvar vcf in dbvar (see above) + Comment: '' + ColumnHeaders: [CLNSIG, CLNREVSTAT] # info tags in VCF file + DataType: [int, varchar(255)] + +#hapmap2and3_CEU: +# Annotation: hg19_hapmap2and3_CEU +# Source: '' #TBA +# Category: allele_frequency +# Description: CEU hapmap population allele frequency +# Comment: lifted over from hg18 +# Delimiters_for_multiple_matches: '' +# ColumnHeaders: ['chrom', 'start', 'stop', 'ref', 'alt', 'info'] +# DataType: ['varchar(10)', 'int', 'int', 'varchar(512)', 'varchar(512)', 'varchar(255)'] + +popfreq_all: + Annotation: hg19_popfreq_all_20150413 + Source: 'http://www.openbioinformatics.org/annovar/download/hg19_popfreq_all_20150413.txt.gz' +# Class: #TBA + AnnotationType: region + Description: + Comment: '' + ColumnHeaders: ['chrom', 'start', 'stop', 'ref', 'alt', 'pop_freq_max', "1000g_all", "1000g_afr", "1000g_amr", "1000g_eas", "1000g_eur", "1000g_sas", "exac_all", "exac_afr", "exac_amr", "exac_eas", "exac_fin", 'exac_nfe', 'exac_oth', 'exac_sas', 'esp6500siv2_all', 'esp6500siv2_aa', 'esp6500siv2_ea', 'cg46'] + DataType: ['varchar(10)', 'int', 'int', 'varchar(512)', 'varchar(512)', 'float', 'float', 'float', 'float', 'float', 'float', 'float', 'float', 'float', 'float', 'float', 'float', 'float', 'float', 'float', 'float', 'float', 'float', 'float'] + +cg69: + Annotation: hg19_cg69 + Source: 'http://www.openbioinformatics.org/annovar/download/hg19_cg69.txt.gz' + AnnotationType: region + Category: frequency + Description: Complete genomics public panel (69 subjects, including 17 member CEPH pedigree) + Comment: '' + ColumnHeaders: ['chrom', 'start', 'stop', 'ref', 'alt', 'info'] + DataType: ['varchar(10)', 'int', 'int', 'varchar(512)', 'varchar(512)', 'varchar(255)'] + +#hapmap2and3_CHB: +# Annotation: hg19_hapmap2and3_CHB +# Source: '' # TBA +# Category: allele_frequency +# Description: CHB hapmap population allele frequency +# Comment: lifted over from hg18 +# Delimiters_for_multiple_matches: '' +# ColumnHeaders: ['chrom', 'start', 'stop', 'ref', 'alt', 'info'] +# DataType: ['varchar(10)', 'int', 'int', 'varchar(512)', 'varchar(512)', 'varchar(255)'] + +#hapmap2and3_YRI: +# Annotation: hapmap2and3_YRI +# Category: allele_frequency +# Description: YRI hapmap population allele frequency +# Comment: lifted over from hg18 +# Delimiters_for_multiple_matches: '' +# ColumnHeaders: ['chrom', 'start', 'stop', 'ref', 'alt', 'info'] +# DataType: ['varchar(10)', 'int', 'int', 'varchar(512)', 'varchar(512)', 'varchar(255)'] + +#phastCons: +# Annotation: hg19_phastConsElements46way +# Category: position +# Description: +# - phastCons most conserved element score, 0-1000 +# - phastCons most conserved element lod score +# Comment: DOES NOT match alt allele from vcf file to risk variant +# Delimiters_for_multiple_matches: '|' +# ColumnNames: ['chrom', 'start', 'stop', 'MSA_MCE_score', 'MSA_MCE_lod'] +# DataType: ['varchar(10)', 'int', 'int', 'varchar(255)', 'varchar(500)'] + +dbnsfp: + Annotation: hg19_ljb26_all + Source: 'http://www.openbioinformatics.org/annovar/download/hg19_ljb26_all.txt.gz' + Category: position + Description: + - "placental subset of site-wise conservation score PhyloP score from dbNSFP 0-1" + - "placental subset of site-wise conservation score PhyloPprediction fromdbNSFP C=conserved, N=neutral" + - "SIFT score from dbNSFP, 0-1" + - "SIFT prediction, D=damaging, T=tolerated" + - "HumDiv trained PolyPhen scores from dbNSFP, 0-1" + - "HumDiv trained PolyPhen prediction from dbNSFP, D=probably damaging, P=possibly damaging, B=benign" + - "LRT test of codon constraint from dbNSFP 0-1" + - "LRT prediction of effect of NS variant from dbNSFP, D=deleterious, N=neutral" + - "Mutation Taster score for ensembl NS SNVs from dbNSFP 0-1" + - 'Mutation Taster score for ensembl NS SNVs from dbNSFP, A=disease causing automatic, D=disease causing, N = polymoprhism, P = polymorphism automatic ' + - GERP++ predictions for NS SNVs from dbNSFP + Comment: ['on dbNSFP scale, larger score is more conserved', 'http://onlinelibrary_wiley_com/doi/10_1002/humu_21517/full'] + Delimiters_for_multiple_matches: '' + ColumnNames: ["chrom", "start", "end", "ref", "alt", "SIFT_score", "SIFT_pred", "Polyphen2_HDIV_score", "Polyphen2_HDIV_pred", "Polyphen2_HVAR_score", "Polyphen2_HVAR_pred", "LRT_score", "LRT_pred", "MutationTaster_score", "MutationTaster_pred", "MutationAssessor_score", "MutationAssessor_pred", "FATHMM_score", "FATHMM_pred", "RadialSVM_score", "RadialSVM_pred", "LR_score", "LR_pred", "VEST3_score", "CADD_raw", "CADD_phred", "GERP++_RS", "phyloP46way_placental", "phyloP100way_vertebrate", "SiPhy_29way_logOdds"] + DataType: ['varchar(10)', 'int', 'int', 'varchar(512)', 'varchar(512)', 'double', 'varchar(1)', 'double', 'varchar(1)', 'double', 'varchar(1)', 'double', 'varchar(1)', 'double', 'varchar(1)', 'double', 'varchar(1)', 'double', 'varchar(1)', 'double', 'varchar(1)', 'double', 'varchar(1)', 'double', 'double', 'double', 'double', 'double', 'double', 'double'] + +# If you would like to import additional datasets for use in annotation, add them below. To find out more about the information required for each dataset listed in this file, see the datasets above and datasets_spec.yml. diff --git a/code/config/datasets_spec.yml b/code/config/datasets_spec.yml new file mode 100644 index 0000000..0cdeaac --- /dev/null +++ b/code/config/datasets_spec.yml @@ -0,0 +1,19 @@ +default: + Build: GRCh37 + Dataset_Path: 'datasets/' # where datasets will be downloaded before loading into our database + Delimiters_for_multiple_matches: ['||'] # potentially check if this comes up in any dataset during load and raise a warning/adjust it if it does + Parameter_Annovar: # annovar default parameters + +#Template dataset: + Annotation: What the dataset should be called in our database. This will be prepended to each column in the annotated output file (e.g. for Annotation=clinvar, output columns would be clinvar_clnsig, clinvar_clnrevstat, etc.) + Source: URL/path to locally downloaded source file + Class: (optional) any combination of ['function','freq', 'regulatory', 'low-confidence', 'conservation', 'tolerance', 'function_score', 'somatic', 'pgx', 'clinical'] + AnnotationType: (optional) one of ['Annovar'|'Snpeff'|'region'|'point'] + ColumnHeaders: ordered list of columns named as you would like them to appear in the annotated output. To exclude a column, just give it a blank name '' (e.g. ['', 'chr', 'start', 'stop', ...]. If dataset is a VCF, just specify the names of the tags you'd like to import from the INFO column. Standard VCF columns (e.g. chr, start, ID, ref, alt, qual, filter) will be imported automatically. + DataType: ordered list of data types for each of the columns specified above. If a column is excluded, the datatype should also be given as a blank string ''. For VCF datasets, just specify datatypes of the INFO tags given above -- datatypes for the other columns will be taken care of automatically. Note that sqlite3 does not check data types so STMP will not throw an error if the actual data does not match the given data type. + StartingLine: (optional) Line in the dataset file to start the import at (default = 0). Use this if headers are not prefixed with '#'. + Description: (optional) description of dataset + License: (optional) + # Type: (optional) e.g. academic + # URL: (optional) URL of dataset homepage/license page + Comment: (optional) any other comments \ No newline at end of file diff --git a/code/pgxUtils.py b/code/pgxUtils.py new file mode 100644 index 0000000..c6c051c --- /dev/null +++ b/code/pgxUtils.py @@ -0,0 +1,302 @@ +#Rick Dewey 2.13.13 rdewey@stanford.edu +#Last modified: 1.26.14 +#PGX annotation +#utils for PGX annotations for STMP + +import os +import re +import fileinput +import sys +import getopt +import glob +import gzip + + +def open_compressed_or_regular(f, options): + if(f.endswith('.gz')): + return gzip.open(f, options) + #else + return open(f, options) + +#reads in vcf file and return variant dictionary +def vcf_reader_vars(infile): + var_dict = {} + + filein = open_compressed_or_regular(infile, "r") + for line in filein.readlines(): + if ("#" in line) == 0: + linelist = line.replace("\n", "").split("\t") + rsid = linelist[2] + ref = linelist[3] + alt = linelist[4] + gt_list = linelist[9].split(":") + gt = gt_list[0] + if gt == "0/0": + var_dict[rsid] = ref+ref + elif gt == "1/1": + var_dict[rsid] = alt+alt + elif gt == "0/1": + if ref0: + print("\n"+"Possible allele pairs: ") + for key, value in alleles.iteritems(): + print("\n"+key+","+value) + + return alleles, found_pair + + +#wrapper for calling star alleles for all haplotype tables in a directory +def star_caller(hap_dir, n_file, o_stem): + + #debug +# print 'hap_Dir: ' + str(hap_dir) +# print 'n_file: ' + str(n_file) +# print 'o_stem: ' + str(o_stem) + + hap_file_list = glob.glob(hap_dir+"/*-haplotypes-snvs.txt") + fileout = open_compressed_or_regular(o_stem+".star.txt", "w") + + #read in input vcf file + vcf_dict, vcf_hom, vcf_het, vcf_all = vcf_reader_haps(n_file) + + #iterate over haplotypes in directory of snv-defined star alleles + for item in hap_file_list: + gene_symb = item.replace(hap_dir, "").replace("/", "").split("-")[0] + all_dict, is_found = haplotyper(gene_symb, item, vcf_all, vcf_het, vcf_hom, vcf_dict, n_file) + if is_found > 0: + for key, value in all_dict.iteritems(): + fileout.write(gene_symb+"\t"+key+"\t"+value+"\n") + else: + fileout.write(gene_symb+"\t"+"No haplotype matches\n") + fileout.close() + + +#merges star allele designations and individual genotypes with CPIC guidelines for output of guideline based recommendations +#def cpic_annotator(cpic, stars, n_file, o_stem): +# vcf_vars = vcf_reader_vars(n_file) +# file out = open_compressed_or_regular(o_stem+".cpic.txt", "w") + diff --git a/code/stmp.py b/code/stmp.py new file mode 100755 index 0000000..2681cb0 --- /dev/null +++ b/code/stmp.py @@ -0,0 +1,445 @@ +#!/usr/bin/env python + +''' +Author: Eli Moss elimoss@stanford.edu, Prag Batra prag@stanford.edu + +Purpose: + + a) Provide facile creation/maintenance of SQLite database containing variant annotation data. + b) Annotate variants (as VCF) with annotations contained in database. + c) Prioritize annotated variants into 4 different tiers according to functional and other annotations. + +Explanation: + + Organization and maintenance of annotation data is complex when many dozens of datasets are involved. Subsequently, applying + those annotations to a collection of variants becomes an intricate task rapidly. This script solves both problems by creating + and utilizing a SQLite annotation database. Further detail is provided in the code. + +Example: + +stmp.py --update_db --yaml=config/annotation.yml # loads all datasets specified in the YAML file into our database + +stmp.py --vcf={input vcf or vcf.gz file} --output_dir={output directory} # applies annotation and tiering to the input VCF, outputting it in the specified output directory. + +For a complete list of parameters, just run stmp.py with no options. + + +''' + + +import argparse +import stmp_annotation_util +import stmp_tiering_util +import pgxUtils +import multiprocessing +from multiprocessing import pool +import time +from time import strftime, localtime +import os +import sys +import yaml +import subprocess +import datetime +import gzip + +cur_path = os.path.dirname(os.path.abspath(__file__)) +resources_path= os.path.join(cur_path, os.path.pardir, 'data') + +# parse commandline options. +parser = argparse.ArgumentParser(description = 'Sequence to Medical Phenotypes') + +parser.add_argument("--config", dest='yaml', help = 'yaml-formatted annotation/db update specification', default=os.path.join(cur_path, 'config', 'datasets.yml')) +# parser.add_argument('--modules', help='yaml-formatted options for each module (annotation, tiering, pgx, trio)', default=os.path.join(cur_path, 'config', 'modules.yml')) + +# arguments related to updating the database +db_update_group = parser.add_argument_group("Database initialization/update", 'Initialize DB, or update if already extant.') +db_update_group.add_argument("--update_db", action='store_true', + help = 'Initialize or update MySQL database from text annotation files. Please provide either YAML configuration file or directory containing annotation database text files (see below parameters)') +db_update_group.add_argument('--input_directory', help='Directory containing annotation database text files.') +db_update_group.add_argument("--skip", help = 'Skip data sources already present in the database', default = False, const = True, nargs = '?') +db_update_group.add_argument("--download_datasets_only", action='store_true', help='just download the datasets specified in the YAML file without loading them into the DB or performing annotation') +db_update_group.add_argument('--check_datasets_only', action='store_true', help='just check which datasets from the YAML were downloaded already') +db_update_group.add_argument('--dataset_output_dir', help='output dir for the downloaded datasets') + +# arguments related to annotating a vcf +annotate_group = parser.add_argument_group('Annotation Parameters', 'Arguments required in order to perform VCF annotation.') +annotate_group.add_argument("--vcf", help = 'input VCF or gzipped VCF file') +annotate_group.add_argument("--output_dir", help = 'location of output files') +annotate_group.add_argument("--clean_beds" , action='store_true', dest='clean_beds', help="do a clean run instead of reusing previously generated bed files for range annotation (note that generating these files takes a while)") +annotate_group.add_argument("--skip_multiallelic_fix", action='store_true', dest='skip_multiallelic', help="don't use bcftools to split lines with multiple allele changes") +annotate_group.add_argument("--reuse_multiallelic", action='store_true', help='reuse multiallelic split file if it already exists') +annotate_group.add_argument("--force_input_overwrite", action='store_true', dest='force_input_overwrite', help='forces input VCF to be reimported into the DB, even if it has already been imported in the past') +annotate_group.add_argument('--log', help='name of logfile') +annotate_group.add_argument('--database_file', help='path to SQLite database file (default: ../db/annotationDB.sqlite)', default=os.path.join(cur_path, '..', 'db' ,'annotationDB.sqlite')) +annotate_group.add_argument('--db_bed_dir', help='location of BED files generated for range annotation (default: ../db/db_beds)', default=os.path.join(cur_path, os.pardir, 'db', 'db_beds/')) +annotate_group.add_argument('--annotate_only', action='store_true', help='just do annotation (no tiering, pgx, etc.)') +annotate_group.add_argument('--drop_samples', action='store_true', help='drops sample tables (use this before distributing the database)') +annotate_group.add_argument('--drop_sample', action='store_true', help='drops this sample from the database after completing annotation') +annotate_group.add_argument('--region_annotations_only', action='store_true', help='just do region annotation') +annotate_group.add_argument('--print_region_cmd_only', action='store_true', help="just print region annotation command (don't actually do the annotation or anything else") +# annotate_group.add_argument('--sorted_vcf', action='store_true', help='use this if the input VCF is presorted by chr, then start position. Range annotation will then use more memory-efficient algorithms.') + +# variant tiering (prioritization) +tiering_group = parser.add_argument_group('Variant Prioritization', 'Arguments for variant prioritization') +tiering_group.add_argument('-t', '--target_genes', default = os.path.join(resources_path, 'clinvar', 'clin_var_curated_genes.txt'), +help = 'target gene file, default clinvar') # cur_path+"/resource/clinvar/clin_var_curated_genes.txt", help = 'target gene file, default clinvar') +tiering_group.add_argument('-e', '--ethnicity', default = "CEU", help = 'ethnicity for allele frequency filtering') +tiering_group.add_argument('-s', '--sfs_file', default = "None", help = "input site frequency spectrum file") +tiering_group.add_argument('--tiering_only', action='store_true', help='just do tiering (only annotates what is needed for tiering)') # TODO finsh implementing selective annotation + +# pgx (pharmgkb/clinvar annotations) +pgx_group = parser.add_argument_group('Pharmacogenomics', 'Arguments for pharmacogenomics module') +pgx_group.add_argument('-n', '--num_threads', default = 1) +pgx_group.add_argument('-b', '--input_bam', default = "None", help = 'input bam file') +pgx_group.add_argument('--reference_sequence', help = 'reference sequence (FASTA file) to accompany input bam') +pgx_group.add_argument('--ref', help='reference (e.g. hg19 or GRCh37)', default='GRCh37') +pgx_group.add_argument('--pgx_only', action='store_true', help='just do pgx (takes care of required annotation, etc.)') +pgx_group.add_argument('--dbsnp', help='path to dbsnp file (used by GATK)') + +#debug modes +debug_group = parser.add_argument_group('Debugging parameters') +debug_group.add_argument('--debug_point_annotations', action='store_true', help='enable debug mode for point annotations') +debug_group.add_argument('--point_annotations_only', action='store_true', help='only do point annotations (no functional/range annotations, tiering, etc.)') +debug_group.add_argument('--print_sql_query_only', action='store_true', help='just print out SQL query') +# debug_group.add_argument('--compact_logs') +debug_group.add_argument('--skip_join_checks', action='store_true', help='skips join checks for snpeff, annovar, point annotation, range annotation. Without this the log file may get fairly large.') + + +args = parser.parse_args() + +#print help and exit if no arguments are supplied. +if len(sys.argv) == 1: + parser.print_help() + sys.exit(1) + +# parse YAML if specified +if(args.yaml != None): + yaml_commands = stmp_annotation_util.parse_yaml(args.yaml) + if(args.download_datasets_only): + stmp_annotation_util.downloadDBs(yaml_commands, args.dataset_output_dir, args.log) + sys.exit(0) + elif args.check_datasets_only: + stmp_annotation_util.checkDBs(yaml_commands, args.dataset_output_dir) + sys.exit(0) + + +# clean up any existing bed files if needed - NOTE: no longer needed +# if args.clean_beds: +# print 'Cleaning up old BED files' +# cmd = 'rm -f /tmp/stmp2/db_beds/*' +# #cmd = 'mv /tmp/stmp2/db_beds/* /tmp/stmp2/db_beds/old/' +# subprocess.Popen(cmd, shell=True).wait() + +#open the connection to the database +# if(args.database_file != None): +db_conn = stmp_annotation_util.connect_db(db_file=args.database_file, host_name='', user_name='', db_name='', unix_socket_loc='') +# else: +# db_conn = stmp_annotation_util.connect_db(host_name='', user_name='', db_name='', unix_socket_loc='') + +if args.drop_samples: + stmp_annotation_util.drop_samples(db_conn) + +if args.update_db: # check if database setup is requested + if args.input_directory != None: + args.update_db = stmp_annotation_util.root_or_cwd(args.input_directory) # complete the filepath if an absolute filepath is not provided. + stmp_annotation_util.setup_db(args.input_directory, db_conn, args.skip) # Launch DB updating process. + elif args.yaml != None: + stmp_annotation_util.setup_db_yaml(db_conn, yaml_commands, args.skip) + else: + print 'Error: neither YAML nor directory with input datasets specified' + parser.print_help() + sys.exit(1) + + +if args.vcf != None: # annotation + #Files and Directories + args.vcf = stmp_annotation_util.root_or_cwd(args.vcf) # complete the filepath if an absolute filepath is not provided. + args.output_dir = stmp_annotation_util.root_or_cwd(args.output_dir) # ditto + args.scratch_dir = os.path.join(args.output_dir, 'scratch') + if not os.path.exists(args.scratch_dir): + os.makedirs(args.scratch_dir) + + ######################################################################################################################## + #Convert multiallelic to single line for easier merging of functional annotations later + + if args.reuse_multiallelic and not args.skip_multiallelic: + noMultialllic_vcf = stmp_annotation_util.splitMultiallelic(args.vcf, args.scratch_dir, skip_if_exists=True) + args.vcf = noMultialllic_vcf + elif not args.skip_multiallelic: + noMultialllic_vcf = stmp_annotation_util.splitMultiallelic(args.vcf, args.scratch_dir) + args.vcf = noMultialllic_vcf + else: + print 'Skipping multiallelic check' + + # strip chr prefix + stripChr_vcf = stmp_annotation_util.stripChrPrefix(args.vcf, args.scratch_dir, skip_if_exists=False) + args.vcf=stripChr_vcf + +############### MAIN FUNCTIONS (ANNOTATION, TIERING, PGX) ################ + + # ANNOTATION MAIN FUNCTION + def annotate(args): + + if args.region_annotations_only: + #region annotation does not require sample vcf to be uploaded to our db + region_outfile = stmp_annotation_util.annotate_range(db_conn, args.vcf, args.scratch_dir, db_bed_dir=args.db_bed_dir) + exit(0) + + #Functional variant effect prediction + #snpeff + if(not args.point_annotations_only): + [snpeff_proc, sample_name, snpeff_vcf_outfile] = stmp_annotation_util.snpeff(args.vcf, args.scratch_dir) # launch snpEff on the VCF. This will chug in the background, and the script will wait for the completion of the returned process at the end if it hasn't terminated by that time. + + #Actual Annotation + # upload vcf + sample_db_path = stmp_annotation_util.upload_vcf(db_conn, args.vcf, args.scratch_dir, args.force_input_overwrite) + + # annovar + region annotation + if not args.point_annotations_only: + [annovar_proc, annovar_outfile] = stmp_annotation_util.annovar_annotate_functional(args.vcf, args.scratch_dir) + region_outfile = stmp_annotation_util.annotate_range(db_conn, args.vcf, args.scratch_dir, db_bed_dir=args.db_bed_dir) # Find annotations which cover a genomic interval. This is done with BEDtools. + + # point annotation + point_outfile = stmp_annotation_util.annotate_point(db_conn, args.vcf, args.scratch_dir, sample_db_path, debug=args.debug_point_annotations) # Find annotations which are associated with a single locus. This is done with a SQL join. + if args.point_annotations_only: + exit(0) # stop after point annotation done + + #wait for snpeff and annovar to complete, if they haven't already. + print 'Waiting for snpeff to complete...' + snpeff_proc.wait() + print 'Waiting for annovar to complete...' + annovar_proc.wait() + + # convert snpeff vcf to tsv (remove all lines with '#') + snpeff_tsv_outfile = stmp_annotation_util.snpeff2tsv(sample_name, snpeff_vcf_outfile, args.scratch_dir) + + #join the results into a single file + joined_outfile = stmp_annotation_util.joinFiles(args.vcf, snpeff_tsv_outfile, annovar_outfile, region_outfile, point_outfile, args.output_dir, args.skip_join_checks) + + # for now (must do this to avoid issues with region annotation) +# print 'Cleaning up temporary range annotation files' +# cmd = 'rm -f /tmp/stmp2/intersected/*' +# # cmd = 'mv /tmp/stmp2/intersected/* /tmp/stmp2/intersected/old/' +# subprocess.Popen(cmd, shell=True).wait() + + print 'Done annotating ' + joined_outfile + return joined_outfile + + # end annotation function + + + ####################################################################### + ####### Variant Tiering ############## + + ## HELPER FUNCTIONS + #wrapper to call mapped processes + def call_process(command): + print "Processing command: "+command + status = "Return code for command "+command+":"+str(os.system(command)) + return status + + #function to add rsid to GATK output + def add_rsid(intervals, in_file, out_file): + f1 = open(intervals, "r") + f2 = stmp_annotation_util.open_compressed_or_regular(in_file, "r") + f3 = open(out_file, "w") + + rsdict = {} + for line in f1: + if ("#" in line) == 0: + linelist = line.split("\t") + rsdict[linelist[0]+":"+linelist[1]] = linelist[2].replace("target_", "").replace("\n", "") + + while 1: + temp = f2.readline() + if not temp: + break + else: + if (("#" in temp) == 0): + linelist = temp.split("\t") + if rsdict.has_key(linelist[0]+":"+linelist[1]): + f3.write(linelist[0]+"\t"+linelist[1]+"\t"+rsdict[linelist[0]+":"+linelist[1]]+"\t"+"\t".join(linelist[3:len(linelist)])) + else: + f3.write(temp) + f1.close() + f2.close() + f3.close() + + + # TIERING (VARIANT PRIORITIZATION) MAIN FUNCTION + def tier(args, annotation_joined_outfile, yaml_cmds): + ## MAIN CODE + print 'Performing variant prioritization' + + # targeted tiering only if BAM file provided? + # stmp_tiering_util.tiers_target(os.path.join(args.output_dir, 'tiers_target.tsv'), os.path.join(args.output_dir, 'tiers_target'), args.target_genes, pop=args.ethnicity) + + # standard VCF prioritization (tiering) + stmp_tiering_util.tiers_allvars(joined_outfile, os.path.join(args.output_dir, 'tiering_allvars'), args.target_genes, pop=args.ethnicity, yaml_cmds=yaml_cmds) + + if args.sfs_file != "None": + for i in range(1,5): + stmp_tiering_util.filter_sfs(os.path.join(args.output_dir, "allvars.tier"+str(i)+".txt"), args.sfs_file, os.path.join(args.output_dir, "allvars.tier"+str(i)+"-sfs_filtered.txt"), 2) + + + print("Done with variant prioritization. Check output files in " + args.output_dir) + + # end tiering function + + ################################################################################################# + + ########### Pharmgkb and ClinVar Annotation ####################### + + # PGX MAIN FUNCION (PHARMGKB AND CLINVAR ANNOTATION) + def pgx(args): + # consts + args.output = args.output_dir + + ########## HELPER METHODS ############### + + #wrapper to annotate snvs/indels + # def annotate_snvs(snv_in, snv_out_stem): + # + # #convert input file to annovar format + # if ".vcf" in snv_in: + # os.system("perl "+cur_path+"/stanovar/convert2annovar.pl "+snv_in+" --includeinfo -format vcf4 > "+snv_out_stem+".snv.annovar.txt") + # else: + # print >> sys.stderr, "Error in annotate_vars.py: Invalid vcf input file format" + # exit(1) + # + # #read in command file + # #yaml_in = "/stanovar/config/annotation_testing_subset.yaml" + # #print("USING TESTING ANNOTATION SUBSET") + # yaml_in = "/stanovar/config/annotation.yaml" + # commands = parse_yaml_commands(snv_out_stem, yaml_in) + # return commands + + ########## MAIN CODE ##################### + + print str(datetime.datetime.now()) + ': Performing PharmGKB + ClinVar (pgx) annotation' + +# # GENOTYPING +# #pool of processors for concurrent processing +# pool = multiprocessing.Pool(processes = int(args.num_threads)) +# +# command_call = [] +# #call targeted genotypes and perform clinvar and PharmGKB annotation, if BAM file provided +# if args.input_bam != "None": +# if ".bam" in args.input_bam: +# # choose appropriate resource files based on specified reference (hg19, GRCh37, etc.). Default file (e.g. pgx_cd_5.7.13.snvs.vcf.gz) is grch37 (does not include chr prefix), other file (pgx_cd_5.7.13_hg19.snvs.vcf.gz) is hg19 (includes chr prefix). +# pgx_snv_interval_filename = 'pgx_cd_5.7.13.snvs.vcf.gz_b37.vcf.gz' if args.ref.lower() == 'grch37' else 'pgx_cd_5.7.13.snvs_hg19.vcf.gz' if args.ref.lower() == 'hg19' else '' +# pgx_indel_interval_filename = 'pgx_cd_5.7.13.b37.indels.vcf' if args.ref.lower() == 'grch37' else 'pgx_cd_5.7.13.indels.vcf' if args.ref.lower() == 'hg19' else '' +# # clinvar_indel_interval_filename = 'clinvar_3.15.13.b37.indels.vcf' if args.ref.lower() == 'grch37' else 'clinvar_3.15.13.indels.vcf' if args.ref.lower() == 'hg19' else '' +# #debug +# # clinvar_indel_interval_filename = 'clinvar_3.15.13.indels.vcf' +# clinvar_indel_interval_filename = 'clinvar_indels.vcf.recode.vcf' +# +# # then call appropriate commands +# cmd = "sh "+cur_path+"/target_snvs.sh "+args.input_bam+" "+cur_path+"/resource/intervals/clinvar.interval_list "+args.output+"/clinvar.snvs"+' '+args.reference_sequence+' '+args.dbsnp +# #debug +# print 'cmd: ' + cmd +# command_call.append(cmd) +# +# cmd = "sh "+cur_path+"/target_snvs.sh "+args.input_bam+" "+cur_path+"/resource/intervals/"+pgx_snv_interval_filename+" "+args.output+"/pgx.snvs"+' '+args.reference_sequence+' '+args.dbsnp +# #debug +# print 'cmd: ' + cmd +# command_call.append(cmd) +# +# cmd = "sh "+cur_path+"/target_indels.sh "+args.input_bam+" "+cur_path+"/resource/intervals/"+clinvar_indel_interval_filename+" "+args.output+"/clinvar.indels"+' '+args.reference_sequence+' '+args.dbsnp +# #debug +# print 'cmd: ' + cmd +# command_call.append(cmd) +# +# cmd = "sh "+cur_path+"/target_indels.sh "+args.input_bam+" "+cur_path+"/resource/intervals/"+pgx_indel_interval_filename+" "+args.output+"/pgx.indels"+' '+args.reference_sequence+' '+args.dbsnp +# #debug +# print 'cmd: ' + cmd +# command_call.append(cmd) +# +# #log file specification +# log_file = open(args.output+"/stmp2.log", "w") +# log_file.write(">>> Sequence to medical phenotypes log file <<<\n") +# log_file.write("\nstmp2 started: "+strftime("%a, %d %b %Y %H:%M:%S +0000", localtime())+"\n\n") +# +# #map calling commands +# res_calls = pool.map(call_process, command_call) +# for item in res_calls: +# log_file.write(item+"\n") +# +# #merge clinvar, and pgx calls and re-annotate rsid +# add_rsid(cur_path+"/resource/intervals/"+pgx_snv_interval_filename, args.output+"/pgx.snvs.filtered.vcf", args.output+"/pgx.snvs.annotated.vcf") +# add_rsid(cur_path+"/resource/intervals/"+pgx_indel_interval_filename, args.output+"/pgx.indels.filtered.vcf", args.output+"/pgx.indels.annotated.vcf") +# # add_rsid(cur_path+"/resource/intervals/clinvar_3.15.13.snvs.vcf", args.output+"/clinvar.snvs.filtered.vcf", args.output+"/clinvar.snvs.annotated.vcf") +# # add_rsid(cur_path+"/resource/intervals/clinvar_3.15.13.indels.vcf", args.output+"/clinvar.indels.filtered.vcf", args.output+"/clinvar.indels.annotated.vcf") +# os.system("sh "+cur_path+"/combine_variants.sh "+args.output+"/pgx.snvs.annotated.vcf "+args.output+"/pgx.indels.annotated.vcf "+args.output+"/pgx.all.vcf") +# os.system("sh "+cur_path+"/combine_variants.sh "+args.output+"/clinvar.snvs.filtered.vcf "+args.output+"/clinvar.indels.filtered.vcf "+args.output+"/clinvar.all.vcf") + + #annotate and prioritize clinvar variants using Stanovar + # command_ann_clin = annotate_snvs(args.output+"/clinvar.all.vcf", args.output+"/clinvar") + # res_ann = pool.map(call_process, command_ann_clin) + # for item in res_ann: + # log_file.write(item+"\n") + # os.system("perl "+cur_path+"/stanovar/summarize_annovar.pl "+args.output+"/clinvar"+" "+cur_path+"/stanovar/humandb '"+get_head(args.output+"/clinvar.all.vcf")+"'") + # diseaseUtils.tiers_target(args.output+"/clinvar.genome_summary.tsv", args.output+"/clinvar", args.target_genes, 0.01, args.ethnicity) + # if args.sfs_file != "None": + # for i in range(1,5): + # diseaseUtils.filter_sfs(args.output+"/clinvar.tier"+str(i)+".txt", args.sfs_file, args.output+"/clinvar.tier"+str(i)+"-sfs_filtered.txt", 2) + + #pharmgkb annotation + + pgxUtils.pgx_annotator(args.vcf, os.path.join(resources_path, "pgx_vars", "clinical_ann_metadata-snvs.txt"), os.path.join(args.output, "pharmacogenomics")) + pgxUtils.star_caller(os.path.join(resources_path, "pgx_haps/"), args.vcf, os.path.join(args.output, "pharmacogenomics")) + +# pgxUtils.pgx_annotator(os.path.join(args.output, "pgx.all.vcf"), os.path.join(cur_path, "resource/pgx_vars/clinical_ann_metadata-snvs.txt"), os.path.join(args.output, "pharmacogenomics")) +# pgxUtils.star_caller(os.path.join(cur_path, "resource/pgx_haps/"), os.path.join(args.output, "pgx.all.vcf"), os.path.join(args.output, "pharmacogenomics")) +# else: +# print >> sys.stderr, "Error in stmp2.py - input file does not appear to be bam format" +# exit(1) + + print str(datetime.datetime.now()) + ': Done with pgx/clinvar annotation' + + # end pgx function + + +###################### MAIN CODE (logic to call main functions) ############### + + #just print sql query if specified + if args.print_sql_query_only: + sample_db_path = stmp_annotation_util.get_sample_db_path(args.scratch_dir, stmp_annotation_util.getSampleName(args.vcf)) + stmp_annotation_util.annotate_point(db_conn, args.vcf, args.scratch_dir, sample_db_path, print_sql_query_only=True, debug=args.debug_point_annotations) + exit(0) + + if args.print_region_cmd_only: + stmp_annotation_util.annotate_range(db_conn, args.vcf, args.scratch_dir, db_bed_dir=args.db_bed_dir, print_range_cmd_only=True) + exit(0) + + # pgx doesn't depend on other annotations + if(args.pgx_only): + pgx(args) + exit(0) + + # tiering requires annotation to already be done + if(args.tiering_only): + joined_outfile = stmp_annotation_util.generateJoinedOutfilePath(args.output_dir, stmp_annotation_util.getSampleName(args.vcf)) # generates path to outfile but does not create it + tier(args, joined_outfile, yaml_cmds=yaml_commands) + exit(0) + + if(args.annotate_only): + annotate(args) + exit(0) + + # by default, run full pipeline + joined_outfile = annotate(args) + tier(args, joined_outfile, yaml_cmds=yaml_commands) + + # comment out the below line for stable branch (currently doesn't work) + pgx(args) + + + #remove sample from database if desired + if(args.drop_sample): + stmp_annotation_util.drop_sample(db_conn, args.vcf) + + # clean up samples in database if needed + if(args.drop_samples): + stmp_annotation_util.drop_samples(db_conn) + diff --git a/code/stmp_annotation_util.py b/code/stmp_annotation_util.py new file mode 100644 index 0000000..d13f414 --- /dev/null +++ b/code/stmp_annotation_util.py @@ -0,0 +1,1463 @@ +#!/usr/bin/env python + +''' +Author: Eli Moss elimoss@stanford.edu, Prag Batra prag@stanford.edu + +Purpose: + + All the heavy lifting for variant annotation happens here. + +Explanation: + + Functionality is so diverse that descriptions are best left to inline comments. + +Example: + + For usage, see stmp.py where these methods are all called. + +''' + +import sys +import linecache +import sqlite3 +import os +from subprocess import * +import subprocess +import stmp_consts +import yaml +import mmap +import datetime +import vcfHeaders +import vcfUtils +import gzip + +# Locations of important things. (for now -- ideally should be in user's path) +SNPEFF = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir, os.pardir, 'third_party', 'snpeff', 'snpEff', 'snpEff.jar')) +# 'snpEff.jar' # should be in user's PATH +# os.path.join(os.path.dirname(os.path.realpath(__file__)), 'third_party/snpeff/snpEff/snpEff.jar') # location of Pablo's famous variant effect predictor. +SNPEFF_MEMORY_ALLOCATION = '6g' + +ANNOVAR_PATH = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir, os.pardir, 'third_party', 'annovar')) # we need this both for annovar executable (annotate_variation.pl, table_annovar.pl) and to locate humandb folder for functional annotations + +# os.path.join(os.path.dirname(os.path.realpath(__file__)), 'third_party/annovar') # needed for humandb folder + +START_COLUMN_HEADERS = ['start', 'begin', 'pos'] +STOP_COLUMN_HEADERS = ['stop', 'end'] +CHR_HEADERS = ['chr', 'chrom', 'chromosome'] + +BED_DELIMITER = '|||' + +def open_compressed_or_regular(f, options): + if(f.endswith('.gz')): + return gzip.open(f, options) + #else + return open(f, options) + +def downloadDB(db_yaml, out_path, out_dir, download_method, ucsc_basePath = None): + + if(download_method == 'ANNOVAR'): + # TODO use annovar to download + print 'Error ANNOVAR download method not yet implemented for dataset ' + db_yaml['Annotation'] + None + elif(download_method == 'URL'): + if not os.path.exists(out_dir): + os.makedirs(out_dir) + cmd = "cd {out_dir}; wget --retr-symlinks --timestamping {url}".format(out_dir=out_dir, outfile=out_path, url=db_yaml['Source']) # For now, just download the file with the same name as on the server (we'll use the name given in the YAML when importing it into our database). "--timestamping" flag won't re-retrieve files unless newer than local file. + subprocess.Popen(cmd, shell=True).wait() + #record download date in separate metadata file for versioning purposes + metadata_path = out_path+'.info' + writef(metadata_path, 'Downloaded '+str(datetime.datetime.now())+"\n") #TODO maybe capture download time at beginning insead of end of download + + return out_path + # TODO maybe include UCSC stuff as part of URL download (instead of having UCSC base path, etc.) + None +# elif(download_method == 'UCSC'): +# # TODO use UCSC base path to download dataset + + +# downloads datasets from annovar (via annovar or UCSC website) +def downloadDBs(yaml_commands, out_dir, logfile = None): + out_log = None + if logfile != None: + out_log = open(logfile, 'w') + + build = '' + + for dataset in yaml_commands: + if(dataset == 'default'): + build = yaml_commands[dataset]['Build'] + continue + + if(yaml_commands[dataset] != None and 'Annotation' in yaml_commands[dataset]): + dataset_name = yaml_commands[dataset]['Annotation'] + print 'Downloading dataset for annotation: ' + dataset_name + # attempt to download from annovar site + cmd = 'perl {annotate_variation} -buildver {build} -downdb -webfrom annovar {dbname} {out_dir}'.format(build=build, annotate_variation=os.path.join(ANNOVAR_PATH, 'annotate_variation.pl'), dbname=dataset_name, out_dir=out_dir) + retVal = subprocess.Popen(cmd, shell=True).wait() + # TODO grab name/path of annovar downloaded file + if(retVal != 0): + # attempt to download from UCSC site + cmd2 = 'perl {annotate_variation} -buildver hg19 -downdb {dbname} {out_dir}'.format(annotate_variation=os.path.join(ANNOVAR_PATH, 'annotate_variation.pl'), dbname=dataset_name, out_dir=out_dir) + retVal = subprocess.Popen(cmd2, shell=True).wait() + # TODO grab name/path of downloaded file + if(retVal != 0): + print 'unable to download ' + dataset_name + if out_log != None: + out_log.write('unable to download ' + dataset_name + "\n") + + print 'Finished downloading datasets to ' + out_dir + + +# checks which DBs were downloaded +def checkDBs(yaml_commands, out_dir): + print 'checking downloaded datasets at ' + out_dir + ' against YAML' + files = os.listdir(out_dir) + filesHash = {} + for file in files: + filesHash[os.path.splitext(file)[0].lower()] = 1 + + missingDatasets = 0 + for dataset in yaml_commands: + if('hg19_' + dataset.lower() not in filesHash): + print 'missing dataset ' + dataset + missingDatasets += 1 + + print 'Total datasets in YAML: ' + str(len(yaml_commands.keys())) + print 'Missing datasets: ' + str(missingDatasets) + + +# foundFiles = [] +# for file in os.listdir(db_dir): +# filename = os.path.splitext(file)[0] +# #debug +# print 'filename: ' + filename +# if(filename not in yaml_commands): +# print 'yaml ' +# +# for dataset in yaml_commands: +# if(dataset in os.listdir(db_dir)) +# # TODO finish + +# CURRENTLY UNUSED +# helper function: uses mmap to delete a given set of positions from a file +def deleteFromMmap(f, mm, start, end): + length = end - start + size = len(mm) + newsize = size - length + + mm.move(start,end,size-end) + mm.flush() + mm.close() + f.truncate(newsize) + mm = mmap.mmap(f.fileno(),0) + return mm + + +def getSampleTableName(vcf_file_loc): + return 'sample_' + getSampleName(vcf_file_loc) + +def getSampleName(vcf_file_loc): + return vcf_file_loc[0:len(vcf_file_loc) - 4].replace('.', '_').replace('-', '_').split('/')[-1] + +def getFilename(file_path): + return os.path.split(file_path)[-1] + +def stripChrPrefix(vcf_filepath, out_dir, skip_if_exists=False): + print 'Stripping chr prefix from VCF CHROM column (if present)' + vcf_name = getSampleName(vcf_filepath) + outfilepath = os.path.join(out_dir, vcf_name+'_strippedChr' + '.vcf.gz') + if(skip_if_exists and os.path.isfile(outfilepath)): + print 'Reusing existing stripped chr VCF file at ' + outfilepath + return outfilepath + #else + #strip chr prefix + vcf = open_compressed_or_regular(vcf_filepath, 'r') + out = open_compressed_or_regular(outfilepath, 'w') + + for line in vcf: + if(line.startswith('#')): + out.write(line) + continue + #else + lineContents = line.rstrip("\n").split("\t") + chrom = lineContents[0] + if(chrom.startswith('chr')): + chrom = chrom[3:] # strip 'chr' prefix + lineContents[0] = chrom + newline = "\t".join(lineContents)+"\n" + out.write(newline) + + return outfilepath + + +# splits multiallelic site in VCF into separate rows using bcftools +def splitMultiallelic(vcf_filepath, out_dir, skip_if_exists=False): + print 'Converting VCF so there is only 1 allele per line' + vcf_name = getSampleName(vcf_filepath) + outfilepath = os.path.join(out_dir, vcf_name + '_noMultiallelic' + '.vcf.gz') + if(skip_if_exists and os.path.isfile(outfilepath)): + print 'Reusing existing converted VCF file at ' + outfilepath + return outfilepath + #else + cmd = "bcftools norm -m - '{vcf_filepath}' -O z -o '{out_dir}'".format(vcf_filepath=vcf_filepath, out_dir=outfilepath) + + subprocess.Popen(cmd, shell=True).wait() + return outfilepath + + +def stripVCFComments(vcf_filepath, out_dir): + print 'Removing extra fields (##) from VCF' + vcf_name = getSampleName(vcf_filepath) + outfilepath = os.path.join(out_dir, vcf_name + '_noComments' + '.vcf') + cmd = 'grep -v "^##" {vcf_filepath} > {vcf_outfile}'.format(vcf_filepath = vcf_filepath, vcf_outfile = outfilepath) + subprocess.Popen(cmd, shell=True).wait() + return outfilepath + + +def annovar_annotate_functional(vcf_file_loc, output_dir, buildver='hg19', humandb_loc=os.path.join(ANNOVAR_PATH, 'humandb'), genedefs=['refGene', 'knownGene', 'wgEncodeGencodeBasicV19']): + sample_name = getSampleName(vcf_file_loc) + print('Running annovar on ' + sample_name) + + outpathprefix = os.path.join(output_dir, 'annovar') + + # annotate + cmd = '{table_annovar} {vcf_file_loc} {humandb_loc} -buildver {buildver} -out {outprefix} -remove -protocol {protocols} -operation {operations} -vcfinput'.format(vcf_file_loc=vcf_file_loc, table_annovar = os.path.join(ANNOVAR_PATH, 'table_annovar.pl'), humandb_loc=humandb_loc, buildver=buildver, outprefix=outpathprefix, protocols=",".join(genedefs), operations=','.join("g" for i in range(0, len(genedefs)))) + + + outfile = os.path.join(output_dir, 'annovar' + '.' + buildver + '_multianno.txt') + + return [subprocess.Popen(cmd, shell=True), outfile] + + +# helper function to convert a VCF consisting of per-sample allele info to a VCF with just allele freqs using bcftools +# currently waits for completion, but could be easily made async (immediately returning what the output file name would be after completion) +def vcf2allelefreq(vcf_file_loc, output_dir, overwriteIfExists=False): + sample_name = getSampleName(vcf_file_loc) + outfilename = sample_name + '_alleleFreqs.vcf' + outfilepath = os.path.join(output_dir, outfilename) + if((not overwriteIfExists) and os.path.isfile(outfilepath)): + print 'skipped conversion of ' + sample_name + ' to allele freq VCF because already converted' + else: + cmd = "bcftools query -f '%CHROM\t%POS\t%ID\t%REF\t%ALT\t%AC\t%AN\n' " + vcf_file_loc + " | awk '{OFS=\"\t\";print $0,$6/$7}' > " + outfilepath + subprocess.Popen(cmd, shell=True).wait() + + return outfilename + + +def snpeff(vcf_file_loc, output_dir): + # In a subprocess, start a SnpEff run on the sample VCF, and output it to the user-designated folder. + # By returning the process pointer, a step where its completion is awaited can be added to the top-level + # master script. That way we don't need to hold things waiting for completion here. + sample_name = getSampleName(vcf_file_loc) + print("Running snpEff on " + sample_name) + cmd = "java -Xmx{memalloc} -jar {snpeff_jar} eff hg19 {vcf}".format(snpeff_jar = SNPEFF, vcf = vcf_file_loc, memalloc=SNPEFF_MEMORY_ALLOCATION) + #debug + print 'cmd: ' + cmd + annotated_vcf = os.path.join(output_dir, "{sample_name}.snpeff.vcf".format(sample_name = sample_name)) + p = subprocess.Popen(cmd, stdout = open_compressed_or_regular(annotated_vcf, 'w'), shell = True) + + return [p, sample_name, annotated_vcf] + + +# converts snpeff vcf file to tsv by removing lines with '#' +# snpeff_vcf_outfile = directory of this file +def snpeff2tsv(sample_name, snpeff_vcf_outfile, output_dir): + # strip comments from VCF to make it a tsv + cmd = "grep -v '^##' {vcf}".format(vcf = snpeff_vcf_outfile) + tsv_out_filePath = os.path.join(output_dir, "{sample_name}.snpeff.tsv".format(sample_name = sample_name)) + out_file = open(tsv_out_filePath, 'w') + subprocess.Popen(cmd, stdout = out_file, shell=True).wait() + + return tsv_out_filePath + +#writes the given text to the file, overwriting anything else in the file +# NOTE: automatically writes "\n" at end of text (similar to print command) +def writef(file_path, text): + f = open_compressed_or_regular(file_path, 'w') + f.write(text + "\n") + f.close() + + +def getVCFHeader(vcf_file_loc): + vcf = open_compressed_or_regular(vcf_file_loc, 'r') + for line in vcf: + if(line[0] == '#' and line[1] != '#'): + vcf.close() + return line[1:].rstrip("\n") + + # else + print 'Error no header found in vcf ' + vcf_file_loc + vcf.close() + return '' + +#returns filename without extension +def stripExtension(filename): + return filename.split('.')[0] + +# converts VCF to TSV, extracting each specified tag from the INFO column and listing it as a seperate column in the output TSV +def vcf2tsv(vcf_path, tags, output_dir, output_extension='.tsv'): + vcf_filename = getFilename(vcf_path) + vcf_filename_noExtension = stripExtension(vcf_filename) + outpath = os.path.join(output_dir, vcf_filename_noExtension+output_extension) + vcfHeader = getVCFHeader(vcf_path) + vcfCols = vcfHeader.split("\t") + header = '#' + "\t".join(vcfCols[:-1]) + "\t" + "\t".join(tags) + #write header + writef(outpath, header) + # then write data + tagStrs = [] + for tag in tags: + tagStrs.append('%INFO/{tag}'.format(tag=tag)) + vcfColStrs = [] + for col in vcfCols: + vcfColStrs.append('%' + col) + cmd = "bcftools query -f '{vcfCols}\t{joinedTags}\n' {vcf}".format(vcfCols = "\t".join(vcfColStrs[:-1]), joinedTags="\t".join(tagStrs), vcf=vcf_path) + subprocess.Popen(cmd, stdout = open_compressed_or_regular(outpath, 'a'), shell=True).wait() + + return outpath + + +# generates path for final annotated output file (can be used to find this file if it has already been generated in a previous run) +def generateJoinedOutfilePath(output_dir, sample_name): + return os.path.join(output_dir, "{sample_name}.annotated.all.tsv".format(sample_name = sample_name)) + +# # checks the 2 lines to make sure gene, chr, ref, alt are the same (based on whichever are present in both lines) +# def checkLines(line1, line2): +# chrKeys = ['chr', 'chrom', 'chromosome'] +# startKeys = ['start', 'begin', 'pos'] +# end + +# joins the files together to form 1 big annotated TSV +# NOTE: requires all files to have exactly the same # of lines in the same order +# Also will not work properly if point or region annotation output files have multiple header lines (which start with #) +def joinFiles(inputVCF, snpeff_tsv, annovar_tsv, region_tsv, point_tsv, output_dir, skipJoinCheck, skip=False): # by default, don't skip in case the output file was updated + + print 'Merging all annotations into a single file' + + ivh = open_compressed_or_regular(inputVCF, "r") + snpeff = open(snpeff_tsv, "r") + annovar = open(annovar_tsv, "r") + region = open(region_tsv, "r") + point = open(point_tsv, "r") + + out_filepath = generateJoinedOutfilePath(output_dir, getSampleName(inputVCF)) + output = open(out_filepath, "w") + + allCols = {} + fileCols = [] + foundAnnovarHeader = False + + lineNum = -1 + for (vcfLineNum, line) in enumerate(ivh): + if(line[0:2] != '##'): + lineNum += 1 + line = line.rstrip("\n") + + # remove "." and " " + + # add existing cols to hash to prevent duplicate columns in final output + if(line.startswith('#')): + for col in line.split("\t"): + if col.lower() not in allCols: + allCols[col.lower()] = 1 + + pointLine = point.readline() + regionLine = region.readline() + snpeffLine = snpeff.readline() + annoLine = annovar.readline() + + + # check lines to make sure the rows are aligned + if(not skipJoinCheck): + # point check + if(not pointLine.startswith('#')): + ptLineStr = pointLine.rstrip("\n").split("\t")[0:7] # chr, coord, id, ref, alt, qual, filter, info + inLineStr = line.split("\t")[0:7] + if(ptLineStr != inLineStr): + print 'Warning joining annotations: input VCF line ' + str(vcfLineNum) + ' does not match point annot line ' + str(lineNum) + print 'point annot line excerpt: ' + str(ptLineStr) + print 'input VCF line excerpt: ' + str(inLineStr) + + # annovar check + if(not annoLine.startswith('#')): + annoCols = annoLine.rstrip("\n").split("\t") + chr = annoCols[0] + start = annoCols[1] + stop = annoCols[2] + ref = annoCols[3] + alt = annoCols[4] + inCols = line.split("\t") + if(not (annoCols[0] == inCols[0] # chr + and inCols[1] == annoCols[1] # start + #and inCols[1] <= annoCols[2] # stop + and inCols[3] == annoCols[3] # ref + and inCols[4] == annoCols[4] # alt + ) + and annoCols[3] != '-' and annoCols[3] != '.' and annoCols[3] != '0' + and annoCols[4] != '-' and annoCols[4] != '.' and annoCols[4] != '0' + and inCols[3] != '-' and inCols[3] != '.' and inCols[3] != '0' + and inCols[4] != '-' and inCols[4] != '.' and inCols[4] != '0' + ): + print 'Warning joining annovar functional annotations: input vcf line ' + str(vcfLineNum) + ' does not match annovar line ' + str(lineNum) + icp = inCols[0:2] + icp.extend(inCols[3:5]) + acp = annoCols[0:2] + acp.extend(annoCols[3:5]) + print 'input vcf line (partial): ' + str("\t".join(icp)) + print 'annovar line (partial): ' + str("\t".join(acp)) + + # region check + # TODO finish + + + # deal with annoLine separately + annoLine = annoLine.rstrip("\n") + if(not foundAnnovarHeader): # first line is header in annovar + annoLine = annoLine.replace('.', '_') + annovarHeader = annoLine + # prepend "Annovar_" to each column in the annovar header + annovarHeaderCols = annovarHeader.split("\t") + for idx,col in enumerate(annovarHeaderCols): + annovarHeaderCols[idx] = 'Annovar_' + col + annovarHeader = "\t".join(annovarHeaderCols) + annoLine = annovarHeader # since we print out header from annoLine below + foundAnnovarHeader = True + line = line + "\t" + "\t".join(annoLine.split("\t")[5:len(annovarHeader.split("\t"))-1]) # include all columns except the last one (Otherinfo), which spans multiple columns + + # deal with other lines +# for fileIndex, line2 in enumerate([snpeffLine, pointLine, regionLine]): + for fileIndex, line2 in enumerate([pointLine, regionLine]): # for now, exclude snpeff since it annotates in the INFO column which is trickier to merge + line2 = line2.rstrip("\n") + lineContents = line2.split("\t") + if(line.startswith('#')): #header - warning: will not work properly if multiple header lines + outputCols = [] + for idx, col in enumerate(lineContents): + if(col.lower() not in allCols + and not col.lower().endswith('chrom') # we already have these + and not col.lower().endswith('pos') + and not col.lower().endswith('coord') + and not col.lower().endswith('ref') + and not col.lower().endswith('alt') + and col.lower() != 'chromosome' # same as CHROM + and col.lower() != 'coordinate' # same as POS + and col.lower() != 'reference' # same as REF + and col.lower() != 'alternate' # same as ALT + and col != '' + ): + allCols[col.lower()] = 1 + outputCols.append(idx) + + fileCols.append(outputCols) + + lineAddArr = [] + + for i in fileCols[fileIndex]: + if (i < len(lineContents)): + lineAddArr.append(lineContents[i]) + else: + lineAddArr.append('') + line = line + "\t" + "\t".join(lineAddArr) + + #process lines + line = line.replace('#', '') # '#' messes up import into R + + # convert any . to '' in a given entry (to be consistent) + lineElts = line.split("\t") + for idx, lineElt in enumerate(lineElts): + if(lineElt.lstrip().rstrip() == '.' or lineElt.lstrip().rstrip() == ''): + lineElt = '' + lineElts[idx] = lineElt + line = "\t".join(lineElts) + + output.write(line + "\n") + + return out_filepath + + +def root_or_cwd(dir): + # If the user has specified a file using a partial filepath relative to the current working directory, complete that path so that + # the file may be located. If the filepath is absolute (i.e. starting from the root directory) then leave it alone. + + if dir[0] != '/': + return os.path.join(os.getcwd(), dir) # merge the current working directory to the provided partial path + else: + return(dir) # no change + +# loads YAML file and returns content as nested python dictionaries/arrays +def parse_yaml(loc): + # Parse a YAML file which will instruct the annotation steps to be completed. + with open(loc, "r") as stream: + yaml_commands = yaml.safe_load(stream) + return yaml_commands + +# converts a relative path to an absolute path with respect to the directory where this script is located (NOT the current working directory) +def relativeToAbsolutePath_scriptDir(relativePath): + script_dir = os.path.dirname(os.path.realpath(__file__)) + if(not relativePath.startswith('/')): + relativePath = os.path.join(script_dir, relativePath) + return relativePath + +# connect to SQLite database +def connect_db(db_file, host_name='', user_name='', db_name='', unix_socket_loc=''): + + db_file = os.path.abspath(db_file) + +# # TODO use relativeToAbsolutePath helper function above +# script_dir = os.path.dirname(os.path.realpath(__file__)) +# # os.path.abspath(db_file) +# if(not db_file.startswith('/')): +# db_file = os.path.join(script_dir, db_file) + + print 'using database file: ' + db_file + if(not os.path.exists(os.path.dirname(db_file))): + os.makedirs(os.path.dirname(db_file)) + + return sqlite3.connect(db_file) + + +# gets filename from url +def url2filename(url): + return url.split('/')[-1] + + +# converts YAML type (e.g. char) to database type (e.g. varchar(1)) +def yamlTypeToDBType(yamlType): + if(yamlType.lower() == 'character' or yamlType.lower() == 'char'): + return 'varchar(1)' + else: + return yamlType + +# looks up SQLite data types for standard VCF columns +def getVCFColTypes(colHeaders): + colTypes = [] + for header in colHeaders: + if(header.lower() in vcfHeaders.kVCFColTypes): + colTypes.append(vcfHeaders.kVCFColTypes[header.lower()]) + else: + print 'error could not find type of column ' + header + colTypes.append('') + + return colTypes + + +def is_region_dataset(dataset_name): + return dataset_name.endswith('_r') + +# gets name of column referring to "starting" position (startKey), whether it is called "start", "begin", "pos", etc. +# TODO use this method when forming sql queries instead of inline code to find startKey +def getStartKey(colHeadersLowercase, startKeys): + for startKey in startKeys: + if(startKey.lower() in colHeadersLowercase): + return startKey.lower() + + print 'could not get startKey' + return '' + +# whether a given set of column headers has an end position (i.e. refers to a range) +def hasEndKey(colHeaders, endKeys): + for colHeader in colHeaders: + if(colHeader.lower() in endKeys): + return True + return False + +# whether any heaeder in the given list of columns matches a key in the list of keys. +# NOTE: colHeaders are converted to lowercase, keys are NOT (so must be lowercase to begin with). +def hasKey(colHeaders, keys): + return hasEndKey(colHeaders, keys) + +# detects variants of chrom, start, stop, ref, alt and changes them to these standard names for consistency +# NOTE: CURRENTLY UNUSED (standardizeColHeaders below is used instead) +def standardizeYamlHeader(db_yaml): + colHeadersLc = makeListLowercase(db_yaml['ColumnHeaders']) + chrIdx = listInLcList(CHR_HEADERS, colHeadersLc) + if(chrIdx != None): + db_yaml['ColumnHeaders'][chrIdx] = 'chrom' + startIdx = listInLcList(START_COLUMN_HEADERS, colHeadersLc) + if(startIdx != None): + db_yaml['ColumnHeaders'][startIdx] = 'start' + stopIdx = listInLcList(STOP_COLUMN_HEADERS, colHeadersLc) + if(stopIdx != None): + db_yaml['ColumnHeaders'][stopIdx] = 'stop' + + return db_yaml + + +# detects variants of chrom, start, stop, ref, alt and changes them to these standard names for consistency +def standardizeColHeaders(colHeader): + colHeadersLc = makeListLowercase(colHeader) + chrIdx = listInLcList(CHR_HEADERS, colHeadersLc) + if(chrIdx != None): + colHeader[chrIdx] = 'chrom' + startIdx = listInLcList(START_COLUMN_HEADERS, colHeadersLc) + if(startIdx != None): + colHeader[startIdx] = 'start' + stopIdx = listInLcList(STOP_COLUMN_HEADERS, colHeadersLc) + if(stopIdx != None): + colHeader[stopIdx] = 'stop' + + return colHeader + + +## special DB import helper functions +# annotates existing clinvar TSV with star ratings +def clinvar_addStars(clinvar_tsv_path, colHeaders, colTypes, yaml_cmds, clinStarHeader=vcfHeaders.kClinvarStarHeader, output_dir=None): + + #debug + print 'clinvar tmp tsv path (prior to star annotation): ' + clinvar_tsv_path + + filename = getFilename(clinvar_tsv_path) + filename_noExtension = stripExtension(filename) + if(output_dir == None): + output_dir = os.path.dirname(clinvar_tsv_path) + outpath = os.path.join(output_dir, filename_noExtension+'.tsv') + infile = open(clinvar_tsv_path, 'r') + outfile = open(outpath, 'w') + header = [] + for line in infile: + line = line.rstrip("\n") + if(line.startswith('#')): + line = line[1:] + header = line.split("\t") + outfile.write('#' + line + "\t" + clinStarHeader + "\n") + continue + #else + star = vcfUtils.clinvarStars(line, header, yaml_cmds) + outfile.write(line + "\t" + str(star) + "\n") + + colHeaders.append(clinStarHeader) + colTypes.append('int') + +# outfile.close() +# os.chmod(outpath, 'g+rw') + + return outpath, colHeaders, colTypes + + +# loads datasets using info from the YAML file +def setup_db_yaml(database_connection, yaml_commands, skip=True): + c = database_connection.cursor() + + for db in yaml_commands: + + #load default info + datasetPath = yaml_commands['default']['Dataset_Path'] + if(not os.path.isabs(datasetPath)): + datasetPath = os.path.join(os.path.dirname(os.path.realpath(__file__)), datasetPath) + if not os.path.exists(datasetPath): + os.makedirs(datasetPath) + + if(db == 'default'): +# # build = yaml_commands['default']['Build'] # required +# datasetPath = yaml_commands['default']['Dataset_Path'] +# #debug +# print 'datasetpath: ' + str(datasetPath) +# if(not os.path.isabs(datasetPath)): +# datasetPath = os.path.join(os.path.dirname(os.path.realpath(__file__)), datasetPath) +# if not os.path.exists(datasetPath): +# os.makedirs(datasetPath) +# # databasePath[''] +# # ucsc_baseurl = yaml_commands['default']['UCSC_BaseURL'] # required +# # annovar_params = yaml_commands['default']['Parameter_Annovar'] if 'Parameter_Annovar' in yaml_commands['default'] else '' + continue + + #else + startLine = yaml_commands[db]['StartingLine'] if 'StartingLine' in yaml_commands[db] else 0 + #handle URL download + if yaml_commands[db]['Source'].lower().startswith('http:') or yaml_commands[db]['Source'].lower().startswith('https:') or yaml_commands[db]['Source'].lower().startswith('ftp:'): + filename = url2filename(yaml_commands[db]['Source']) + db_full_path = os.path.join(datasetPath, filename) # Complete the absolute path to the dataset text file. + if not os.path.isfile(db_full_path): + db_full_path = downloadDB(yaml_commands[db], db_full_path, datasetPath, 'URL') # for now, just URL downloads (no Annovar) + + #handle file path instead of URL + else: + db_full_path = root_or_cwd(yaml_commands[db]['Source']) + filename = getFilename(db_full_path) + + # now do the database import + c = database_connection.cursor() + + colHeaders = yaml_commands[db]['ColumnHeaders'] # headers/names of columns in input file + colTypes = yaml_commands[db]['DataType'] + + # if file is VCF, convert to TSV with desired INFO tags as columns + if(filename.endswith('.vcf') or filename.endswith('.vcf.gz')): + vcfHeader = getVCFHeader(db_full_path) + # convert to TSV (so each INFO tag goes in a separate column) + db_full_path = vcf2tsv(db_full_path, colHeaders, datasetPath, output_extension='.tmp.tsv' if yaml_commands[db]['Annotation']=='clinvar' else '.tsv') + # update colHeaders and types to reflect standard VCF cols + vcfHeaderCols = vcfHeader.split("\t")[:-1] # ignore INFO column + vcfTypes = getVCFColTypes(vcfHeaderCols) + colHeaders = vcfHeaderCols+colHeaders + colTypes = vcfTypes+colTypes + # update filename + filename = getFilename(db_full_path) + + # special extra conversion for clinvar + if(filename == 'clinvar.tmp.tsv'): # TODO maybe check top-level entry in YAML instead of this + [db_full_path, colHeaders, colTypes] = clinvar_addStars(db_full_path, colHeaders, colTypes, yaml_cmds=yaml_commands, clinStarHeader=vcfHeaders.kClinvarStarHeader) + filename = getFilename(db_full_path) + + + db_name = yaml_commands[db]['Annotation'].replace('.', '_').replace('-', '_') # get the name of the database from the YAML, replacing illegal characters + + if(hasEndKey(colHeaders, STOP_COLUMN_HEADERS)): + db_name += '_r' # indicate a DB to be used for region annotation + + #standardize column headers + colHeaders = standardizeColHeaders(colHeaders) + + #Skip tables already present (by name, that is) in the database. + c.execute('SELECT name FROM sqlite_master WHERE type = "table";') + tables= c.fetchall() + table_names = [t[0] for t in tables] + if (db_name in table_names or db_name + '_r' in table_names) and skip: # if the user has chosen to skip completed datasets and the table name is present in the database... + print("Skipped completed DB: " + db_name) + continue + elif db_name in table_names: # if user has chosen not to skip completed datasets and table name is present in the database + # drop table + c.execute("DROP table if exists '{table}';".format(table = db_name)) + elif db_name+'_r' in table_names: + c.execute("DROP table if exists '{table}';".format(table = db_name+'_r')) + + # get dataset column info + cols = [] + colIndices = {} + for idx,name in enumerate(colHeaders): + if(name != ''): + cols.append("'" + name + "'" + ' ' + "\"{type}\"".format(type=yamlTypeToDBType(colTypes[idx]))) + colIndices[name] = idx + + print 'loading ' + db_name + + + colHeaderKeysLower = set(k.lower() for k in colHeaders) + + chromKey = 'chrom' if hasKey(colHeaderKeysLower, CHR_HEADERS) else '' + startKey = 'start' if hasKey(colHeaderKeysLower, START_COLUMN_HEADERS) else '' + stopKey = 'stop' if hasKey(colHeaderKeysLower, STOP_COLUMN_HEADERS) else '' + + # create new table in our db + c.execute('BEGIN') + if(is_region_dataset(db_name)): + c.execute("create table if not exists {db_name}({cols},\ + primary key({chromkey}, {startkey}, {stopkey}));".format(db_name = db_name, stopkey=stopKey, chromkey=chromKey, startkey=startKey, cols = ", ".join(cols))) + c.execute("create index if not exists start_idx on {db_name}({startkey});".format(db_name = db_name, startkey=startKey)) + c.execute("create index if not exists stop_idx on {db_name}({stopkey});".format(db_name = db_name, stopkey=stopKey)) + c.execute("create index if not exists start_stop_idx on {db_name}({startkey}, {stopkey});".format(db_name = db_name, stopkey=stopKey, startkey=startKey)) + else: + query = "create table if not exists {db_name}({cols},\ + primary key({chromkey}, {startkey}, ref, alt));".format(db_name = db_name, chromkey=chromKey, startkey=startKey, cols = ", ".join(cols)) + c.execute(query) + c.execute("create index if not exists start_idx on {db_name}({startkey});".format(db_name = db_name, startkey=startKey)) + + # load data into our db + print 'loading file and updating table...' + db_import(c, db_full_path, db_name, startLine=startLine, colMappings=colIndices, isVCF=filename.endswith('.vcf'), escapeStr='#', enforceTableTypes=False) # header won't be incorrectly imported as long as prefixed with '#' + database_connection.commit() + print 'Done importing ' + db_name + + +# UNUSED and DEPRECATED - replaced by setup_db_yaml +def setup_db(db_dir, database_connection, skip): + # This script both updates extant datasets and creates new ones within the MySQL database. + # A block of code, commented with a line beginning with "format:", accommodates each format + # in which the incoming datasets may occur. A dataset is not updated/created when its name + # appears in the existing tables. + c = database_connection.cursor() + + for f in os.listdir(db_dir): # For each text dataset specified in the input directory + + # skip all subdirs + if os.path.isdir(f): + print 'skipping subdir ' + f + continue + + if (f.endswith('bcf.gz')): + # convert to vcf + db_full_path = os.path.join(db_dir, f) # Complete the absolute path to the dataset text file. + vcf2allelefreq(db_full_path, db_dir, not skip) + + # Note: will the for loop update and get to the newly converted file as well? + if f.endswith('txt') or f.endswith('tsv') or f.endswith('vcf'): # Using only the .txt and .vcf files... + db_name = f[0:len(f) - 4].replace('.', '_').replace('-', '_') # Parse the name of the database, replacing illegal characters. + db_full_path = os.path.join(db_dir, f) # Complete the absolute path to the dataset text file. + + #Skip tables already present (by name, that is) in the database. + c.execute('SELECT name FROM sqlite_master WHERE type = "table";') + tables= c.fetchall() + table_names = [t[0] for t in tables] + if (db_name in table_names or db_name + '_r' in table_names) and skip: # if the user has chosen to skip completed datasets and the table name is present in the database... + print("Skipped completed DB: " + db_name) + continue + + #comprehend format of database. + with open_compressed_or_regular(db_full_path) as db_txt: # open the database file... + + if f.endswith('vcf'): + print("Updating " + db_name) + # scan to find header + line = db_txt.readline() + print 'Scanning for VCF header' #debug + while(len(line) < 3 or line[1] == '#' or line [0] != '#'): + line = db_txt.readline() + if(len(line) == 0): + print 'Warning: no VCF header found. Assuming standard columns (chrom, start, id, ref, alt, qual, filter, info)' + break + + #header + header = line[1:].rstrip().split("\t") # omits leading # + + # start with standard columns (the first 8 columns) + cols = ['chrom varchar(10)', 'start int', 'id varchar(127)', 'ref varchar(512)', 'alt varchar(512)', 'qual varchar(127)', 'filter varchar(127)', 'info varchar(255)'] + colIndices = {'chrom': 0, 'start': 1, 'id': 2, 'ref':3, 'alt':4, 'qual':5, 'filter':6, 'info':7} + + # then deal with nonstandard columns + # note: currently ignores all columns that do not have a corresponding type in the lookup tables + for index, col in enumerate(header[8:]): + index += 8 # since we started at col 8 of header + foundType = False + if(col.lower() in stmp_consts.col_table_types_absolute): # make the column names lowercase for case-insensitive comparison + cols.append(col.lower() + ' ' + stmp_consts.col_table_types_absolute[col.lower()]) + colIndices[col.lower()] = index + foundType = True + else: # check prefixes dictionary (linear operation) + for prefix in stmp_consts.col_table_types_prefixes.keys(): + if(col.lower().startswith(prefix)): + cols.append(col.lower() + ' ' + prefix) + colIndices[col.lower()] = index + foundType = True + break + + if not foundType: + print 'Warning: unknown column ' + col + + # load into DB + c.execute("BEGIN") + c.execute("create table if not exists {db_name}({cols},\ + primary key(chrom, start, ref, alt));".format(db_name = db_name, cols = ", ".join(cols))) + c.execute("create index if not exists start_idx on {db_name}(start);".format(db_name = db_name)) + + print("loading file and updating table...") + db_import(c, db_full_path, db_name, 0, colIndices, '#') # start at line 0, using the appropriate column indices, and excluding lines beginning with '#' + database_connection.commit() + + + elif f.endswith('txt') or f.endswith('tsv'): + print 'text file: ' + f + # check for header and process accordingly + firstLine = db_txt.readline() + if(firstLine[0] == '#'): + header = firstLine[1:].rstrip().split("\t") + + # annovar popfreq_all + annovar_popfreq_colHeaders = ['Chr', 'Start', 'End', 'Ref', 'Alt', + 'PopFreqMax', '1000G_ALL', '1000G_AFR', + '1000G_AMR', '1000G_EAS', '1000G_EUR', + '1000G_SAS', 'ExAC_ALL', 'ExAC_AFR', + 'ExAC_AMR', 'ExAC_EAS', 'ExAC_FIN', 'ExAC_NFE', + 'ExAC_OTH', 'ExAC_SAS', 'ESP6500siv2_ALL', 'ESP6500siv2_AA', + 'ESP6500siv2_EA', 'CG46'] + if(header == annovar_popfreq_colHeaders): + print("Updating " + db_name) + c.execute("BEGIN") + c.execute("create table if not exists {db_name}(chrom varchar(10), start int, stop int, ref varchar(512), alt varchar(512), pop_freq_max float, '1000g_all' float, '1000g_afr' float, '1000g_amr' float, '1000g_eas' float, '1000g_eur' float, '1000g_sas' float, 'exac_all' float, 'exac_afr' float, 'exac_amr' float, 'exac_eas' float, 'exac_fin' float, exac_nfe float, exac_oth float, exac_sas float, esp6500siv2_all float, esp6500siv2_aa float, esp6500siv2_ea float, cg46 float, \ + primary key (chrom, start, stop, ref, alt));".format(db_name = db_name)) + c.execute("create index if not exists start_idx on {db_name}(start);".format(db_name = db_name)) + c.execute("create index if not exists stop_idx on {db_name}(stop);".format(db_name = db_name)) + c.execute("create index if not exists start_stop_idx on {db_name}(start, stop);".format(db_name = db_name)) + print("loading file and updating table...") + db_import(c, db_full_path, db_name, 1) # start at line 1, ignoring line 0 + database_connection.commit() + + else: + print 'Skipped DB without understood formatting: ' + db_name + + else: + db_txt.seek(0) # go back to the beginning of the db file + sample = db_txt.readlines(10)[-1].rstrip().split('\t') # ...and sample a few lines from it in order to see its format. + + #format: chrom, start, stop, ref, alt, info (where start = stop) + if len(sample) == 6 and str.isdigit(sample[0]) and str.isdigit(sample[1]) and str.isdigit(sample[2]) and str.isalpha(sample[3]) \ + and str.isalpha(sample[4]) and sample[1] == sample[2]: + print("Updating " + db_name) + c.execute("BEGIN") + c.execute("CREATE TABLE if not exists {db_name}(chrom varchar(10), start int, stop int, ref varchar(512), alt varchar(512), info varchar(255), \ + primary key (chrom, start, stop, ref, alt));".format(db_name = db_name)) # initialize the table if it doesn't already exist + c.execute("create index if not exists start_idx on {db_name}(start);".format(db_name = db_name)) + c.execute("create index if not exists stop_idx on {db_name}(stop);".format(db_name = db_name)) + c.execute("create index if not exists start_stop_idx on {db_name}(start, stop);".format(db_name = db_name)) + print("loading file and updating table...") + db_import(c, db_full_path, db_name, 1) # start at line 1, ignoring line 0 + database_connection.commit() + + #format: index, chrom with "chr" to be ignored, start, stop, info, ignored1, ignored2, ignored3, ignored4, ignored5 + #e.g. ['590', 'chr1', '760537', '761137', '6_Weak_Enhancer', '0', '.', '760537', '761137', '16776196'] + elif len(sample) == 10 and str.isdigit(sample[0]) and \ + str.isdigit(sample[2]) and str.isdigit(sample[3]) and str.isdigit(sample[4][0]) and str.isdigit(sample[5]) and sample[2] != sample[3]: + #label database as containing ranges, rather than single locations. This will inform the sort of merging which takes place later. + db_name = db_name + '_r' + + print("Updating " + db_name) + c.execute("BEGIN") + c.execute("CREATE TABLE if not exists {db_name}(chrom varchar(10), start int, stop int, info varchar(255), \ + primary key (chrom, start, stop, info));".format(db_name = db_name)) # initialize the table if it doesn't already exist + print("loading file and updating table...") + db_import(c, db_full_path, db_name, 1, {'chrom':1, 'start':2, 'stop':3, 'info':4}) + + #remove 'chr' + print("removing chr character") + c.execute("UPDATE {table} set chrom = replace(chrom, 'chr', '') where chrom like 'chr%'".format(table = db_name)) + database_connection.commit() + + #format: index, chrom with "chr" to be ignored, start, stop, info, info2 + # (e.g. clinvar region file) + elif len(sample) == 6 and str.isdigit(sample[0]) and str.isdigit(sample[2]) and str.isdigit(sample[3]): # TODO mb check more carefully + db_name = db_name + '_r' + print('Updating ' + db_name) + c.execute("BEGIN") + c.execute("CREATE TABLE if not exists '{db_name}'(chrom varchar(10), start int, stop int, info varchar(500), \ + primary key (chrom, start, stop, info));".format(db_name = db_name)) # initialize the table if it doesn't already exist + print("loading file and updating table...") + db_import(c, db_full_path, db_name, 0, {'chrom':1, 'start':2, 'stop':3, 'info':'4:6'}, enforceTableTypes=False) # ":" = same slicing notation as Python (goes from 4 to 6-1=5 in this case) # WARNING: CANNOT CHECK TYPE (e.g. int) bc chrom contains "chr" (and hence is initially string instead of int) + + #remove 'chr' + print("removing chr character") + c.execute("UPDATE {table} set chrom = replace(chrom, 'chr', '') where chrom like 'chr%'".format(table = db_name)) + database_connection.commit() + + + # format: chr start stop ref alt sift_score qual? pass? + elif len(sample) == 8 and str.isdigit(sample[0]) and str.isdigit(sample[1]) and str.isdigit(sample[2]) and str.isalpha(sample[3]) and str.isalpha(sample[4]) and str.isdigit(sample[5]): +# db_name = db_name + '_r' # won't work for region annotation bc not VCF (region annotation just uses the info field). Since start and stop appear to always be the same for avsift though, it doesn't matter. + print 'Updating ' + db_name + c.execute("BEGIN") + c.execute("CREATE TABLE if not exists '{db_name}'(chrom varchar(10), start int, stop int, ref varchar(512), alt varchar(512), score double, column7 varchar(10), column8 varchar(10), \ + primary key (chrom, start, stop));".format(db_name = db_name)) # initialize the table if it doesn't already exist + print("loading file and updating table...") + db_import(c, db_full_path, db_name, 0, enforceTableTypes=False) + + database_connection.commit() + + + # unknown formatting + else: + print("Skipped db without understood formatting: " + db_name) + pass + + + +def makeListLowercase(list1): + list2 = [] + for item in list1: + list2.append(item.lower()) + return list2 + +# checks if ANY of the items in list are in the lc list +# returns index in the lclist or None if not found +def listInLcList(list1, lclist): + for item in list1: + if item.lower() in lclist: + return lclist.index(item.lower()) + return None + +# reorders columns so the standard columns (chrom, start, stop, ref, alt) are in the proper order when we create the table in our database +# currently requires STANDARD lowercase column names (chrom, start, stop, ref, alt), NOT alternate names (e.g. chr) +def reorderColumns(colNamesLc): + if('chrom' in colNamesLc): + colNamesLc.remove('chrom') + colNamesLc.insert(0, 'chrom') + if('start' in colNamesLc): + colNamesLc.remove('start') + colNamesLc.insert(1, 'start') + if('stop' in colNamesLc): + colNamesLc.remove('stop') + colNamesLc.insert(2, 'stop') + if('ref' in colNamesLc): + colNamesLc.remove('ref') + colNamesLc.insert(3, 'ref') + if('alt' in colNamesLc): + colNamesLc.remove('alt') + colNamesLc.insert(4, 'alt') + + return colNamesLc + + +# generates bed files from region tables in our database so we can use bedtools to perform the region annotation +def generate_bed_formatted_dbs(database_connection, table_names, db_bed_dir): + print("Generating bed-formatted temporary tables") + + db_bed_dir = relativeToAbsolutePath_scriptDir(db_bed_dir) + + if(not os.path.exists(db_bed_dir)): + os.makedirs(db_bed_dir) +# if not os.path.exists(BED_FORMATTED_DB_TMP_DIR): +# os.makedirs(BED_FORMATTED_DB_TMP_DIR) + + c = database_connection.cursor() + + tables_and_files = [(table, os.path.join(db_bed_dir, table + '.bed')) for table in table_names] + + for t,f in tables_and_files: + if not os.path.isfile(f): + print("Generating BED for " + t) + columnsInfo = getColumnsOfTable(c, t) + colNamesLc = [] + # get column nmes + for columnInfo in columnsInfo: + colNamesLc.append(str(columnInfo[1]).lower()) + # check for standard columns (chrom, start, stop, ref, alt) and add them in proper order + colNamesLc = reorderColumns(colNamesLc) + + # for bedtools, only pull the rows that have genomic coordinates and positive start coordinate + cmd = "SELECT {colnames} from '{t}' where start != '' and stop != '' and start >= 0;".format(t=t, f=f, colnames = ', '.join(colNamesLc)) + + # write header - NOTE: DOES NOT INCLUDE CHR, START, STOP (only the columns after these, aka the cols that need to be split up when parsing the intersected file) + headerf = getHeaderFile(f) + headerout = open(headerf, 'w') + headerout.write("\t".join([t+'_'+colname for colname in colNamesLc[3:]]) + "\n") + + with open(f, 'w') as outfile: + for row in c.execute(cmd): + strings = [] + infoArr = [] + for idx,x in enumerate(row): + if type(x) is int or type(x) is float or type(x) is str: + x2 = str(x) + x2 = x2.encode('utf8') + else: + x2 = x.encode('utf8') + if(idx < 3): # chr, start, stop + strings.append(x2) + else: # extra info -> we'll put it all in the "name" column of the BED file + infoArr.append(x2) + + #make name column + name = BED_DELIMITER.join(infoArr) + strings.append(name) + + #now write our 4 columns to BED file + outstr = "\t".join(strings) + outfile.write(outstr + "\n") + + else: + print("Reusing existing BED for " + t) + + database_connection.commit() + + +# exception handling +def PrintException(): + exc_type, exc_obj, tb = sys.exc_info() + f = tb.tb_frame + lineno = tb.tb_lineno + filename = f.f_code.co_filename + linecache.checkcache(filename) + line = linecache.getline(filename, lineno, f.f_globals) + print 'EXCEPTION IN ({}, LINE {} "{}"): {}'.format(filename, lineno, line.strip(), exc_obj) + + +# gets our generated header file for the given bed file (file with the same name as the BED file but ends in .bed.header instead of .bed) +def getHeaderFile(bed_file_path): + return bed_file_path.replace('.bed', '.bed.header') + + +def annotate_range(database_connection, vcf_file_loc, output_dir_loc, db_bed_dir, skip=False, print_range_cmd_only=False, presorted_vcf=False): + intersected_tmp_dir = os.path.join(output_dir_loc, 'intersected_beds') # TODO make scratch dir a separate param for this function + db_bed_dir = relativeToAbsolutePath_scriptDir(db_bed_dir) + + c = database_connection.cursor() + sample_name = 'sample_' + vcf_file_loc[0:len(vcf_file_loc) - 4].replace('.', '_').replace('-', '_').split('/')[-1] + out_file_loc = os.path.join(output_dir_loc, sample_name + "_annotated.tsv") + + print("Annotating variants for sample " + sample_name) + + c.execute('SELECT name FROM sqlite_master WHERE type = "table";') + tables= c.fetchall() + + #determine which tables involve ranges (start != stop) and which are single location (start == stop) + range_tables = [t[0] for t in tables if t[0].endswith('_r') and not t[0].startswith('sample')] + + #perform BEDtools intersections with the range tables + print("Performing BEDtools intersections with {tabs} tables".format(tabs = len(range_tables))) + + generate_bed_formatted_dbs(database_connection, range_tables, db_bed_dir=db_bed_dir) + + processes = [] + + if not os.path.exists(intersected_tmp_dir): + os.makedirs(intersected_tmp_dir) + + for t in range_tables: + out_file_loc = os.path.join(intersected_tmp_dir, sample_name + '_isect_' + t + '.tab') + bed_file_path = os.path.join(db_bed_dir, t + '.bed') + + try: +# cmd = "(cat {header}; intersectBed -a {vcf_file_loc} -b {fname} -loj | {condense})".format( # WARNING should be 'cut -f13' after condense? + cmd = "(cat {header}; intersectBed -a {vcf_file_loc} -b {fname} -loj | {condense} | cut -f13)".format( + header = getHeaderFile(bed_file_path), + vcf_file_loc = vcf_file_loc, + fname = bed_file_path, + condense = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'condense_intersectBed_output.py') + ) + + if(print_range_cmd_only): + print 'range cmd: ' + cmd + else: + processes.append(subprocess.Popen(cmd, stdout = open(out_file_loc, 'w'), shell = True)) + except: + PrintException() + + if(print_range_cmd_only): + return + + for p in processes: + p.wait() + + annotations = [os.path.join(intersected_tmp_dir, f) for f in os.listdir(intersected_tmp_dir)] + + out_filepath = os.path.join(output_dir_loc, "{name}.range_joined.vcf".format(name = sample_name)) + + out_file = open(out_filepath, 'w') + + # open each intersected file + files = [] + fileHeaders = {} # dictionary of arrays by filename + for file1 in annotations: + f = open(file1, 'r') + files.append(f) + fileHeaders[f] = f.readline().rstrip("\n").split("\t") # header split by tab, not bed delimiter + f.seek(0) # reset file pos so we correctly read and print out header below + + try: + def mergeFiles(): + currPos = 0 + while True: + lineContents = [] + for file1 in files: + fl = file1.readline().rstrip("\n") + if(len(fl) == 0 or fl == '.'): + # extend lineContents by appropriate # of blank columns + lineContents.extend(['']*len(fileHeaders[file1])) + else: + flc = fl.split(BED_DELIMITER) + lineContents.extend(flc) + out_file.write("\t".join(lineContents) + "\n") + + #check for EOF + newPos = files[0].tell() + if(newPos == currPos): + print 'done with intersectbed merge' + return + currPos = newPos + + mergeFiles() + + except StopIteration: # never gets called + # done writing + print 'done with intersectbed merge' + + print 'Finished bedtools region (range) annotation' + + return out_filepath + + +# escapes the elts in the array with single quotes '' +def escapeElts(array): + array2 = [] + for elt in array: + array2.append("'" + elt + "'") + + return array2 + + +# prints the given string every [interval] s or longer (depending on how often this method is called). Call it each time the progress (e.g. line number) changes. +# NOTE: prevTime and interval must be in SECONDS +def print_progress_timed(progressStr, prevTime, interval=5): + currtime = datetime.datetime.now().second + if(abs(currtime - prevTime) > interval): + print str(datetime.datetime.now()) + ': ' + progressStr + return currtime + #else + return prevTime + +#returns an array with info about each column (column[1] = name, column[2] = type) +def getColumnsOfTable(db_connection_cursor, tablename): + db_connection_cursor.execute('pragma table_info({table});'.format(table=tablename)) + columns = db_connection_cursor.fetchall(); + return columns + +# Helper method to import the contents of a TSV/VCF/vcf.gz file to a given table in the database +# colMappings = hash mapping field names in the table to column #s in the file (starting at 0) +# e.g. "chrom" -> 1 +# escapeStr = escape string for input data file (so it can ignore these lines) -> e.g. '#' +# printDebug = whether or not to print debug messages +# TODO: add option to do something other than replace if the elt to be inserted already exists +def db_import(db_connection_cursor, filename, tablename, startLine=0, colMappings={}, escapeStr='', isVCF=False, printDebug=False, enforceTableTypes=True, stripChrIfPresent=True): + if(printDebug): + print 'filename: ' + filename + + db_connection_cursor.execute('pragma table_info({table});'.format(table=tablename)) + columns = db_connection_cursor.fetchall(); + colTypes = [] + for column in columns: + name = column[1] + colType = column[2] + colTypes.append(colType) + + entries = [] # will be list of tuples to add to db + + colNames = colMappings.keys() + + # imports all current entries into the db, clearing the entries array afterward + # uses colNames from outer function scope + def importEntries(entries): + colNameStr = '' + if(len(colNames) > 0): + colNameStr = '(' + ", ".join(escapeElts(colNames)) + ")" + db_connection_cursor.executemany("insert or replace into {tablename}{colNameStr} values ({vals});" + .format(tablename=tablename, + colNameStr=colNameStr, + vals=", ".join("?" for i in range(0, len(entries[0])))), + entries) + entries = [] # clear entries array since done importing + return entries + + with open_compressed_or_regular(filename, 'r') as f: + for i in range (0, startLine): + next(f) # skip lines until we reach the desired start point + + idx = 0 + prevTime = datetime.datetime.now().second + + for line in f: + #strip trailing newline + line = line.rstrip("\n") + + # print our progress (line #) + prevTime = print_progress_timed('importing line ' + str(idx) + ' of ' + tablename, prevTime) + idx += 1; + + line = line.decode('utf-8', 'ignore') # in case there are any byte-strings, convert them to utf-8 or ignore them if they can't be converted. This avoids potential errors when trying to add bytestrings to the sqlite db. + if(len(escapeStr) == 0 or line[0:len(escapeStr)] != escapeStr): + lineContents = line.split("\t") + if printDebug: + print 'got line: ' + line + if(len(colNames) > 0): # extract specific columns/VCF tags from file + colVals = [] + for colName in colNames: + if(colName.lower() in CHR_HEADERS): + #strip 'chr' prefix if present in line data (e.g. 'chr1' becomes just '1') + if(lineContents[colMappings[colName]].startswith('chr')): + lineContents[colMappings[colName]] = lineContents[colMappings[colName]][3:] + if(isinstance(colMappings[colName], (int))): + colVals.append(lineContents[colMappings[colName]]) # add column values in appropriate order + + else: # colMappings[colName] is of the form #:# to indicate a range of columns that should be merged using | to separate them + col_range = colMappings[colName] + col_range = col_range.split(":") + colVals.append("|".join(lineContents[int(col_range[0]):int(col_range[1])])) # TODO maybe make the delimiter customizable + + # verify that columns are of valid type, if type enforcing enabled + addtoEntries = True + + if(enforceTableTypes): + for idx,colVal in enumerate(colVals): + if( + (colTypes[idx].startswith('int') and not colVal.isdigit()) + ): + addtoEntries = False + break + + if(addtoEntries): + colTuple = tuple(colVals) + entries.append(colTuple) + if printDebug: + print 'appended tuple ' + str(colTuple) + 'to entries' + + # bunch into chunks of 1000 entries for improved load performance + if(len(entries) > 1000): + entries = importEntries(entries) + + else: # add all columns from file + addtoEntries = True + + if(enforceTableTypes): + for idx,colVal in enumerate(lineContents): + if( + (colTypes[idx].startswith('int') and not colVal.isdigit()) + ): + print 'warning: ' + str(colVal) + ' is not of type ' + str(colTypes[idx]) + ' and will be ignored for row ' + str(lineContents) + addtoEntries = False + break + + if(addtoEntries): + colTuple = tuple(lineContents) + entries.append(colTuple) + if(len(entries) > 1000): + entries = importEntries(entries) + + else: # line has escape str + None + + # import any remaining entries (<=1000) + if(len(entries) > 0): + entries = importEntries(entries) + + +#drops a single sample table (used for dropping the sample table after annotation, if specified) +def drop_sample(database_connection, vcf_file_loc): + sampleTableName = getSampleTableName(vcf_file_loc) + print 'Dropping sample table ' + sampleTableName + ' from the database' + c = database_connection.cursor() + c.execute("DROP table if exists '{table}';".format(table = sampleTableName)) + +# drops all tables beginning with "sample_" +def drop_samples(database_connection): + print 'Dropping all sample tables from database' + + c = database_connection.cursor() + c.execute('SELECT name FROM sqlite_master WHERE type = "table";') + tables= c.fetchall() + for table in tables: + if(table[0].startswith('sample')): + c.execute('drop table {table};'.format(table=table[0])) + + +# perform point annotation +def annotate_point(database_connection, vcf_file_loc, output_dir_loc, sample_db_path, print_sql_query_only=False, debug=False): + c = database_connection.cursor() + sample_name = 'sample_' + vcf_file_loc[0:len(vcf_file_loc) - 4].replace('.', '_').replace('-', '_').split('/')[-1] + out_file_loc = os.path.join(output_dir_loc, sample_name + ".point_annotated.tsv") + + print("Annotating variants for sample " + sample_name) + + # attach sample db + c.execute('attach "{sample_db}" as sample;'.format(sample_db=sample_db_path)) + + c.execute('SELECT name FROM sqlite_master WHERE type = "table";') + tables= c.fetchall() + + # perform SQL join with locus tables + locus_tables = [t[0] for t in tables if not t[0].endswith('_r') and not t[0].startswith('sample')] + print("Performing SQL join with {tabs} tables:".format(tabs = len(locus_tables))) + print('\n'.join(locus_tables)) + + cmd = '' # initialize command text + + #returns whether or not to include the given table (reused in 3 different places) + def include_table(table): + #debug - pt annotation +# return not table.startswith('sample') and table == 'clinvar' + return not table.startswith('sample') + + # generate headers + cmd += "select 'Chromosome', 'Coordinate', 'ID', 'Reference', 'Alternate', 'Qual', 'Filter', 'Info'" + for table in locus_tables: + if include_table(table): + c.execute("PRAGMA table_info('{table}');".format(table=table)) # get list of columns in table. Warning: this is specific to sqlite + columns = c.fetchall() + for column in columns: + column = column[1] + if(column != 'chrom' and column != 'start' and column != 'stop' + and column != 'ref' and column != 'alt' + and column != 'id' and column != 'qual' + and column != 'filter' + ): + cmd += ", '{db}_{column}'".format(db = table, column=column) + + cmd += '\nUNION ALL' + + # select output columns + cmd += "\nselect '{samp}'.*".format(samp = sample_name) + for table in locus_tables: + if include_table(table): + c.execute("PRAGMA table_info('{table}');".format(table=table)) # get list of columns in table. Warning: this is specific to sqlite + columns = c.fetchall() + for index, column in enumerate(columns): + column = column[1] + if(column != 'chrom' and column != 'start' and column != 'stop' + and column != 'ref' and column != 'alt' + and column != 'id' and column != 'qual' + and column != 'filter' + ): + #regular + cmd += ", ifnull({table}.'{column}','') as '{table}_{column}'".format(table = table, column=column) # add tab to keep columns separated + + #perform massive join + cmd += ' from ' + sample_name + for table in locus_tables: + if include_table(table): + cmd += "\nleft join {next_table} on {sample}.chrom = {next_table}.chrom and {sample}.start = {next_table}.start and {sample}.ref = {next_table}.ref and {sample}.alt = {next_table}.alt".format(next_table = table, sample = sample_name) + cmd += " where {sample}.id IS NOT NULL;".format(sample = sample_name) + + if(print_sql_query_only): + print 'point annotation cmd: ' + cmd + return # don't actually run the query or write to the file + + if os.path.isfile(out_file_loc): + call(["rm", out_file_loc]) + + print 'computing total number of lines to annotate' + lines_cmd = "grep -v '^##' {vcf}| wc -l".format(vcf=vcf_file_loc) + totalLines = (subprocess.check_output(lines_cmd, shell=True)).rstrip() + print 'total number of lines: ' + str(totalLines) + + print 'writing point annotation output file ' + out_file_loc + with open(out_file_loc, 'w') as f: + timer = datetime.datetime.now().second + idx = 0 + for row in c.execute(cmd): # seems to take a while on some input files + #progress tracking as this can take a while - output current row # once every 5 s + currtime = datetime.datetime.now().second + if(abs(currtime - timer) > 5): + percent = float(idx)/int(totalLines)*100 + print str(datetime.datetime.now()) + ': writing line ' + str(idx) + '/' + str(totalLines) + ' (' + '%.2f' % percent + '% complete)' + ' to point annotation file' + timer = currtime + + f.write("\t".join(str(x).strip("\n") for x in row) + "\n") + idx += 1 + + database_connection.commit() + + print 'finished writing point annotation output file' + + return out_file_loc + +def get_sample_db_path(db_dir, sample_name): + return os.path.join(db_dir, sample_name+'.sqlite') + +def upload_vcf(database_connection2, vcf_file_loc, db_dir, force_overwrite=False): +# c = database_connection.cursor() + sample_name = getSampleTableName(vcf_file_loc) + sample_db_path = get_sample_db_path(db_dir, sample_name) + database_connection = sqlite3.connect(sample_db_path) + c = database_connection.cursor() + + c.execute('SELECT name FROM sqlite_master WHERE type = "table";') + tables= [t[0] for t in c.fetchall()] + + if sample_name not in tables or force_overwrite: + print("Uploading VCF to database for sample " + sample_name) + c.execute("BEGIN") + c.execute("DROP table if exists '{table}';".format(table = sample_name)) + c.execute("CREATE TABLE '{table}'( \ + chrom varchar(10), \ + start int, \ + id varchar(127), \ + ref varchar(512), \ + alt varchar(512), \ + qual varchar(127), \ + filter varchar(127), \ + info varchar(255), \ + primary key(chrom, start, ref, alt));".format(table = sample_name)) # initialize the table if it doesn't already exist + + print("updating VCF table...") + db_import(c, vcf_file_loc, sample_name, 1, {'chrom':0, 'start':1, 'id':2, 'ref':3, 'alt':4, 'qual':5, 'filter':6, 'info':7}, '#') + database_connection.commit() + else: + print(sample_name + " found in database. Beginning annotation without re-upload.") + + return sample_db_path + + diff --git a/code/stmp_consts.py b/code/stmp_consts.py new file mode 100644 index 0000000..45f2c9e --- /dev/null +++ b/code/stmp_consts.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python + +''' +Author: Prag Batra + +Purpose: + + Provides a single place to keep track of all constants used in STMP. + +Explanation: + + See purpose above. Note: all column names should be lowercase + for comparison purposes. + +Example: + + For usage, see stmp2.py where these methods are all called. + +''' + +import collections +from collections import OrderedDict + +# annotation_db_file = 'data/annotationDB.sqlite' +# db_beds_dir = 'data/db_beds' +tiering_db_file = 'data/tieringDB.sqlite' + +# must exactly match the given column name +# NOTE: the standard VCF columns (chrom, start, id, ref, alt, qual, filter, info) are currently hardcoded so this dictinary is ignored for these values +col_table_types_absolute = { + 'chr': 'varchar(10)', + 'chrom': 'varchar(10)', + 'start': 'int', + 'stop': 'int', + 'ref': 'varchar(512)', + 'alt': 'varchar(512)', + 'pop_freq_max': 'float', + 'info': 'varchar(255)', + 'format': 'varchar(255)' + } + +# Only needs to match the beginning of the given column name. +# These are listed in search order (first match is the one used). +col_table_types_prefixes = OrderedDict([ + ('shuffle_wellderly', 'varchar(255)') + ]) + +# { +# 'shuffle_wellderly': 'varchar(255)' +# +# } + diff --git a/code/stmp_tiering_util.py b/code/stmp_tiering_util.py new file mode 100644 index 0000000..3ec9d77 --- /dev/null +++ b/code/stmp_tiering_util.py @@ -0,0 +1,248 @@ +#!/usr/bin/env python + +''' +Author: Prag Batra prag@stanford.edu + +Purpose: + + All the heavy lifting for tiering happens here. + +Explanation: + + Classifies variant annotations into different tiers of potential pathogenicity according to various criteria. + +Example: + + For usage, see stmp.py where these methods are all called. + +''' + +import vcfUtils +import vcfHeaders +import sys + +#function for tier 1,2,3,4 targeted calls in specified gene regions, infile is from stanovar vcf +# pop = population our sample comes from +# freq = frequency cutoff +def tiers_allvars(in_file, out_stem, gene_file, pop, yaml_cmds, freq=0.01, geneNameCol=82): + #open input and output files and initialize counters and lists for background populations + filein = open(in_file, "r") + output_log = open(out_stem+".metrics", "w") + output_log.write("Metrics for stmp filtering, all variants from reference\n") + header = filein.readline().rstrip("\n") + headlist = header.split("\t") + g_file = open(gene_file, "r") + fileout0 = open(out_stem+".tier0.txt", 'w') + fileout1 = open(out_stem+".tier1.txt", "w") + fileout2 = open(out_stem+".tier2.txt", "w") + fileout3 = open(out_stem+".tier3.txt", "w") + fileout4 = open(out_stem+".tier4.txt", "w") + fileout0.write(header + "\n") + fileout1.write(header + "\n") + fileout2.write(header + "\n") + fileout3.write(header + "\n") + fileout4.write(header + "\n") + total = 0 + damaging0 = 0 + damaging1 = 0 + damaging2 = 0 + damaging3 = 0 + damaging4 = 0 + target_genes = 0 + rarevars = 0 + + if (pop == "CEU") or (pop == "c"): + backpoplist = vcfUtils.get_listindex(headlist, [vcfHeaders.kHapMap2And3_CEU, vcfHeaders.k1000g_all, vcfHeaders.k1000g_eur, vcfHeaders.kCg69, vcfHeaders.kEsp6500si_ALL, vcfHeaders.kEsp6500si_EA]) + elif (pop == "ASN") or (pop == "a"): + backpoplist = vcfUtils.get_listindex(headlist, [vcfHeaders.k_hapmap2and3_CHB, vcfHeaders.k1000g_all, vcfHeaders.kCg69, vcfHeaders.kEsp6500si_ALL]) + elif (pop == "AFR") or (pop == "f"): + backpoplist = vcfUtils.get_listindex(headlist, [vcfHeaders.k_hapmap2and3_YRI, vcfHeaders.k1000g_all, vcfHeaders.k1000g_afr, vcfHeaders.kCg69, vcfHeaders.kEsp6500si_ALL, vcfHeaders.k_esp6500si_AA]) + else: + print >> sys.stderr, "Error in diseaseUtils.tiers_allvars - Population specified is not supported" + exit(1) + + #initialize gene list for region prioritization + genes = {} + for line in g_file: + linelist = line.split("\t") + gene = linelist[1] + + if genes.has_key(gene) == 0: + genes[gene] = linelist[2]+":"+linelist[3] + else: + genes[gene] = genes[gene]+";"+linelist[2]+":"+linelist[3] + + #iterate over input file and parse into tiers + for line in filein: + total+=1 + if ("PASS" in line) and ("#" in line) == 0 and vcfUtils.is_rare(line, freq, backpoplist): + rarevars+=1 + linelist = line.split("\t") + # for now + tmp = linelist[geneNameCol].split(',') + gene = tmp[0] + + if genes.has_key(gene): + target_genes+=1 + # tier 0: clinvar + if(vcfUtils.isClinvarPathogenicOrLikelyPathogenic(line, headlist, yaml_cmds)): + fileout0.write(line) + damaging0+=1 + elif vcfUtils.is_functional(line, "stoploss stopgain splicing frameshift"): + fileout1.write(line) + damaging1+=1 + elif (vcfUtils.is_functional(line, "nonsynonymous") and vcfUtils.is_conserved(line, headlist, 2)) or ("nonframeshift" in line): + fileout2.write(line) + damaging2+=1 + elif vcfUtils.is_functional(line, "nonsynonymous") and vcfUtils.is_pathogenic(line, headlist, 2): + fileout3.write(line) + damaging3+=1 + else: + fileout4.write(line) + damaging4+=1 + + output_log.write("Total variants queried: "+str(total)+"\n") + output_log.write("Rare variants queried: "+str(rarevars)+"\n") + output_log.write("Rare variants in target genes: "+str(target_genes)+"\n") + output_log.write("Candidate variants, tier 0: "+str(damaging0)+"\n") + output_log.write("Candidate variants, tier 1: "+str(damaging1)+"\n") + output_log.write("Candidate variants, tier 2: "+str(damaging2)+"\n") + output_log.write("Candidate variants, tier 3: "+str(damaging3)+"\n") + output_log.write("Candidate variants, tier 4: "+str(damaging4)+"\n") + + filein.close() + g_file.close() + fileout0.close() + fileout1.close() + fileout2.close() + fileout3.close() + fileout4.close() + + +#function tier 1,2,3,4 variants from reference in specified gene regions, default clinvar - starts from stanovar vcf +def tiers_target(in_file, out_stem, gene_file, pop, yaml_cmds, freq=0.01): + #open input and output files and initialize counters and lists for background populations + filein = open(in_file, "r") + g_file = open(gene_file, "r") + header = filein.readline().rstrip("\n") + headlist = header.split("\t") + output_log = open(out_stem+".metrics", "w") + output_log.write("Metrics for stmp filtering, clinvar variants\n") + fileout0 = open(out_stem+".tier0.txt", 'w') + fileout1 = open(out_stem+".tier1.txt", "w") + fileout2 = open(out_stem+".tier2.txt", "w") + fileout3 = open(out_stem+".tier3.txt", "w") + fileout4 = open(out_stem+".tier4.txt", "w") + fileout1.write(header + "\n") + fileout2.write(header + "\n") + fileout3.write(header + "\n") + fileout4.write(header + "\n") + total = 0 + damaging0 = 0 + damaging1 = 0 + damaging2 = 0 + damaging3 = 0 + damaging4 = 0 + target_genes = 0 + + # TODO: generate these headers as dynamically as possible using info in the YAML. + # TODO test to make sure each of these headers actually exists in the annotated file and warn if any are missing + if (pop == "CEU") or (pop == "c"): + backpoplist = vcfUtils.get_listindex(headlist, "hg19_hapmap2and3_CEU_info hg19_popfreq_all_20150413_1000g_all hg19_popfreq_all_20150413_1000g_eur hg19_cg69_info hg19_esp6500si_all_info hg19_popfreq_all_20150413_esp6500siv2_all hg19_esp6500si_ea_info hg19_popfreq_all_20150413_esp6500siv2_ea") +# backpoplist = vcfUtils.get_listindex(headlist, "hapmap2and3_CEU 1000g2010nov_ALL 1000g2011may_ALL 1000g2012apr_ALL 1000g2012apr_EUR cg69 esp6500si_ALL esp6500si_EA") + elif (pop == "ASN") or (pop == "a"): + backpoplist = vcfUtils.get_listindex(headlist, "hg19_hapmap2and3_CHB_info hg19_popfreq_all_20150413_1000g_all 1000g2012apr_ASN hg19_cg69_info hg19_esp6500si_all_info hg19_popfreq_all_20150413_esp6500siv2_all") # WARNING missing 1000g_ASN in curent datasets +# backpoplist = vcfUtils.get_listindex(headlist, "hapmap2and3_CHB 1000g2010nov_ALL 1000g2011may_ALL 1000g2012apr_ALL 1000g2012apr_ASN cg69 esp6500si_ALL") + elif (pop == "AFR") or (pop == "f"): + backpoplist = vcfUtils.get_listindex(headlist, "hg19_hapmap2and3_YRI_info hg19_popfreq_all_20150413_1000g_all hg19_popfreq_all_20150413_1000g_afr hg19_cg69_info hg19_esp6500si_all_info hg19_popfreq_all_20150413_esp6500siv2_all hg19_esp6500si_aa_info hg19_popfreq_all_20150413_esp6500siv2_aa") + else: + print >> sys.stderr, "Error in diseaseUtils.tiers_allvars - Population specified is not supported" + exit(1) + + #initialize gene list for region prioritization + genes = {} + for line in g_file: + linelist = line.split("\t") + gene = linelist[1] + if genes.has_key(gene) == 0: + genes[gene] = linelist[2]+":"+linelist[3] + else: + genes[gene] = genes[gene]+";"+linelist[2]+":"+linelist[3] + + #iterate over input file and parse into tiers + for line in filein: + total+=1 + if ("PASS" in line) and (("#" in line) == 0) and (("0/1" in line) or ("1/1" in line)): + linelist = line.split("\t") + gene = linelist[1] + if genes.has_key(gene): + target_genes+=1 + # tier 0: clinvar + if(vcfUtils.isClinvarPathogenicOrLikelyPathogenic(line, headlist, yaml_cmds)): + fileout0.write(line) + damaging0+=1 + elif vcfUtils.is_functional(line, "stoploss stopgain splicing frameshift"): + fileout1.write(line) + damaging1+=1 + elif vcfUtils.is_rare(line, freq, backpoplist): + fileout2.write(line) + damaging2+=1 + elif vcfUtils.is_functional(line, "nonframeshift nonsynonymous"): + fileout3.write(line) + damaging3+=1 + else: + fileout4.write(line) + damaging4+=1 + + output_log.write("Total variants queried: "+str(total)+"\n") + output_log.write("Total variants in gene list: "+str(target_genes)+"\n") + output_log.write("Candidate variants, tier 0: "+str(damaging0)+"\n") + output_log.write("Candidate variants, tier 1: "+str(damaging1)+"\n") + output_log.write("Candidate variants, tier 2: "+str(damaging2)+"\n") + output_log.write("Candidate variants, tier 3: "+str(damaging3)+"\n") + output_log.write("Candidate variants, tier 4: "+str(damaging4)+"\n") + + filein.close() + g_file.close() + fileout0.close() + fileout1.close() + fileout2.close() + fileout3.close() + fileout4.close() + + +#filter all by local allele frequency +def filter_sfs(infile, sfs_file, outfile, thresh): + f_sfs = open(sfs_file, "r") + f_in = open(infile, "r") + f_out = open(outfile, "w") + all_dict = {} + + #read in + for line in f_sfs: + linelist = line.replace("\n", "").split("\t") + chrom = linelist[0] + pos = linelist[1] + all_dict[chrom+":"+pos] = linelist[2] + + #read and filter input file + header = f_in.readline().replace("\n", "\t")+"Num_subjects\n" + headlist = header.split("\t") + chrindex = headlist.index("CHROM") + posindex = headlist.index("POS") + f_out.write(header) + for line in f_in: + if ("CHROM" in line) == 0: + linelist = line.split("\t") + chrom = linelist[chrindex] + pos = linelist[posindex] + if all_dict.has_key(chrom+":"+pos): + if int(all_dict[chrom+":"+pos]) <= int(thresh): + f_out.write(line.replace("\n", "\t")+all_dict[chrom+":"+pos]+"\n") + else: + f_out.write(line.replace("\n", "\t")+"0\n") + + f_sfs.close() + f_in.close() + f_out.close() + diff --git a/code/trio/EmissionQuartetGen.txt b/code/trio/EmissionQuartetGen.txt new file mode 100644 index 0000000..b413107 --- /dev/null +++ b/code/trio/EmissionQuartetGen.txt @@ -0,0 +1,82 @@ +allele_code alleles haploidenticalPaternal haploidenticalMaternal identical nonidentical compression mie +0 0,0,0,0 goodprobHI goodprobHI goodprobID goodprobID erprobC erprobM +1 0,0,0,1 erprobHI erprobHI erprobID erprobID erprobC mieprob +2 0,0,0,2 erprobHI erprobHI erprobID erprobID erprobC mieprob +3 0,0,1,0 erprobHI erprobHI erprobID erprobID erprobC mieprob +4 0,0,1,1 erprobHI erprobHI erprobID erprobID erprobC mieprob +5 0,0,1,2 erprobHI erprobHI erprobID erprobID erprobC mieprob +6 0,0,2,0 erprobHI erprobHI erprobID erprobID erprobC mieprob +7 0,0,2,1 erprobHI erprobHI erprobID erprobID erprobC mieprob +8 0,0,2,2 erprobHI erprobHI erprobID erprobID erprobC mieprob +9 0,1,0,0 erprobHI goodprobHI goodprobID erprobID erprobC erprobM +10 0,1,0,1 goodprobHI erprobHI erprobID goodprobID erprobC erprobM +11 0,1,0,2 erprobHI erprobHI erprobID erprobID erprobC mieprob +12 0,1,1,0 goodprobHI erprobHI erprobID goodprobID erprobC erprobM +13 0,1,1,1 erprobHI goodprobHI goodprobID erprobID erprobC erprobM +14 0,1,1,2 erprobHI erprobHI erprobID erprobID erprobC mieprob +15 0,1,2,0 erprobHI erprobHI erprobID erprobID erprobC mieprob +16 0,1,2,1 erprobHI erprobHI erprobID erprobID erprobC mieprob +17 0,1,2,2 erprobHI erprobHI erprobID erprobID erprobC mieprob +18 0,2,0,0 erprobHI erprobHI erprobID erprobID erprobC mieprob +19 0,2,0,1 erprobHI erprobHI erprobID erprobID erprobC mieprob +20 0,2,0,2 erprobHI erprobHI erprobID erprobID erprobC mieprob +21 0,2,1,0 erprobHI erprobHI erprobID erprobID erprobC mieprob +22 0,2,1,1 goodprobHI goodprobHI goodprobID goodprobID erprobC erprobM +23 0,2,1,2 erprobHI erprobHI erprobID erprobID erprobC mieprob +24 0,2,2,0 erprobHI erprobHI erprobID erprobID erprobC mieprob +25 0,2,2,1 erprobHI erprobHI erprobID erprobID erprobC mieprob +26 0,2,2,2 erprobHI erprobHI erprobID erprobID erprobC mieprob +27 1,0,0,0 goodprobHI erprobHI goodprobID erprobID erprobC erprobM +28 1,0,0,1 erprobHI goodprobHI erprobID goodprobID erprobC erprobM +29 1,0,0,2 erprobHI erprobHI erprobID erprobID erprobC mieprob +30 1,0,1,0 erprobHI goodprobHI erprobID goodprobID erprobC erprobM +31 1,0,1,1 goodprobHI erprobHI goodprobID erprobID erprobC erprobM +32 1,0,1,2 erprobHI erprobHI erprobID erprobID erprobC mieprob +33 1,0,2,0 erprobHI erprobHI erprobID erprobID erprobC mieprob +34 1,0,2,1 erprobHI erprobHI erprobID erprobID erprobC mieprob +35 1,0,2,2 erprobHI erprobHI erprobID erprobID erprobC mieprob +36 1,1,0,0 erprobHI erprobHI goodprobID erprobID erprobC erprobM +37 1,1,0,1 goodprobHI goodprobHI erprobID erprobID erprobC erprobM +38 1,1,0,2 erprobHI erprobHI erprobID goodprobID erprobC erprobM +39 1,1,1,0 goodprobHI goodprobHI erprobID erprobID erprobC erprobM +40 1,1,1,1 erprobHI erprobHI goodprobID goodprobID comprob erprobM +41 1,1,1,2 goodprobHI goodprobHI erprobID erprobID erprobC erprobM +42 1,1,2,0 erprobHI erprobHI erprobID goodprobID erprobC erprobM +43 1,1,2,1 goodprobHI goodprobHI erprobID erprobID erprobC erprobM +44 1,1,2,2 erprobHI erprobHI goodprobID erprobID erprobC erprobM +45 1,2,0,0 erprobHI erprobHI erprobID erprobID erprobC mieprob +46 1,2,0,1 erprobHI erprobHI erprobID erprobID erprobC mieprob +47 1,2,0,2 erprobHI erprobHI erprobID erprobID erprobC mieprob +48 1,2,1,0 erprobHI erprobHI erprobID erprobID erprobC mieprob +49 1,2,1,1 goodprobHI erprobHI goodprobID erprobID erprobC erprobM +50 1,2,1,2 erprobHI goodprobHI erprobID goodprobID erprobC erprobM +51 1,2,2,0 erprobHI erprobHI erprobID erprobID erprobC mieprob +52 1,2,2,1 erprobHI goodprobHI erprobID goodprobID erprobC erprobM +53 1,2,2,2 goodprobHI erprobHI goodprobID erprobID erprobC erprobM +54 2,0,0,0 erprobHI erprobHI erprobID erprobID erprobC mieprob +55 2,0,0,1 erprobHI erprobHI erprobID erprobID erprobC mieprob +56 2,0,0,2 erprobHI erprobHI erprobID erprobID erprobC mieprob +57 2,0,1,0 erprobHI erprobHI erprobID erprobID erprobC mieprob +58 2,0,1,1 goodprobHI goodprobHI goodprobID goodprobID erprobC erprobM +59 2,0,1,2 erprobHI erprobHI erprobID erprobID erprobC mieprob +60 2,0,2,0 erprobHI erprobHI erprobID erprobID erprobC mieprob +61 2,0,2,1 erprobHI erprobHI erprobID erprobID erprobC mieprob +62 2,0,2,2 erprobHI erprobHI erprobID erprobID erprobC mieprob +63 2,1,0,0 erprobHI erprobHI erprobID erprobID erprobC mieprob +64 2,1,0,1 erprobHI erprobHI erprobID erprobID erprobC mieprob +65 2,1,0,2 erprobHI erprobHI erprobID erprobID erprobC mieprob +66 2,1,1,0 erprobHI erprobHI erprobID erprobID erprobC mieprob +67 2,1,1,1 erprobHI goodprobHI goodprobID erprobID erprobC erprobM +68 2,1,1,2 goodprobHI erprobHI erprobID goodprobID erprobC erprobM +69 2,1,2,0 erprobHI erprobHI erprobID erprobID erprobC mieprob +70 2,1,2,1 goodprobHI erprobHI erprobID goodprobID erprobC erprobM +71 2,1,2,2 erprobHI goodprobHI goodprobID erprobID erprobC erprobM +72 2,2,0,0 erprobHI erprobHI erprobID erprobID erprobC mieprob +73 2,2,0,1 erprobHI erprobHI erprobID erprobID erprobC mieprob +74 2,2,0,2 erprobHI erprobHI erprobID erprobID erprobC mieprob +75 2,2,1,0 erprobHI erprobHI erprobID erprobID erprobC mieprob +76 2,2,1,1 erprobHI erprobHI erprobID erprobID erprobC mieprob +77 2,2,1,2 erprobHI erprobHI erprobID erprobID erprobC mieprob +78 2,2,2,0 erprobHI erprobHI erprobID erprobID erprobC mieprob +79 2,2,2,1 erprobHI erprobHI erprobID erprobID erprobC mieprob +80 2,2,2,2 goodprobHI goodprobHI goodprobID goodprobID erprobC erprobM \ No newline at end of file diff --git a/code/trio/EmissionTrioGen.txt b/code/trio/EmissionTrioGen.txt new file mode 100644 index 0000000..b4c69d9 --- /dev/null +++ b/code/trio/EmissionTrioGen.txt @@ -0,0 +1,28 @@ +allele_code alleles MIErich Compression GoodData +0 0,0,0 erprobM erprobC goodprob +1 0,0,1 mieprob erprobC erprobG +2 0,0,2 mieprob erprobC erprobG +3 0,1,0 erprobM erprobC goodprob +4 0,1,1 erprobM erprobC goodprob +5 0,1,2 mieprob erprobC erprobG +6 0,2,0 mieprob erprobC erprobG +7 0,2,1 erprobM erprobC goodprob +8 0,2,2 mieprob erprobC erprobG +9 1,0,0 erprobM erprobC goodprob +10 1,0,1 erprobM erprobC goodprob +11 1,0,2 mieprob erprobC erprobG +12 1,1,0 erprobM erprobC goodprob +13 1,1,1 erprobM comprob goodprob +14 1,1,2 erprobM erprobC goodprob +15 1,2,0 mieprob erprobC erprobG +16 1,2,1 erprobM erprobC goodprob +17 1,2,2 erprobM erprobC goodprob +18 2,0,0 mieprob erprobC erprobG +19 2,0,1 erprobM erprobC goodprob +20 2,0,2 mieprob erprobC erprobG +21 2,1,0 mieprob erprobC erprobG +22 2,1,1 erprobM erprobC goodprob +23 2,1,2 erprobM erprobC goodprob +24 2,2,0 mieprob erprobC erprobG +25 2,2,1 mieprob erprobC erprobG +26 2,2,2 erprobM erprobC goodprob \ No newline at end of file diff --git a/code/trio/TransitionQuartetGen.txt b/code/trio/TransitionQuartetGen.txt new file mode 100644 index 0000000..dfa5ac5 --- /dev/null +++ b/code/trio/TransitionQuartetGen.txt @@ -0,0 +1,6 @@ +self nonself nonself nonself nonself nonself +nonself self nonself nonself nonself nonself +nonself nonself self nonself nonself nonself +nonself nonself nonself self nonself nonself +nonself nonself nonself nonself self nonself +nonself nonself nonself nonself nonself self \ No newline at end of file diff --git a/code/trio/TransitionTrioGen.txt b/code/trio/TransitionTrioGen.txt new file mode 100644 index 0000000..d05f965 --- /dev/null +++ b/code/trio/TransitionTrioGen.txt @@ -0,0 +1,3 @@ +self nonself nonself +nonself self nonself +nonself nonself self \ No newline at end of file diff --git a/code/trio/__init__.py b/code/trio/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/code/trio/hmmUtils.c b/code/trio/hmmUtils.c new file mode 100644 index 0000000..c80b404 --- /dev/null +++ b/code/trio/hmmUtils.c @@ -0,0 +1,12264 @@ +/* Generated by Cython 0.17 on Tue Sep 4 09:07:00 2012 */ + +#define PY_SSIZE_T_CLEAN +#include "Python.h" +#ifndef Py_PYTHON_H + #error Python headers needed to compile C extensions, please install development version of Python. +#elif PY_VERSION_HEX < 0x02040000 + #error Cython requires Python 2.4+. +#else +#include /* For offsetof */ +#ifndef offsetof +#define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) +#endif +#if !defined(WIN32) && !defined(MS_WINDOWS) + #ifndef __stdcall + #define __stdcall + #endif + #ifndef __cdecl + #define __cdecl + #endif + #ifndef __fastcall + #define __fastcall + #endif +#endif +#ifndef DL_IMPORT + #define DL_IMPORT(t) t +#endif +#ifndef DL_EXPORT + #define DL_EXPORT(t) t +#endif +#ifndef PY_LONG_LONG + #define PY_LONG_LONG LONG_LONG +#endif +#ifndef Py_HUGE_VAL + #define Py_HUGE_VAL HUGE_VAL +#endif +#ifdef PYPY_VERSION +#define CYTHON_COMPILING_IN_PYPY 1 +#define CYTHON_COMPILING_IN_CPYTHON 0 +#else +#define CYTHON_COMPILING_IN_PYPY 0 +#define CYTHON_COMPILING_IN_CPYTHON 1 +#endif +#if PY_VERSION_HEX < 0x02050000 + typedef int Py_ssize_t; + #define PY_SSIZE_T_MAX INT_MAX + #define PY_SSIZE_T_MIN INT_MIN + #define PY_FORMAT_SIZE_T "" + #define CYTHON_FORMAT_SSIZE_T "" + #define PyInt_FromSsize_t(z) PyInt_FromLong(z) + #define PyInt_AsSsize_t(o) __Pyx_PyInt_AsInt(o) + #define PyNumber_Index(o) ((PyNumber_Check(o) && !PyFloat_Check(o)) ? PyNumber_Int(o) : \ + (PyErr_Format(PyExc_TypeError, \ + "expected index value, got %.200s", Py_TYPE(o)->tp_name), \ + (PyObject*)0)) + #define PyIndex_Check(o) (PyNumber_Check(o) && !PyFloat_Check(o) && !PyComplex_Check(o)) + #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message) + #define __PYX_BUILD_PY_SSIZE_T "i" +#else + #define __PYX_BUILD_PY_SSIZE_T "n" + #define CYTHON_FORMAT_SSIZE_T "z" +#endif +#if PY_VERSION_HEX < 0x02060000 + #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt) + #define Py_TYPE(ob) (((PyObject*)(ob))->ob_type) + #define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size) + #define PyVarObject_HEAD_INIT(type, size) \ + PyObject_HEAD_INIT(type) size, + #define PyType_Modified(t) + typedef struct { + void *buf; + PyObject *obj; + Py_ssize_t len; + Py_ssize_t itemsize; + int readonly; + int ndim; + char *format; + Py_ssize_t *shape; + Py_ssize_t *strides; + Py_ssize_t *suboffsets; + void *internal; + } Py_buffer; + #define PyBUF_SIMPLE 0 + #define PyBUF_WRITABLE 0x0001 + #define PyBUF_FORMAT 0x0004 + #define PyBUF_ND 0x0008 + #define PyBUF_STRIDES (0x0010 | PyBUF_ND) + #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES) + #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES) + #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES) + #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES) + #define PyBUF_RECORDS (PyBUF_STRIDES | PyBUF_FORMAT | PyBUF_WRITABLE) + #define PyBUF_FULL (PyBUF_INDIRECT | PyBUF_FORMAT | PyBUF_WRITABLE) + typedef int (*getbufferproc)(PyObject *, Py_buffer *, int); + typedef void (*releasebufferproc)(PyObject *, Py_buffer *); +#endif +#if PY_MAJOR_VERSION < 3 + #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" + #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \ + PyCode_New(a, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) +#else + #define __Pyx_BUILTIN_MODULE_NAME "builtins" + #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \ + PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) +#endif +#if PY_MAJOR_VERSION < 3 && PY_MINOR_VERSION < 6 + #define PyUnicode_FromString(s) PyUnicode_Decode(s, strlen(s), "UTF-8", "strict") +#endif +#if PY_MAJOR_VERSION >= 3 + #define Py_TPFLAGS_CHECKTYPES 0 + #define Py_TPFLAGS_HAVE_INDEX 0 +#endif +#if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3) + #define Py_TPFLAGS_HAVE_NEWBUFFER 0 +#endif +#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) + #define CYTHON_PEP393_ENABLED 1 + #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ? \ + 0 : _PyUnicode_Ready((PyObject *)(op))) + #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) + #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) + #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) +#else + #define CYTHON_PEP393_ENABLED 0 + #define __Pyx_PyUnicode_READY(op) (0) + #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) + #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) + #define __Pyx_PyUnicode_READ(k, d, i) ((k=k), (Py_UCS4)(((Py_UNICODE*)d)[i])) +#endif +#if PY_MAJOR_VERSION >= 3 + #define PyBaseString_Type PyUnicode_Type + #define PyStringObject PyUnicodeObject + #define PyString_Type PyUnicode_Type + #define PyString_Check PyUnicode_Check + #define PyString_CheckExact PyUnicode_CheckExact +#endif +#if PY_VERSION_HEX < 0x02060000 + #define PyBytesObject PyStringObject + #define PyBytes_Type PyString_Type + #define PyBytes_Check PyString_Check + #define PyBytes_CheckExact PyString_CheckExact + #define PyBytes_FromString PyString_FromString + #define PyBytes_FromStringAndSize PyString_FromStringAndSize + #define PyBytes_FromFormat PyString_FromFormat + #define PyBytes_DecodeEscape PyString_DecodeEscape + #define PyBytes_AsString PyString_AsString + #define PyBytes_AsStringAndSize PyString_AsStringAndSize + #define PyBytes_Size PyString_Size + #define PyBytes_AS_STRING PyString_AS_STRING + #define PyBytes_GET_SIZE PyString_GET_SIZE + #define PyBytes_Repr PyString_Repr + #define PyBytes_Concat PyString_Concat + #define PyBytes_ConcatAndDel PyString_ConcatAndDel +#endif +#if PY_VERSION_HEX < 0x02060000 + #define PySet_Check(obj) PyObject_TypeCheck(obj, &PySet_Type) + #define PyFrozenSet_Check(obj) PyObject_TypeCheck(obj, &PyFrozenSet_Type) +#endif +#ifndef PySet_CheckExact + #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) +#endif +#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) +#if PY_MAJOR_VERSION >= 3 + #define PyIntObject PyLongObject + #define PyInt_Type PyLong_Type + #define PyInt_Check(op) PyLong_Check(op) + #define PyInt_CheckExact(op) PyLong_CheckExact(op) + #define PyInt_FromString PyLong_FromString + #define PyInt_FromUnicode PyLong_FromUnicode + #define PyInt_FromLong PyLong_FromLong + #define PyInt_FromSize_t PyLong_FromSize_t + #define PyInt_FromSsize_t PyLong_FromSsize_t + #define PyInt_AsLong PyLong_AsLong + #define PyInt_AS_LONG PyLong_AS_LONG + #define PyInt_AsSsize_t PyLong_AsSsize_t + #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask + #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask +#endif +#if PY_MAJOR_VERSION >= 3 + #define PyBoolObject PyLongObject +#endif +#if PY_VERSION_HEX < 0x03020000 + typedef long Py_hash_t; + #define __Pyx_PyInt_FromHash_t PyInt_FromLong + #define __Pyx_PyInt_AsHash_t PyInt_AsLong +#else + #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t + #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t +#endif +#if (PY_MAJOR_VERSION < 3) || (PY_VERSION_HEX >= 0x03010300) + #define __Pyx_PySequence_GetSlice(obj, a, b) PySequence_GetSlice(obj, a, b) + #define __Pyx_PySequence_SetSlice(obj, a, b, value) PySequence_SetSlice(obj, a, b, value) + #define __Pyx_PySequence_DelSlice(obj, a, b) PySequence_DelSlice(obj, a, b) +#else + #define __Pyx_PySequence_GetSlice(obj, a, b) (unlikely(!(obj)) ? \ + (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), (PyObject*)0) : \ + (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_GetSlice(obj, a, b)) : \ + (PyErr_Format(PyExc_TypeError, "'%.200s' object is unsliceable", (obj)->ob_type->tp_name), (PyObject*)0))) + #define __Pyx_PySequence_SetSlice(obj, a, b, value) (unlikely(!(obj)) ? \ + (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \ + (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_SetSlice(obj, a, b, value)) : \ + (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice assignment", (obj)->ob_type->tp_name), -1))) + #define __Pyx_PySequence_DelSlice(obj, a, b) (unlikely(!(obj)) ? \ + (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \ + (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_DelSlice(obj, a, b)) : \ + (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice deletion", (obj)->ob_type->tp_name), -1))) +#endif +#if PY_MAJOR_VERSION >= 3 + #define PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func)) +#endif +#if PY_VERSION_HEX < 0x02050000 + #define __Pyx_GetAttrString(o,n) PyObject_GetAttrString((o),((char *)(n))) + #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a)) + #define __Pyx_DelAttrString(o,n) PyObject_DelAttrString((o),((char *)(n))) +#else + #define __Pyx_GetAttrString(o,n) PyObject_GetAttrString((o),(n)) + #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a)) + #define __Pyx_DelAttrString(o,n) PyObject_DelAttrString((o),(n)) +#endif +#if PY_VERSION_HEX < 0x02050000 + #define __Pyx_NAMESTR(n) ((char *)(n)) + #define __Pyx_DOCSTR(n) ((char *)(n)) +#else + #define __Pyx_NAMESTR(n) (n) + #define __Pyx_DOCSTR(n) (n) +#endif + + +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) +#else + #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) +#endif + +#ifndef __PYX_EXTERN_C + #ifdef __cplusplus + #define __PYX_EXTERN_C extern "C" + #else + #define __PYX_EXTERN_C extern + #endif +#endif + +#if defined(WIN32) || defined(MS_WINDOWS) +#define _USE_MATH_DEFINES +#endif +#include +#define __PYX_HAVE__trioToolsNew__hmmUtils +#define __PYX_HAVE_API__trioToolsNew__hmmUtils +#include "stdio.h" +#include "stdlib.h" +#include "numpy/arrayobject.h" +#include "numpy/ufuncobject.h" +#ifdef _OPENMP +#include +#endif /* _OPENMP */ + +#ifdef PYREX_WITHOUT_ASSERTIONS +#define CYTHON_WITHOUT_ASSERTIONS +#endif + + +/* inline attribute */ +#ifndef CYTHON_INLINE + #if defined(__GNUC__) + #define CYTHON_INLINE __inline__ + #elif defined(_MSC_VER) + #define CYTHON_INLINE __inline + #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + #define CYTHON_INLINE inline + #else + #define CYTHON_INLINE + #endif +#endif + +/* unused attribute */ +#ifndef CYTHON_UNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define CYTHON_UNUSED __attribute__ ((__unused__)) +# else +# define CYTHON_UNUSED +# endif +# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) +# define CYTHON_UNUSED __attribute__ ((__unused__)) +# else +# define CYTHON_UNUSED +# endif +#endif + +typedef struct {PyObject **p; char *s; const long n; const char* encoding; const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; /*proto*/ + + +/* Type Conversion Predeclarations */ + +#define __Pyx_PyBytes_FromUString(s) PyBytes_FromString((char*)s) +#define __Pyx_PyBytes_AsUString(s) ((unsigned char*) PyBytes_AsString(s)) + +#define __Pyx_Owned_Py_None(b) (Py_INCREF(Py_None), Py_None) +#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False)) +static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); +static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x); + +static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); +static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); +static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*); + +#if CYTHON_COMPILING_IN_CPYTHON +#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) +#else +#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) +#endif +#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) + +#ifdef __GNUC__ + /* Test for GCC > 2.95 */ + #if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)) + #define likely(x) __builtin_expect(!!(x), 1) + #define unlikely(x) __builtin_expect(!!(x), 0) + #else /* __GNUC__ > 2 ... */ + #define likely(x) (x) + #define unlikely(x) (x) + #endif /* __GNUC__ > 2 ... */ +#else /* __GNUC__ */ + #define likely(x) (x) + #define unlikely(x) (x) +#endif /* __GNUC__ */ + +static PyObject *__pyx_m; +static PyObject *__pyx_b; +static PyObject *__pyx_empty_tuple; +static PyObject *__pyx_empty_bytes; +static int __pyx_lineno; +static int __pyx_clineno = 0; +static const char * __pyx_cfilenm= __FILE__; +static const char *__pyx_filename; + +#if !defined(CYTHON_CCOMPLEX) + #if defined(__cplusplus) + #define CYTHON_CCOMPLEX 1 + #elif defined(_Complex_I) + #define CYTHON_CCOMPLEX 1 + #else + #define CYTHON_CCOMPLEX 0 + #endif +#endif +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + #include + #else + #include + #endif +#endif +#if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__) + #undef _Complex_I + #define _Complex_I 1.0fj +#endif + + +static const char *__pyx_f[] = { + "hmmUtils.pyx", + "numpy.pxd", + "type.pxd", +}; +#define IS_UNSIGNED(type) (((type) -1) > 0) +struct __Pyx_StructField_; +#define __PYX_BUF_FLAGS_PACKED_STRUCT (1 << 0) +typedef struct { + const char* name; /* for error messages only */ + struct __Pyx_StructField_* fields; + size_t size; /* sizeof(type) */ + size_t arraysize[8]; /* length of array in each dimension */ + int ndim; + char typegroup; /* _R_eal, _C_omplex, Signed _I_nt, _U_nsigned int, _S_truct, _P_ointer, _O_bject, c_H_ar */ + char is_unsigned; + int flags; +} __Pyx_TypeInfo; +typedef struct __Pyx_StructField_ { + __Pyx_TypeInfo* type; + const char* name; + size_t offset; +} __Pyx_StructField; +typedef struct { + __Pyx_StructField* field; + size_t parent_offset; +} __Pyx_BufFmt_StackElem; +typedef struct { + __Pyx_StructField root; + __Pyx_BufFmt_StackElem* head; + size_t fmt_offset; + size_t new_count, enc_count; + size_t struct_alignment; + int is_complex; + char enc_type; + char new_packmode; + char enc_packmode; + char is_valid_array; +} __Pyx_BufFmt_Context; + + +/* "numpy.pxd":723 + * # in Cython to enable them only on the right systems. + * + * ctypedef npy_int8 int8_t # <<<<<<<<<<<<<< + * ctypedef npy_int16 int16_t + * ctypedef npy_int32 int32_t + */ +typedef npy_int8 __pyx_t_5numpy_int8_t; + +/* "numpy.pxd":724 + * + * ctypedef npy_int8 int8_t + * ctypedef npy_int16 int16_t # <<<<<<<<<<<<<< + * ctypedef npy_int32 int32_t + * ctypedef npy_int64 int64_t + */ +typedef npy_int16 __pyx_t_5numpy_int16_t; + +/* "numpy.pxd":725 + * ctypedef npy_int8 int8_t + * ctypedef npy_int16 int16_t + * ctypedef npy_int32 int32_t # <<<<<<<<<<<<<< + * ctypedef npy_int64 int64_t + * #ctypedef npy_int96 int96_t + */ +typedef npy_int32 __pyx_t_5numpy_int32_t; + +/* "numpy.pxd":726 + * ctypedef npy_int16 int16_t + * ctypedef npy_int32 int32_t + * ctypedef npy_int64 int64_t # <<<<<<<<<<<<<< + * #ctypedef npy_int96 int96_t + * #ctypedef npy_int128 int128_t + */ +typedef npy_int64 __pyx_t_5numpy_int64_t; + +/* "numpy.pxd":730 + * #ctypedef npy_int128 int128_t + * + * ctypedef npy_uint8 uint8_t # <<<<<<<<<<<<<< + * ctypedef npy_uint16 uint16_t + * ctypedef npy_uint32 uint32_t + */ +typedef npy_uint8 __pyx_t_5numpy_uint8_t; + +/* "numpy.pxd":731 + * + * ctypedef npy_uint8 uint8_t + * ctypedef npy_uint16 uint16_t # <<<<<<<<<<<<<< + * ctypedef npy_uint32 uint32_t + * ctypedef npy_uint64 uint64_t + */ +typedef npy_uint16 __pyx_t_5numpy_uint16_t; + +/* "numpy.pxd":732 + * ctypedef npy_uint8 uint8_t + * ctypedef npy_uint16 uint16_t + * ctypedef npy_uint32 uint32_t # <<<<<<<<<<<<<< + * ctypedef npy_uint64 uint64_t + * #ctypedef npy_uint96 uint96_t + */ +typedef npy_uint32 __pyx_t_5numpy_uint32_t; + +/* "numpy.pxd":733 + * ctypedef npy_uint16 uint16_t + * ctypedef npy_uint32 uint32_t + * ctypedef npy_uint64 uint64_t # <<<<<<<<<<<<<< + * #ctypedef npy_uint96 uint96_t + * #ctypedef npy_uint128 uint128_t + */ +typedef npy_uint64 __pyx_t_5numpy_uint64_t; + +/* "numpy.pxd":737 + * #ctypedef npy_uint128 uint128_t + * + * ctypedef npy_float32 float32_t # <<<<<<<<<<<<<< + * ctypedef npy_float64 float64_t + * #ctypedef npy_float80 float80_t + */ +typedef npy_float32 __pyx_t_5numpy_float32_t; + +/* "numpy.pxd":738 + * + * ctypedef npy_float32 float32_t + * ctypedef npy_float64 float64_t # <<<<<<<<<<<<<< + * #ctypedef npy_float80 float80_t + * #ctypedef npy_float128 float128_t + */ +typedef npy_float64 __pyx_t_5numpy_float64_t; + +/* "numpy.pxd":747 + * # The int types are mapped a bit surprising -- + * # numpy.int corresponds to 'l' and numpy.long to 'q' + * ctypedef npy_long int_t # <<<<<<<<<<<<<< + * ctypedef npy_longlong long_t + * ctypedef npy_longlong longlong_t + */ +typedef npy_long __pyx_t_5numpy_int_t; + +/* "numpy.pxd":748 + * # numpy.int corresponds to 'l' and numpy.long to 'q' + * ctypedef npy_long int_t + * ctypedef npy_longlong long_t # <<<<<<<<<<<<<< + * ctypedef npy_longlong longlong_t + * + */ +typedef npy_longlong __pyx_t_5numpy_long_t; + +/* "numpy.pxd":749 + * ctypedef npy_long int_t + * ctypedef npy_longlong long_t + * ctypedef npy_longlong longlong_t # <<<<<<<<<<<<<< + * + * ctypedef npy_ulong uint_t + */ +typedef npy_longlong __pyx_t_5numpy_longlong_t; + +/* "numpy.pxd":751 + * ctypedef npy_longlong longlong_t + * + * ctypedef npy_ulong uint_t # <<<<<<<<<<<<<< + * ctypedef npy_ulonglong ulong_t + * ctypedef npy_ulonglong ulonglong_t + */ +typedef npy_ulong __pyx_t_5numpy_uint_t; + +/* "numpy.pxd":752 + * + * ctypedef npy_ulong uint_t + * ctypedef npy_ulonglong ulong_t # <<<<<<<<<<<<<< + * ctypedef npy_ulonglong ulonglong_t + * + */ +typedef npy_ulonglong __pyx_t_5numpy_ulong_t; + +/* "numpy.pxd":753 + * ctypedef npy_ulong uint_t + * ctypedef npy_ulonglong ulong_t + * ctypedef npy_ulonglong ulonglong_t # <<<<<<<<<<<<<< + * + * ctypedef npy_intp intp_t + */ +typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t; + +/* "numpy.pxd":755 + * ctypedef npy_ulonglong ulonglong_t + * + * ctypedef npy_intp intp_t # <<<<<<<<<<<<<< + * ctypedef npy_uintp uintp_t + * + */ +typedef npy_intp __pyx_t_5numpy_intp_t; + +/* "numpy.pxd":756 + * + * ctypedef npy_intp intp_t + * ctypedef npy_uintp uintp_t # <<<<<<<<<<<<<< + * + * ctypedef npy_double float_t + */ +typedef npy_uintp __pyx_t_5numpy_uintp_t; + +/* "numpy.pxd":758 + * ctypedef npy_uintp uintp_t + * + * ctypedef npy_double float_t # <<<<<<<<<<<<<< + * ctypedef npy_double double_t + * ctypedef npy_longdouble longdouble_t + */ +typedef npy_double __pyx_t_5numpy_float_t; + +/* "numpy.pxd":759 + * + * ctypedef npy_double float_t + * ctypedef npy_double double_t # <<<<<<<<<<<<<< + * ctypedef npy_longdouble longdouble_t + * + */ +typedef npy_double __pyx_t_5numpy_double_t; + +/* "numpy.pxd":760 + * ctypedef npy_double float_t + * ctypedef npy_double double_t + * ctypedef npy_longdouble longdouble_t # <<<<<<<<<<<<<< + * + * ctypedef npy_cfloat cfloat_t + */ +typedef npy_longdouble __pyx_t_5numpy_longdouble_t; + +/* "trioToolsNew/hmmUtils.pyx":19 + * DTYPEf = np.float + * DTYPEi = np.int + * ctypedef np.float_t DTYPEf_t # <<<<<<<<<<<<<< + * ctypedef np.int_t DTYPEi_t + * + */ +typedef __pyx_t_5numpy_float_t __pyx_t_12trioToolsNew_8hmmUtils_DTYPEf_t; + +/* "trioToolsNew/hmmUtils.pyx":20 + * DTYPEi = np.int + * ctypedef np.float_t DTYPEf_t + * ctypedef np.int_t DTYPEi_t # <<<<<<<<<<<<<< + * + * #loads transition matrix + */ +typedef __pyx_t_5numpy_int_t __pyx_t_12trioToolsNew_8hmmUtils_DTYPEi_t; +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + typedef ::std::complex< float > __pyx_t_float_complex; + #else + typedef float _Complex __pyx_t_float_complex; + #endif +#else + typedef struct { float real, imag; } __pyx_t_float_complex; +#endif + +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + typedef ::std::complex< double > __pyx_t_double_complex; + #else + typedef double _Complex __pyx_t_double_complex; + #endif +#else + typedef struct { double real, imag; } __pyx_t_double_complex; +#endif + + +/*--- Type declarations ---*/ + +/* "numpy.pxd":762 + * ctypedef npy_longdouble longdouble_t + * + * ctypedef npy_cfloat cfloat_t # <<<<<<<<<<<<<< + * ctypedef npy_cdouble cdouble_t + * ctypedef npy_clongdouble clongdouble_t + */ +typedef npy_cfloat __pyx_t_5numpy_cfloat_t; + +/* "numpy.pxd":763 + * + * ctypedef npy_cfloat cfloat_t + * ctypedef npy_cdouble cdouble_t # <<<<<<<<<<<<<< + * ctypedef npy_clongdouble clongdouble_t + * + */ +typedef npy_cdouble __pyx_t_5numpy_cdouble_t; + +/* "numpy.pxd":764 + * ctypedef npy_cfloat cfloat_t + * ctypedef npy_cdouble cdouble_t + * ctypedef npy_clongdouble clongdouble_t # <<<<<<<<<<<<<< + * + * ctypedef npy_cdouble complex_t + */ +typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t; + +/* "numpy.pxd":766 + * ctypedef npy_clongdouble clongdouble_t + * + * ctypedef npy_cdouble complex_t # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew1(a): + */ +typedef npy_cdouble __pyx_t_5numpy_complex_t; +#ifndef CYTHON_REFNANNY + #define CYTHON_REFNANNY 0 +#endif +#if CYTHON_REFNANNY + typedef struct { + void (*INCREF)(void*, PyObject*, int); + void (*DECREF)(void*, PyObject*, int); + void (*GOTREF)(void*, PyObject*, int); + void (*GIVEREF)(void*, PyObject*, int); + void* (*SetupContext)(const char*, int, const char*); + void (*FinishContext)(void**); + } __Pyx_RefNannyAPIStruct; + static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; + static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); /*proto*/ + #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; +#ifdef WITH_THREAD + #define __Pyx_RefNannySetupContext(name, acquire_gil) \ + if (acquire_gil) { \ + PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); \ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \ + PyGILState_Release(__pyx_gilstate_save); \ + } else { \ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \ + } +#else + #define __Pyx_RefNannySetupContext(name, acquire_gil) \ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) +#endif + #define __Pyx_RefNannyFinishContext() \ + __Pyx_RefNanny->FinishContext(&__pyx_refnanny) + #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0) + #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0) + #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0) + #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0) +#else + #define __Pyx_RefNannyDeclarations + #define __Pyx_RefNannySetupContext(name, acquire_gil) + #define __Pyx_RefNannyFinishContext() + #define __Pyx_INCREF(r) Py_INCREF(r) + #define __Pyx_DECREF(r) Py_DECREF(r) + #define __Pyx_GOTREF(r) + #define __Pyx_GIVEREF(r) + #define __Pyx_XINCREF(r) Py_XINCREF(r) + #define __Pyx_XDECREF(r) Py_XDECREF(r) + #define __Pyx_XGOTREF(r) + #define __Pyx_XGIVEREF(r) +#endif /* CYTHON_REFNANNY */ +#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) +#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) + +static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/ + +static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, + Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/ + +static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); /*proto*/ + +static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[], \ + PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, \ + const char* function_name); /*proto*/ + +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { + PyObject *r; + if (!j) return NULL; + r = PyObject_GetItem(o, j); + Py_DECREF(j); + return r; +} +#define __Pyx_GetItemInt_List(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \ + __Pyx_GetItemInt_List_Fast(o, i) : \ + __Pyx_GetItemInt_Generic(o, to_py_func(i))) +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i) { +#if CYTHON_COMPILING_IN_CPYTHON + if (likely((0 <= i) & (i < PyList_GET_SIZE(o)))) { + PyObject *r = PyList_GET_ITEM(o, i); + Py_INCREF(r); + return r; + } + else if ((-PyList_GET_SIZE(o) <= i) & (i < 0)) { + PyObject *r = PyList_GET_ITEM(o, PyList_GET_SIZE(o) + i); + Py_INCREF(r); + return r; + } + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +#else + return PySequence_GetItem(o, i); +#endif +} +#define __Pyx_GetItemInt_Tuple(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \ + __Pyx_GetItemInt_Tuple_Fast(o, i) : \ + __Pyx_GetItemInt_Generic(o, to_py_func(i))) +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i) { +#if CYTHON_COMPILING_IN_CPYTHON + if (likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) { + PyObject *r = PyTuple_GET_ITEM(o, i); + Py_INCREF(r); + return r; + } + else if ((-PyTuple_GET_SIZE(o) <= i) & (i < 0)) { + PyObject *r = PyTuple_GET_ITEM(o, PyTuple_GET_SIZE(o) + i); + Py_INCREF(r); + return r; + } + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +#else + return PySequence_GetItem(o, i); +#endif +} +#define __Pyx_GetItemInt(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \ + __Pyx_GetItemInt_Fast(o, i) : \ + __Pyx_GetItemInt_Generic(o, to_py_func(i))) +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i) { +#if CYTHON_COMPILING_IN_CPYTHON + if (PyList_CheckExact(o)) { + Py_ssize_t n = (likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); + if (likely((n >= 0) & (n < PyList_GET_SIZE(o)))) { + PyObject *r = PyList_GET_ITEM(o, n); + Py_INCREF(r); + return r; + } + } + else if (PyTuple_CheckExact(o)) { + Py_ssize_t n = (likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o); + if (likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) { + PyObject *r = PyTuple_GET_ITEM(o, n); + Py_INCREF(r); + return r; + } + } else { /* inlined PySequence_GetItem() */ + PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; + if (likely(m && m->sq_item)) { + if (unlikely(i < 0) && likely(m->sq_length)) { + Py_ssize_t l = m->sq_length(o); + if (unlikely(l < 0)) return NULL; + i += l; + } + return m->sq_item(o, i); + } + } +#else + if (PySequence_Check(o)) { + return PySequence_GetItem(o, i); + } +#endif + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +} + +#define __Pyx_SetItemInt(o, i, v, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \ + __Pyx_SetItemInt_Fast(o, i, v) : \ + __Pyx_SetItemInt_Generic(o, to_py_func(i), v)) +static CYTHON_INLINE int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) { + int r; + if (!j) return -1; + r = PyObject_SetItem(o, j, v); + Py_DECREF(j); + return r; +} +static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v) { +#if CYTHON_COMPILING_IN_CPYTHON + if (PyList_CheckExact(o)) { + Py_ssize_t n = (likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); + if (likely((n >= 0) & (n < PyList_GET_SIZE(o)))) { + PyObject* old = PyList_GET_ITEM(o, n); + Py_INCREF(v); + PyList_SET_ITEM(o, n, v); + Py_DECREF(old); + return 1; + } + } else { /* inlined PySequence_SetItem() */ + PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; + if (likely(m && m->sq_ass_item)) { + if (unlikely(i < 0) && likely(m->sq_length)) { + Py_ssize_t l = m->sq_length(o); + if (unlikely(l < 0)) return -1; + i += l; + } + return m->sq_ass_item(o, i, v); + } + } +#else +#if CYTHON_COMPILING_IN_PYPY + if (PySequence_Check(o) && !PyDict_Check(o)) { +#else + if (PySequence_Check(o)) { +#endif + return PySequence_SetItem(o, i, v); + } +#endif + return __Pyx_SetItemInt_Generic(o, PyInt_FromSsize_t(i), v); +} + +static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname); + +static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, + const char *name, int exact); /*proto*/ + +static CYTHON_INLINE int __Pyx_GetBufferAndValidate(Py_buffer* buf, PyObject* obj, + __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack); +static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info); + +static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/ + +static void __Pyx_RaiseBufferIndexError(int axis); /*proto*/ + +#define __Pyx_BufPtrStrided1d(type, buf, i0, s0) (type)((char*)buf + i0 * s0) + #define __Pyx_BufPtrStrided2d(type, buf, i0, s0, i1, s1) (type)((char*)buf + i0 * s0 + i1 * s1) + #if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) { + PyListObject* L = (PyListObject*) list; + Py_ssize_t len = Py_SIZE(list); + if (likely(L->allocated > len)) { + Py_INCREF(x); + PyList_SET_ITEM(list, len, x); + Py_SIZE(list) = len+1; + return 0; + } + return PyList_Append(list, x); +} +#else +#define __Pyx_PyList_Append(L,x) PyList_Append(L,x) +#endif + +static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected); + +static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); + +static CYTHON_INLINE int __Pyx_IterFinish(void); /*proto*/ + +static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected); /*proto*/ + +static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/ +static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/ + +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /*proto*/ + +static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void); + +typedef struct { + Py_ssize_t shape, strides, suboffsets; +} __Pyx_Buf_DimInfo; +typedef struct { + size_t refcount; + Py_buffer pybuffer; +} __Pyx_Buffer; +typedef struct { + __Pyx_Buffer *rcbuffer; + char *data; + __Pyx_Buf_DimInfo diminfo[8]; +} __Pyx_LocalBuf_ND; + +#if PY_MAJOR_VERSION < 3 + static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags); + static void __Pyx_ReleaseBuffer(Py_buffer *view); +#else + #define __Pyx_GetBuffer PyObject_GetBuffer + #define __Pyx_ReleaseBuffer PyBuffer_Release +#endif + + + static Py_ssize_t __Pyx_zeros[] = {0, 0, 0, 0, 0, 0, 0, 0}; +static Py_ssize_t __Pyx_minusones[] = {-1, -1, -1, -1, -1, -1, -1, -1}; + +static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, long level); /*proto*/ + +static int __Pyx_Print(PyObject*, PyObject *, int); /*proto*/ +#if CYTHON_COMPILING_IN_PYPY || PY_MAJOR_VERSION >= 3 +static PyObject* __pyx_print = 0; +static PyObject* __pyx_print_kwargs = 0; +#endif + +static int __Pyx_PrintOne(PyObject* stream, PyObject *o); /*proto*/ + +static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_npy_long(npy_long); + +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + #define __Pyx_CREAL(z) ((z).real()) + #define __Pyx_CIMAG(z) ((z).imag()) + #else + #define __Pyx_CREAL(z) (__real__(z)) + #define __Pyx_CIMAG(z) (__imag__(z)) + #endif +#else + #define __Pyx_CREAL(z) ((z).real) + #define __Pyx_CIMAG(z) ((z).imag) +#endif +#if defined(_WIN32) && defined(__cplusplus) && CYTHON_CCOMPLEX + #define __Pyx_SET_CREAL(z,x) ((z).real(x)) + #define __Pyx_SET_CIMAG(z,y) ((z).imag(y)) +#else + #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x) + #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y) +#endif + +static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float); + +#if CYTHON_CCOMPLEX + #define __Pyx_c_eqf(a, b) ((a)==(b)) + #define __Pyx_c_sumf(a, b) ((a)+(b)) + #define __Pyx_c_difff(a, b) ((a)-(b)) + #define __Pyx_c_prodf(a, b) ((a)*(b)) + #define __Pyx_c_quotf(a, b) ((a)/(b)) + #define __Pyx_c_negf(a) (-(a)) + #ifdef __cplusplus + #define __Pyx_c_is_zerof(z) ((z)==(float)0) + #define __Pyx_c_conjf(z) (::std::conj(z)) + #if 1 + #define __Pyx_c_absf(z) (::std::abs(z)) + #define __Pyx_c_powf(a, b) (::std::pow(a, b)) + #endif + #else + #define __Pyx_c_is_zerof(z) ((z)==0) + #define __Pyx_c_conjf(z) (conjf(z)) + #if 1 + #define __Pyx_c_absf(z) (cabsf(z)) + #define __Pyx_c_powf(a, b) (cpowf(a, b)) + #endif + #endif +#else + static CYTHON_INLINE int __Pyx_c_eqf(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sumf(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_difff(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prodf(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quotf(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_negf(__pyx_t_float_complex); + static CYTHON_INLINE int __Pyx_c_is_zerof(__pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conjf(__pyx_t_float_complex); + #if 1 + static CYTHON_INLINE float __Pyx_c_absf(__pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_powf(__pyx_t_float_complex, __pyx_t_float_complex); + #endif +#endif + +static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double); + +#if CYTHON_CCOMPLEX + #define __Pyx_c_eq(a, b) ((a)==(b)) + #define __Pyx_c_sum(a, b) ((a)+(b)) + #define __Pyx_c_diff(a, b) ((a)-(b)) + #define __Pyx_c_prod(a, b) ((a)*(b)) + #define __Pyx_c_quot(a, b) ((a)/(b)) + #define __Pyx_c_neg(a) (-(a)) + #ifdef __cplusplus + #define __Pyx_c_is_zero(z) ((z)==(double)0) + #define __Pyx_c_conj(z) (::std::conj(z)) + #if 1 + #define __Pyx_c_abs(z) (::std::abs(z)) + #define __Pyx_c_pow(a, b) (::std::pow(a, b)) + #endif + #else + #define __Pyx_c_is_zero(z) ((z)==0) + #define __Pyx_c_conj(z) (conj(z)) + #if 1 + #define __Pyx_c_abs(z) (cabs(z)) + #define __Pyx_c_pow(a, b) (cpow(a, b)) + #endif + #endif +#else + static CYTHON_INLINE int __Pyx_c_eq(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg(__pyx_t_double_complex); + static CYTHON_INLINE int __Pyx_c_is_zero(__pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj(__pyx_t_double_complex); + #if 1 + static CYTHON_INLINE double __Pyx_c_abs(__pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow(__pyx_t_double_complex, __pyx_t_double_complex); + #endif +#endif + +static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *); + +static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *); + +static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject *); + +static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject *); + +static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject *); + +static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject *); + +static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject *); + +static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject *); + +static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject *); + +static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject *); + +static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject *); + +static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject *); + +static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject *); + +static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject *); + +static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *); + +static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *); + +static int __Pyx_check_binary_version(void); + +#if !defined(__Pyx_PyIdentifier_FromString) +#if PY_MAJOR_VERSION < 3 + #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s) +#else + #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s) +#endif +#endif + +static PyObject *__Pyx_ImportModule(const char *name); /*proto*/ + +static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict); /*proto*/ + +typedef struct { + int code_line; + PyCodeObject* code_object; +} __Pyx_CodeObjectCacheEntry; +struct __Pyx_CodeObjectCache { + int count; + int max_count; + __Pyx_CodeObjectCacheEntry* entries; +}; +static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL}; +static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); +static PyCodeObject *__pyx_find_code_object(int code_line); +static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); + +static void __Pyx_AddTraceback(const char *funcname, int c_line, + int py_line, const char *filename); /*proto*/ + +static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/ + + +/* Module declarations from 'cpython.buffer' */ + +/* Module declarations from 'cpython.ref' */ + +/* Module declarations from 'libc.stdio' */ + +/* Module declarations from 'cpython.object' */ + +/* Module declarations from '__builtin__' */ + +/* Module declarations from 'cpython.type' */ +static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0; + +/* Module declarations from 'libc.stdlib' */ + +/* Module declarations from 'numpy' */ + +/* Module declarations from 'numpy' */ +static PyTypeObject *__pyx_ptype_5numpy_dtype = 0; +static PyTypeObject *__pyx_ptype_5numpy_flatiter = 0; +static PyTypeObject *__pyx_ptype_5numpy_broadcast = 0; +static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0; +static PyTypeObject *__pyx_ptype_5numpy_ufunc = 0; +static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *, char *, char *, int *); /*proto*/ + +/* Module declarations from 'trioToolsNew.hmmUtils' */ +static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_12trioToolsNew_8hmmUtils_DTYPEi_t = { "DTYPEi_t", NULL, sizeof(__pyx_t_12trioToolsNew_8hmmUtils_DTYPEi_t), { 0 }, 0, IS_UNSIGNED(__pyx_t_12trioToolsNew_8hmmUtils_DTYPEi_t) ? 'U' : 'I', IS_UNSIGNED(__pyx_t_12trioToolsNew_8hmmUtils_DTYPEi_t), 0 }; +static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_12trioToolsNew_8hmmUtils_DTYPEf_t = { "DTYPEf_t", NULL, sizeof(__pyx_t_12trioToolsNew_8hmmUtils_DTYPEf_t), { 0 }, 0, 'R', 0, 0 }; +#define __Pyx_MODULE_NAME "trioToolsNew.hmmUtils" +int __pyx_module_is_main_trioToolsNew__hmmUtils = 0; + +/* Implementation of 'trioToolsNew.hmmUtils' */ +static PyObject *__pyx_builtin_open; +static PyObject *__pyx_builtin_exit; +static PyObject *__pyx_builtin_range; +static PyObject *__pyx_builtin_max; +static PyObject *__pyx_builtin_ValueError; +static PyObject *__pyx_builtin_RuntimeError; +static PyObject *__pyx_pf_12trioToolsNew_8hmmUtils_load_transition(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_path, PyObject *__pyx_v_selftrans, PyObject *__pyx_v_nonselftrans, PyObject *__pyx_v_sub_ped); /* proto */ +static PyObject *__pyx_pf_12trioToolsNew_8hmmUtils_2load_emission(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_path, PyObject *__pyx_v_comp, PyObject *__pyx_v_mie, PyObject *__pyx_v_err, PyObject *__pyx_v_sub_ped); /* proto */ +static PyObject *__pyx_pf_12trioToolsNew_8hmmUtils_4makeobs_set(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_numsubj); /* proto */ +static PyObject *__pyx_pf_12trioToolsNew_8hmmUtils_6input_map(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_path_efile, PyObject *__pyx_v_sub_ped); /* proto */ +static PyObject *__pyx_pf_12trioToolsNew_8hmmUtils_8make_hmm(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_mpath, PyObject *__pyx_v_sprob, PyObject *__pyx_v_comp, PyObject *__pyx_v_mprob, PyObject *__pyx_v_errprob, PyObject *__pyx_v_sub_ped); /* proto */ +static PyObject *__pyx_pf_12trioToolsNew_8hmmUtils_10viterbi(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_obs, PyArrayObject *__pyx_v_states, PyArrayObject *__pyx_v_start_p, PyArrayObject *__pyx_v_trans_p, PyArrayObject *__pyx_v_emit_p); /* proto */ +static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */ +static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info); /* proto */ +static char __pyx_k_1[] = "\n"; +static char __pyx_k_2[] = ""; +static char __pyx_k_4[] = "\t"; +static char __pyx_k_8[] = "Error in hmmUtils.load_transition: Unknown sub-pedigree format: "; +static char __pyx_k_24[] = "Error in hmmUtils.load_emission: Unknown sub-pedigree format: "; +static char __pyx_k_26[] = "EmissionTrioGen.txt"; +static char __pyx_k_27[] = "EmissionQuartetGen.txt"; +static char __pyx_k_28[] = "Error in hmmUtils.input_map: Unknown sub-pedigree format: "; +static char __pyx_k_32[] = "TransitionTrioGen.txt"; +static char __pyx_k_40[] = "TransitionQuartetGen.txt"; +static char __pyx_k_53[] = "Error in hmmUtils.make_hmm: Unknown sub-pedigree format: "; +static char __pyx_k_55[] = "ndarray is not C contiguous"; +static char __pyx_k_57[] = "ndarray is not Fortran contiguous"; +static char __pyx_k_59[] = "Non-native byte order not supported"; +static char __pyx_k_61[] = "unknown dtype code in numpy.pxd (%d)"; +static char __pyx_k_62[] = "Format string allocated too short, see comment in numpy.pxd"; +static char __pyx_k_65[] = "Format string allocated too short."; +static char __pyx_k_69[] = "/home/apps/trioToolsNew/hmmUtils.pyx"; +static char __pyx_k_70[] = "trioToolsNew.hmmUtils"; +static char __pyx_k__B[] = "B"; +static char __pyx_k__H[] = "H"; +static char __pyx_k__I[] = "I"; +static char __pyx_k__L[] = "L"; +static char __pyx_k__O[] = "O"; +static char __pyx_k__Q[] = "Q"; +static char __pyx_k__V[] = "V"; +static char __pyx_k__b[] = "b"; +static char __pyx_k__d[] = "d"; +static char __pyx_k__f[] = "f"; +static char __pyx_k__g[] = "g"; +static char __pyx_k__h[] = "h"; +static char __pyx_k__i[] = "i"; +static char __pyx_k__l[] = "l"; +static char __pyx_k__q[] = "q"; +static char __pyx_k__r[] = "r"; +static char __pyx_k__t[] = "t"; +static char __pyx_k__y[] = "y"; +static char __pyx_k__Zd[] = "Zd"; +static char __pyx_k__Zf[] = "Zf"; +static char __pyx_k__Zg[] = "Zg"; +static char __pyx_k__np[] = "np"; +static char __pyx_k__os[] = "os"; +static char __pyx_k__re[] = "re"; +static char __pyx_k__y0[] = "y0"; +static char __pyx_k__err[] = "err"; +static char __pyx_k__int[] = "int"; +static char __pyx_k__max[] = "max"; +static char __pyx_k__mie[] = "mie"; +static char __pyx_k__obs[] = "obs"; +static char __pyx_k__sys[] = "sys"; +static char __pyx_k__comp[] = "comp"; +static char __pyx_k__emat[] = "emat"; +static char __pyx_k__exit[] = "exit"; +static char __pyx_k__imap[] = "imap"; +static char __pyx_k__line[] = "line"; +static char __pyx_k__math[] = "math"; +static char __pyx_k__open[] = "open"; +static char __pyx_k__path[] = "path"; +static char __pyx_k__prob[] = "prob"; +static char __pyx_k__self[] = "self"; +static char __pyx_k__tmat[] = "tmat"; +static char __pyx_k__array[] = "array"; +static char __pyx_k__efile[] = "efile"; +static char __pyx_k__float[] = "float"; +static char __pyx_k__inmap[] = "inmap"; +static char __pyx_k__log10[] = "log10"; +static char __pyx_k__mpath[] = "mpath"; +static char __pyx_k__mprob[] = "mprob"; +static char __pyx_k__nprob[] = "nprob"; +static char __pyx_k__numpy[] = "numpy"; +static char __pyx_k__range[] = "range"; +static char __pyx_k__split[] = "split"; +static char __pyx_k__sprob[] = "sprob"; +static char __pyx_k__state[] = "state"; +static char __pyx_k__tfile[] = "tfile"; +static char __pyx_k__trash[] = "trash"; +static char __pyx_k__zeros[] = "zeros"; +static char __pyx_k__DTYPEf[] = "DTYPEf"; +static char __pyx_k__DTYPEi[] = "DTYPEi"; +static char __pyx_k__emit_p[] = "emit_p"; +static char __pyx_k__getopt[] = "getopt"; +static char __pyx_k__startp[] = "startp"; +static char __pyx_k__states[] = "states"; +static char __pyx_k__stderr[] = "stderr"; +static char __pyx_k__tempin[] = "tempin"; +static char __pyx_k__comprob[] = "comprob"; +static char __pyx_k__emitmat[] = "emitmat"; +static char __pyx_k__erprobC[] = "erprobC"; +static char __pyx_k__erprobG[] = "erprobG"; +static char __pyx_k__erprobM[] = "erprobM"; +static char __pyx_k__errprob[] = "errprob"; +static char __pyx_k__mieprob[] = "mieprob"; +static char __pyx_k__nonself[] = "nonself"; +static char __pyx_k__numsubj[] = "numsubj"; +static char __pyx_k__replace[] = "replace"; +static char __pyx_k__start_p[] = "start_p"; +static char __pyx_k__sub_ped[] = "sub_ped"; +static char __pyx_k__trans_p[] = "trans_p"; +static char __pyx_k__viterbi[] = "viterbi"; +static char __pyx_k____main__[] = "__main__"; +static char __pyx_k____test__[] = "__test__"; +static char __pyx_k__argparse[] = "argparse"; +static char __pyx_k__erprobHI[] = "erprobHI"; +static char __pyx_k__erprobID[] = "erprobID"; +static char __pyx_k__goodprob[] = "goodprob"; +static char __pyx_k__linelist[] = "linelist"; +static char __pyx_k__make_hmm[] = "make_hmm"; +static char __pyx_k__n_assort[] = "n_assort"; +static char __pyx_k__readline[] = "readline"; +static char __pyx_k__transmat[] = "transmat"; +static char __pyx_k__fileinput[] = "fileinput"; +static char __pyx_k__input_map[] = "input_map"; +static char __pyx_k__readlines[] = "readlines"; +static char __pyx_k__selftrans[] = "selftrans"; +static char __pyx_k__ValueError[] = "ValueError"; +static char __pyx_k__goodprobHI[] = "goodprobHI"; +static char __pyx_k__goodprobID[] = "goodprobID"; +static char __pyx_k__path_efile[] = "path_efile"; +static char __pyx_k__makeobs_set[] = "makeobs_set"; +static char __pyx_k__RuntimeError[] = "RuntimeError"; +static char __pyx_k__nonselftrans[] = "nonselftrans"; +static char __pyx_k__load_emission[] = "load_emission"; +static char __pyx_k__load_transition[] = "load_transition"; +static PyObject *__pyx_kp_s_1; +static PyObject *__pyx_kp_s_2; +static PyObject *__pyx_kp_s_24; +static PyObject *__pyx_kp_s_26; +static PyObject *__pyx_kp_s_27; +static PyObject *__pyx_kp_s_28; +static PyObject *__pyx_kp_s_32; +static PyObject *__pyx_kp_s_4; +static PyObject *__pyx_kp_s_40; +static PyObject *__pyx_kp_s_53; +static PyObject *__pyx_kp_u_55; +static PyObject *__pyx_kp_u_57; +static PyObject *__pyx_kp_u_59; +static PyObject *__pyx_kp_u_61; +static PyObject *__pyx_kp_u_62; +static PyObject *__pyx_kp_u_65; +static PyObject *__pyx_kp_s_69; +static PyObject *__pyx_n_s_70; +static PyObject *__pyx_kp_s_8; +static PyObject *__pyx_n_s__DTYPEf; +static PyObject *__pyx_n_s__DTYPEi; +static PyObject *__pyx_n_s__RuntimeError; +static PyObject *__pyx_n_s__V; +static PyObject *__pyx_n_s__ValueError; +static PyObject *__pyx_n_s____main__; +static PyObject *__pyx_n_s____test__; +static PyObject *__pyx_n_s__argparse; +static PyObject *__pyx_n_s__array; +static PyObject *__pyx_n_s__comp; +static PyObject *__pyx_n_s__comprob; +static PyObject *__pyx_n_s__efile; +static PyObject *__pyx_n_s__emat; +static PyObject *__pyx_n_s__emit_p; +static PyObject *__pyx_n_s__emitmat; +static PyObject *__pyx_n_s__erprobC; +static PyObject *__pyx_n_s__erprobG; +static PyObject *__pyx_n_s__erprobHI; +static PyObject *__pyx_n_s__erprobID; +static PyObject *__pyx_n_s__erprobM; +static PyObject *__pyx_n_s__err; +static PyObject *__pyx_n_s__errprob; +static PyObject *__pyx_n_s__exit; +static PyObject *__pyx_n_s__fileinput; +static PyObject *__pyx_n_s__float; +static PyObject *__pyx_n_s__getopt; +static PyObject *__pyx_n_s__goodprob; +static PyObject *__pyx_n_s__goodprobHI; +static PyObject *__pyx_n_s__goodprobID; +static PyObject *__pyx_n_s__i; +static PyObject *__pyx_n_s__imap; +static PyObject *__pyx_n_s__inmap; +static PyObject *__pyx_n_s__input_map; +static PyObject *__pyx_n_s__int; +static PyObject *__pyx_n_s__line; +static PyObject *__pyx_n_s__linelist; +static PyObject *__pyx_n_s__load_emission; +static PyObject *__pyx_n_s__load_transition; +static PyObject *__pyx_n_s__log10; +static PyObject *__pyx_n_s__make_hmm; +static PyObject *__pyx_n_s__makeobs_set; +static PyObject *__pyx_n_s__math; +static PyObject *__pyx_n_s__max; +static PyObject *__pyx_n_s__mie; +static PyObject *__pyx_n_s__mieprob; +static PyObject *__pyx_n_s__mpath; +static PyObject *__pyx_n_s__mprob; +static PyObject *__pyx_n_s__n_assort; +static PyObject *__pyx_n_s__nonself; +static PyObject *__pyx_n_s__nonselftrans; +static PyObject *__pyx_n_s__np; +static PyObject *__pyx_n_s__nprob; +static PyObject *__pyx_n_s__numpy; +static PyObject *__pyx_n_s__numsubj; +static PyObject *__pyx_n_s__obs; +static PyObject *__pyx_n_s__open; +static PyObject *__pyx_n_s__os; +static PyObject *__pyx_n_s__path; +static PyObject *__pyx_n_s__path_efile; +static PyObject *__pyx_n_s__prob; +static PyObject *__pyx_n_s__q; +static PyObject *__pyx_n_s__r; +static PyObject *__pyx_n_s__range; +static PyObject *__pyx_n_s__re; +static PyObject *__pyx_n_s__readline; +static PyObject *__pyx_n_s__readlines; +static PyObject *__pyx_n_s__replace; +static PyObject *__pyx_n_s__self; +static PyObject *__pyx_n_s__selftrans; +static PyObject *__pyx_n_s__split; +static PyObject *__pyx_n_s__sprob; +static PyObject *__pyx_n_s__start_p; +static PyObject *__pyx_n_s__startp; +static PyObject *__pyx_n_s__state; +static PyObject *__pyx_n_s__states; +static PyObject *__pyx_n_s__stderr; +static PyObject *__pyx_n_s__sub_ped; +static PyObject *__pyx_n_s__sys; +static PyObject *__pyx_n_s__t; +static PyObject *__pyx_n_s__tempin; +static PyObject *__pyx_n_s__tfile; +static PyObject *__pyx_n_s__tmat; +static PyObject *__pyx_n_s__trans_p; +static PyObject *__pyx_n_s__transmat; +static PyObject *__pyx_n_s__trash; +static PyObject *__pyx_n_s__viterbi; +static PyObject *__pyx_n_s__y; +static PyObject *__pyx_n_s__y0; +static PyObject *__pyx_n_s__zeros; +static PyObject *__pyx_int_0; +static PyObject *__pyx_int_1; +static PyObject *__pyx_int_2; +static PyObject *__pyx_int_3; +static PyObject *__pyx_int_4; +static PyObject *__pyx_int_5; +static PyObject *__pyx_int_6; +static PyObject *__pyx_int_12; +static PyObject *__pyx_int_15; +static PyObject *__pyx_int_16; +static PyObject *__pyx_int_26; +static PyObject *__pyx_int_27; +static PyObject *__pyx_int_29; +static PyObject *__pyx_int_52; +static PyObject *__pyx_int_65; +static PyObject *__pyx_int_66; +static PyObject *__pyx_int_80; +static PyObject *__pyx_int_81; +static PyObject *__pyx_k_tuple_3; +static PyObject *__pyx_k_tuple_5; +static PyObject *__pyx_k_tuple_6; +static PyObject *__pyx_k_tuple_7; +static PyObject *__pyx_k_tuple_9; +static PyObject *__pyx_k_tuple_10; +static PyObject *__pyx_k_tuple_11; +static PyObject *__pyx_k_tuple_12; +static PyObject *__pyx_k_tuple_13; +static PyObject *__pyx_k_tuple_14; +static PyObject *__pyx_k_tuple_15; +static PyObject *__pyx_k_tuple_16; +static PyObject *__pyx_k_tuple_17; +static PyObject *__pyx_k_tuple_18; +static PyObject *__pyx_k_tuple_19; +static PyObject *__pyx_k_tuple_20; +static PyObject *__pyx_k_tuple_21; +static PyObject *__pyx_k_tuple_22; +static PyObject *__pyx_k_tuple_23; +static PyObject *__pyx_k_tuple_25; +static PyObject *__pyx_k_tuple_29; +static PyObject *__pyx_k_tuple_30; +static PyObject *__pyx_k_tuple_31; +static PyObject *__pyx_k_tuple_33; +static PyObject *__pyx_k_tuple_34; +static PyObject *__pyx_k_tuple_35; +static PyObject *__pyx_k_tuple_36; +static PyObject *__pyx_k_tuple_37; +static PyObject *__pyx_k_tuple_38; +static PyObject *__pyx_k_tuple_39; +static PyObject *__pyx_k_tuple_41; +static PyObject *__pyx_k_tuple_42; +static PyObject *__pyx_k_tuple_43; +static PyObject *__pyx_k_tuple_44; +static PyObject *__pyx_k_tuple_45; +static PyObject *__pyx_k_tuple_46; +static PyObject *__pyx_k_tuple_47; +static PyObject *__pyx_k_tuple_48; +static PyObject *__pyx_k_tuple_49; +static PyObject *__pyx_k_tuple_50; +static PyObject *__pyx_k_tuple_51; +static PyObject *__pyx_k_tuple_52; +static PyObject *__pyx_k_tuple_54; +static PyObject *__pyx_k_tuple_56; +static PyObject *__pyx_k_tuple_58; +static PyObject *__pyx_k_tuple_60; +static PyObject *__pyx_k_tuple_63; +static PyObject *__pyx_k_tuple_64; +static PyObject *__pyx_k_tuple_66; +static PyObject *__pyx_k_tuple_67; +static PyObject *__pyx_k_tuple_71; +static PyObject *__pyx_k_tuple_73; +static PyObject *__pyx_k_tuple_75; +static PyObject *__pyx_k_tuple_77; +static PyObject *__pyx_k_tuple_79; +static PyObject *__pyx_k_codeobj_68; +static PyObject *__pyx_k_codeobj_72; +static PyObject *__pyx_k_codeobj_74; +static PyObject *__pyx_k_codeobj_76; +static PyObject *__pyx_k_codeobj_78; +static PyObject *__pyx_k_codeobj_80; + +/* Python wrapper */ +static PyObject *__pyx_pw_12trioToolsNew_8hmmUtils_1load_transition(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyMethodDef __pyx_mdef_12trioToolsNew_8hmmUtils_1load_transition = {__Pyx_NAMESTR("load_transition"), (PyCFunction)__pyx_pw_12trioToolsNew_8hmmUtils_1load_transition, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}; +static PyObject *__pyx_pw_12trioToolsNew_8hmmUtils_1load_transition(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_path = 0; + PyObject *__pyx_v_selftrans = 0; + PyObject *__pyx_v_nonselftrans = 0; + PyObject *__pyx_v_sub_ped = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("load_transition (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__path,&__pyx_n_s__selftrans,&__pyx_n_s__nonselftrans,&__pyx_n_s__sub_ped,0}; + PyObject* values[4] = {0,0,0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__path)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__selftrans)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("load_transition", 1, 4, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__nonselftrans)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("load_transition", 1, 4, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 3: + if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__sub_ped)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("load_transition", 1, 4, 4, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "load_transition") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + } + __pyx_v_path = values[0]; + __pyx_v_selftrans = values[1]; + __pyx_v_nonselftrans = values[2]; + __pyx_v_sub_ped = values[3]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("load_transition", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("trioToolsNew.hmmUtils.load_transition", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_12trioToolsNew_8hmmUtils_load_transition(__pyx_self, __pyx_v_path, __pyx_v_selftrans, __pyx_v_nonselftrans, __pyx_v_sub_ped); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "trioToolsNew/hmmUtils.pyx":23 + * + * #loads transition matrix + * def load_transition(path, selftrans, nonselftrans, sub_ped): # <<<<<<<<<<<<<< + * + * #trio case + */ + +static PyObject *__pyx_pf_12trioToolsNew_8hmmUtils_load_transition(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_path, PyObject *__pyx_v_selftrans, PyObject *__pyx_v_nonselftrans, PyObject *__pyx_v_sub_ped) { + PyObject *__pyx_v_tmat = NULL; + PyObject *__pyx_v_i = NULL; + PyObject *__pyx_v_tfile = NULL; + PyObject *__pyx_v_line = NULL; + PyObject *__pyx_v_linelist = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + Py_ssize_t __pyx_t_6; + PyObject *(*__pyx_t_7)(PyObject *); + PyObject *__pyx_t_8 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("load_transition", 0); + + /* "trioToolsNew/hmmUtils.pyx":26 + * + * #trio case + * if sub_ped == "t": # <<<<<<<<<<<<<< + * tmat = np.zeros([3, 3], np.float) + * i = 0 + */ + __pyx_t_1 = PyObject_RichCompare(__pyx_v_sub_ped, ((PyObject *)__pyx_n_s__t), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (__pyx_t_2) { + + /* "trioToolsNew/hmmUtils.pyx":27 + * #trio case + * if sub_ped == "t": + * tmat = np.zeros([3, 3], np.float) # <<<<<<<<<<<<<< + * i = 0 + * tfile = open(path, "r") + */ + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_int_3); + PyList_SET_ITEM(__pyx_t_1, 0, __pyx_int_3); + __Pyx_GIVEREF(__pyx_int_3); + __Pyx_INCREF(__pyx_int_3); + PyList_SET_ITEM(__pyx_t_1, 1, __pyx_int_3); + __Pyx_GIVEREF(__pyx_int_3); + __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__float); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_1)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + __pyx_t_1 = 0; + __pyx_t_5 = 0; + __pyx_t_5 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __pyx_v_tmat = __pyx_t_5; + __pyx_t_5 = 0; + + /* "trioToolsNew/hmmUtils.pyx":28 + * if sub_ped == "t": + * tmat = np.zeros([3, 3], np.float) + * i = 0 # <<<<<<<<<<<<<< + * tfile = open(path, "r") + * for line in tfile.readlines(): + */ + __Pyx_INCREF(__pyx_int_0); + __pyx_v_i = __pyx_int_0; + + /* "trioToolsNew/hmmUtils.pyx":29 + * tmat = np.zeros([3, 3], np.float) + * i = 0 + * tfile = open(path, "r") # <<<<<<<<<<<<<< + * for line in tfile.readlines(): + * linelist = line.replace("nonself", str(nonselftrans)).replace("self", str(selftrans)).replace("\n", "").split("\t") + */ + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_INCREF(__pyx_v_path); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_path); + __Pyx_GIVEREF(__pyx_v_path); + __Pyx_INCREF(((PyObject *)__pyx_n_s__r)); + PyTuple_SET_ITEM(__pyx_t_5, 1, ((PyObject *)__pyx_n_s__r)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__r)); + __pyx_t_4 = PyObject_Call(__pyx_builtin_open, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + __pyx_v_tfile = __pyx_t_4; + __pyx_t_4 = 0; + + /* "trioToolsNew/hmmUtils.pyx":30 + * i = 0 + * tfile = open(path, "r") + * for line in tfile.readlines(): # <<<<<<<<<<<<<< + * linelist = line.replace("nonself", str(nonselftrans)).replace("self", str(selftrans)).replace("\n", "").split("\t") + * tmat[i][0] = math.log10(np.float(linelist[0])) + */ + __pyx_t_4 = PyObject_GetAttr(__pyx_v_tfile, __pyx_n_s__readlines); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (PyList_CheckExact(__pyx_t_5) || PyTuple_CheckExact(__pyx_t_5)) { + __pyx_t_4 = __pyx_t_5; __Pyx_INCREF(__pyx_t_4); __pyx_t_6 = 0; + __pyx_t_7 = NULL; + } else { + __pyx_t_6 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_7 = Py_TYPE(__pyx_t_4)->tp_iternext; + } + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + for (;;) { + if (!__pyx_t_7 && PyList_CheckExact(__pyx_t_4)) { + if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_4)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_5 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_6); __Pyx_INCREF(__pyx_t_5); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_5 = PySequence_ITEM(__pyx_t_4, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + } else if (!__pyx_t_7 && PyTuple_CheckExact(__pyx_t_4)) { + if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_4)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_6); __Pyx_INCREF(__pyx_t_5); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_5 = PySequence_ITEM(__pyx_t_4, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + } else { + __pyx_t_5 = __pyx_t_7(__pyx_t_4); + if (unlikely(!__pyx_t_5)) { + if (PyErr_Occurred()) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); + else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + break; + } + __Pyx_GOTREF(__pyx_t_5); + } + __Pyx_XDECREF(__pyx_v_line); + __pyx_v_line = __pyx_t_5; + __pyx_t_5 = 0; + + /* "trioToolsNew/hmmUtils.pyx":31 + * tfile = open(path, "r") + * for line in tfile.readlines(): + * linelist = line.replace("nonself", str(nonselftrans)).replace("self", str(selftrans)).replace("\n", "").split("\t") # <<<<<<<<<<<<<< + * tmat[i][0] = math.log10(np.float(linelist[0])) + * tmat[i][1] = math.log10(np.float(linelist[1])) + */ + __pyx_t_5 = PyObject_GetAttr(__pyx_v_line, __pyx_n_s__replace); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_v_nonselftrans); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_nonselftrans); + __Pyx_GIVEREF(__pyx_v_nonselftrans); + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(((PyObject *)__pyx_n_s__nonself)); + PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_n_s__nonself)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__nonself)); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_1 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__replace); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_v_selftrans); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_selftrans); + __Pyx_GIVEREF(__pyx_v_selftrans); + __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)__pyx_n_s__self)); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__self)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self)); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + __pyx_t_5 = 0; + __pyx_t_5 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_1 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__replace); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_3), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__split); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_5), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_XDECREF(__pyx_v_linelist); + __pyx_v_linelist = __pyx_t_5; + __pyx_t_5 = 0; + + /* "trioToolsNew/hmmUtils.pyx":32 + * for line in tfile.readlines(): + * linelist = line.replace("nonself", str(nonselftrans)).replace("self", str(selftrans)).replace("\n", "").split("\t") + * tmat[i][0] = math.log10(np.float(linelist[0])) # <<<<<<<<<<<<<< + * tmat[i][1] = math.log10(np.float(linelist[1])) + * tmat[i][2] = math.log10(np.float(linelist[2])) + */ + __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__math); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_1 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__log10); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__float); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_linelist, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + __pyx_t_5 = 0; + __pyx_t_5 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0; + __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + __pyx_t_5 = 0; + __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0; + __pyx_t_8 = PyObject_GetItem(__pyx_v_tmat, __pyx_v_i); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + if (__Pyx_SetItemInt(__pyx_t_8, 0, __pyx_t_5, sizeof(long), PyInt_FromLong) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + + /* "trioToolsNew/hmmUtils.pyx":33 + * linelist = line.replace("nonself", str(nonselftrans)).replace("self", str(selftrans)).replace("\n", "").split("\t") + * tmat[i][0] = math.log10(np.float(linelist[0])) + * tmat[i][1] = math.log10(np.float(linelist[1])) # <<<<<<<<<<<<<< + * tmat[i][2] = math.log10(np.float(linelist[2])) + * i+=1 + */ + __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__math); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_8 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__log10); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_1 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__float); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_linelist, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + __pyx_t_5 = 0; + __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + __pyx_t_5 = 0; + __pyx_t_5 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_t_3 = PyObject_GetItem(__pyx_v_tmat, __pyx_v_i); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + if (__Pyx_SetItemInt(__pyx_t_3, 1, __pyx_t_5, sizeof(long), PyInt_FromLong) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + + /* "trioToolsNew/hmmUtils.pyx":34 + * tmat[i][0] = math.log10(np.float(linelist[0])) + * tmat[i][1] = math.log10(np.float(linelist[1])) + * tmat[i][2] = math.log10(np.float(linelist[2])) # <<<<<<<<<<<<<< + * i+=1 + * return tmat + */ + __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__math); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__log10); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_8 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__float); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_linelist, 2, sizeof(long), PyInt_FromLong); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + __pyx_t_5 = 0; + __pyx_t_5 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + __pyx_t_5 = 0; + __pyx_t_5 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_1 = PyObject_GetItem(__pyx_v_tmat, __pyx_v_i); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (__Pyx_SetItemInt(__pyx_t_1, 2, __pyx_t_5, sizeof(long), PyInt_FromLong) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + + /* "trioToolsNew/hmmUtils.pyx":35 + * tmat[i][1] = math.log10(np.float(linelist[1])) + * tmat[i][2] = math.log10(np.float(linelist[2])) + * i+=1 # <<<<<<<<<<<<<< + * return tmat + * + */ + __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_v_i, __pyx_int_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_v_i); + __pyx_v_i = __pyx_t_5; + __pyx_t_5 = 0; + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + + /* "trioToolsNew/hmmUtils.pyx":36 + * tmat[i][2] = math.log10(np.float(linelist[2])) + * i+=1 + * return tmat # <<<<<<<<<<<<<< + * + * #quartet case + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_tmat); + __pyx_r = __pyx_v_tmat; + goto __pyx_L0; + goto __pyx_L3; + } + + /* "trioToolsNew/hmmUtils.pyx":39 + * + * #quartet case + * elif sub_ped == "q": # <<<<<<<<<<<<<< + * tmat = np.zeros([6, 6], np.float) + * i = 0 + */ + __pyx_t_4 = PyObject_RichCompare(__pyx_v_sub_ped, ((PyObject *)__pyx_n_s__q), Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_2) { + + /* "trioToolsNew/hmmUtils.pyx":40 + * #quartet case + * elif sub_ped == "q": + * tmat = np.zeros([6, 6], np.float) # <<<<<<<<<<<<<< + * i = 0 + * + */ + __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__zeros); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyList_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(__pyx_int_6); + PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_6); + __Pyx_GIVEREF(__pyx_int_6); + __Pyx_INCREF(__pyx_int_6); + PyList_SET_ITEM(__pyx_t_4, 1, __pyx_int_6); + __Pyx_GIVEREF(__pyx_int_6); + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__float); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_4)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_4)); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_4 = 0; + __pyx_t_3 = 0; + __pyx_t_3 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_v_tmat = __pyx_t_3; + __pyx_t_3 = 0; + + /* "trioToolsNew/hmmUtils.pyx":41 + * elif sub_ped == "q": + * tmat = np.zeros([6, 6], np.float) + * i = 0 # <<<<<<<<<<<<<< + * + * tfile = open(path, "r") + */ + __Pyx_INCREF(__pyx_int_0); + __pyx_v_i = __pyx_int_0; + + /* "trioToolsNew/hmmUtils.pyx":43 + * i = 0 + * + * tfile = open(path, "r") # <<<<<<<<<<<<<< + * for line in tfile.readlines(): + * linelist = line.replace("nonself", str(nonselftrans)).replace("self", str(selftrans)).replace("\n", "").split("\t") + */ + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_v_path); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_path); + __Pyx_GIVEREF(__pyx_v_path); + __Pyx_INCREF(((PyObject *)__pyx_n_s__r)); + PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_n_s__r)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__r)); + __pyx_t_1 = PyObject_Call(__pyx_builtin_open, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_v_tfile = __pyx_t_1; + __pyx_t_1 = 0; + + /* "trioToolsNew/hmmUtils.pyx":44 + * + * tfile = open(path, "r") + * for line in tfile.readlines(): # <<<<<<<<<<<<<< + * linelist = line.replace("nonself", str(nonselftrans)).replace("self", str(selftrans)).replace("\n", "").split("\t") + * tmat[i][0] = math.log10(np.float(linelist[0])) + */ + __pyx_t_1 = PyObject_GetAttr(__pyx_v_tfile, __pyx_n_s__readlines); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (PyList_CheckExact(__pyx_t_3) || PyTuple_CheckExact(__pyx_t_3)) { + __pyx_t_1 = __pyx_t_3; __Pyx_INCREF(__pyx_t_1); __pyx_t_6 = 0; + __pyx_t_7 = NULL; + } else { + __pyx_t_6 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_7 = Py_TYPE(__pyx_t_1)->tp_iternext; + } + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + for (;;) { + if (!__pyx_t_7 && PyList_CheckExact(__pyx_t_1)) { + if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + } else if (!__pyx_t_7 && PyTuple_CheckExact(__pyx_t_1)) { + if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + } else { + __pyx_t_3 = __pyx_t_7(__pyx_t_1); + if (unlikely(!__pyx_t_3)) { + if (PyErr_Occurred()) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); + else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + break; + } + __Pyx_GOTREF(__pyx_t_3); + } + __Pyx_XDECREF(__pyx_v_line); + __pyx_v_line = __pyx_t_3; + __pyx_t_3 = 0; + + /* "trioToolsNew/hmmUtils.pyx":45 + * tfile = open(path, "r") + * for line in tfile.readlines(): + * linelist = line.replace("nonself", str(nonselftrans)).replace("self", str(selftrans)).replace("\n", "").split("\t") # <<<<<<<<<<<<<< + * tmat[i][0] = math.log10(np.float(linelist[0])) + * tmat[i][1] = math.log10(np.float(linelist[1])) + */ + __pyx_t_3 = PyObject_GetAttr(__pyx_v_line, __pyx_n_s__replace); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_INCREF(__pyx_v_nonselftrans); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_nonselftrans); + __Pyx_GIVEREF(__pyx_v_nonselftrans); + __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_INCREF(((PyObject *)__pyx_n_s__nonself)); + PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_n_s__nonself)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__nonself)); + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__replace); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(__pyx_v_selftrans); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_selftrans); + __Pyx_GIVEREF(__pyx_v_selftrans); + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(((PyObject *)__pyx_n_s__self)); + PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_n_s__self)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self)); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_3 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __pyx_t_4 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__replace); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_k_tuple_6), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__split); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_k_tuple_7), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_XDECREF(__pyx_v_linelist); + __pyx_v_linelist = __pyx_t_3; + __pyx_t_3 = 0; + + /* "trioToolsNew/hmmUtils.pyx":46 + * for line in tfile.readlines(): + * linelist = line.replace("nonself", str(nonselftrans)).replace("self", str(selftrans)).replace("\n", "").split("\t") + * tmat[i][0] = math.log10(np.float(linelist[0])) # <<<<<<<<<<<<<< + * tmat[i][1] = math.log10(np.float(linelist[1])) + * tmat[i][2] = math.log10(np.float(linelist[2])) + */ + __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__math); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__log10); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__float); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_linelist, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_3 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0; + __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0; + __pyx_t_8 = PyObject_GetItem(__pyx_v_tmat, __pyx_v_i); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + if (__Pyx_SetItemInt(__pyx_t_8, 0, __pyx_t_3, sizeof(long), PyInt_FromLong) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "trioToolsNew/hmmUtils.pyx":47 + * linelist = line.replace("nonself", str(nonselftrans)).replace("self", str(selftrans)).replace("\n", "").split("\t") + * tmat[i][0] = math.log10(np.float(linelist[0])) + * tmat[i][1] = math.log10(np.float(linelist[1])) # <<<<<<<<<<<<<< + * tmat[i][2] = math.log10(np.float(linelist[2])) + * tmat[i][3] = math.log10(np.float(linelist[3])) + */ + __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__math); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_8 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__log10); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__float); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_linelist, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_3 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + __pyx_t_5 = PyObject_GetItem(__pyx_v_tmat, __pyx_v_i); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + if (__Pyx_SetItemInt(__pyx_t_5, 1, __pyx_t_3, sizeof(long), PyInt_FromLong) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "trioToolsNew/hmmUtils.pyx":48 + * tmat[i][0] = math.log10(np.float(linelist[0])) + * tmat[i][1] = math.log10(np.float(linelist[1])) + * tmat[i][2] = math.log10(np.float(linelist[2])) # <<<<<<<<<<<<<< + * tmat[i][3] = math.log10(np.float(linelist[3])) + * tmat[i][4] = math.log10(np.float(linelist[4])) + */ + __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__math); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__log10); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_8 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__float); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_linelist, 2, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_3 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_3 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __pyx_t_4 = PyObject_GetItem(__pyx_v_tmat, __pyx_v_i); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + if (__Pyx_SetItemInt(__pyx_t_4, 2, __pyx_t_3, sizeof(long), PyInt_FromLong) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "trioToolsNew/hmmUtils.pyx":49 + * tmat[i][1] = math.log10(np.float(linelist[1])) + * tmat[i][2] = math.log10(np.float(linelist[2])) + * tmat[i][3] = math.log10(np.float(linelist[3])) # <<<<<<<<<<<<<< + * tmat[i][4] = math.log10(np.float(linelist[4])) + * tmat[i][5] = math.log10(np.float(linelist[5])) + */ + __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__math); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__log10); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__float); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_linelist, 3, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_3 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0; + __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0; + __pyx_t_8 = PyObject_GetItem(__pyx_v_tmat, __pyx_v_i); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + if (__Pyx_SetItemInt(__pyx_t_8, 3, __pyx_t_3, sizeof(long), PyInt_FromLong) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "trioToolsNew/hmmUtils.pyx":50 + * tmat[i][2] = math.log10(np.float(linelist[2])) + * tmat[i][3] = math.log10(np.float(linelist[3])) + * tmat[i][4] = math.log10(np.float(linelist[4])) # <<<<<<<<<<<<<< + * tmat[i][5] = math.log10(np.float(linelist[5])) + * i+=1 + */ + __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__math); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_8 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__log10); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__float); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_linelist, 4, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_3 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + __pyx_t_5 = PyObject_GetItem(__pyx_v_tmat, __pyx_v_i); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + if (__Pyx_SetItemInt(__pyx_t_5, 4, __pyx_t_3, sizeof(long), PyInt_FromLong) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "trioToolsNew/hmmUtils.pyx":51 + * tmat[i][3] = math.log10(np.float(linelist[3])) + * tmat[i][4] = math.log10(np.float(linelist[4])) + * tmat[i][5] = math.log10(np.float(linelist[5])) # <<<<<<<<<<<<<< + * i+=1 + * return tmat + */ + __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__math); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__log10); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_8 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__float); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_linelist, 5, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_3 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_3 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __pyx_t_4 = PyObject_GetItem(__pyx_v_tmat, __pyx_v_i); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + if (__Pyx_SetItemInt(__pyx_t_4, 5, __pyx_t_3, sizeof(long), PyInt_FromLong) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "trioToolsNew/hmmUtils.pyx":52 + * tmat[i][4] = math.log10(np.float(linelist[4])) + * tmat[i][5] = math.log10(np.float(linelist[5])) + * i+=1 # <<<<<<<<<<<<<< + * return tmat + * + */ + __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_i, __pyx_int_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_v_i); + __pyx_v_i = __pyx_t_3; + __pyx_t_3 = 0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "trioToolsNew/hmmUtils.pyx":53 + * tmat[i][5] = math.log10(np.float(linelist[5])) + * i+=1 + * return tmat # <<<<<<<<<<<<<< + * + * else: + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_tmat); + __pyx_r = __pyx_v_tmat; + goto __pyx_L0; + goto __pyx_L3; + } + /*else*/ { + + /* "trioToolsNew/hmmUtils.pyx":56 + * + * else: + * print >> sys.stderr, "Error in hmmUtils.load_transition: Unknown sub-pedigree format: "+sub_ped # <<<<<<<<<<<<<< + * exit(1) + * + */ + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__sys); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__stderr); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyNumber_Add(((PyObject *)__pyx_kp_s_8), __pyx_v_sub_ped); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (__Pyx_PrintOne(__pyx_t_3, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "trioToolsNew/hmmUtils.pyx":57 + * else: + * print >> sys.stderr, "Error in hmmUtils.load_transition: Unknown sub-pedigree format: "+sub_ped + * exit(1) # <<<<<<<<<<<<<< + * + * #loads emission matrix for hmm + */ + __pyx_t_3 = PyObject_Call(__pyx_builtin_exit, ((PyObject *)__pyx_k_tuple_9), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } + __pyx_L3:; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_AddTraceback("trioToolsNew.hmmUtils.load_transition", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_tmat); + __Pyx_XDECREF(__pyx_v_i); + __Pyx_XDECREF(__pyx_v_tfile); + __Pyx_XDECREF(__pyx_v_line); + __Pyx_XDECREF(__pyx_v_linelist); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_12trioToolsNew_8hmmUtils_3load_emission(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyMethodDef __pyx_mdef_12trioToolsNew_8hmmUtils_3load_emission = {__Pyx_NAMESTR("load_emission"), (PyCFunction)__pyx_pw_12trioToolsNew_8hmmUtils_3load_emission, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}; +static PyObject *__pyx_pw_12trioToolsNew_8hmmUtils_3load_emission(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_path = 0; + PyObject *__pyx_v_comp = 0; + PyObject *__pyx_v_mie = 0; + PyObject *__pyx_v_err = 0; + PyObject *__pyx_v_sub_ped = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("load_emission (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__path,&__pyx_n_s__comp,&__pyx_n_s__mie,&__pyx_n_s__err,&__pyx_n_s__sub_ped,0}; + PyObject* values[5] = {0,0,0,0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__path)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__comp)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("load_emission", 1, 5, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__mie)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("load_emission", 1, 5, 5, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 3: + if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__err)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("load_emission", 1, 5, 5, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 4: + if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__sub_ped)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("load_emission", 1, 5, 5, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "load_emission") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 5) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + } + __pyx_v_path = values[0]; + __pyx_v_comp = values[1]; + __pyx_v_mie = values[2]; + __pyx_v_err = values[3]; + __pyx_v_sub_ped = values[4]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("load_emission", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("trioToolsNew.hmmUtils.load_emission", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_12trioToolsNew_8hmmUtils_2load_emission(__pyx_self, __pyx_v_path, __pyx_v_comp, __pyx_v_mie, __pyx_v_err, __pyx_v_sub_ped); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "trioToolsNew/hmmUtils.pyx":60 + * + * #loads emission matrix for hmm + * def load_emission(path, comp, mie, err, sub_ped): # <<<<<<<<<<<<<< + * + * #trio case + */ + +static PyObject *__pyx_pf_12trioToolsNew_8hmmUtils_2load_emission(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_path, PyObject *__pyx_v_comp, PyObject *__pyx_v_mie, PyObject *__pyx_v_err, PyObject *__pyx_v_sub_ped) { + PyObject *__pyx_v_emat = NULL; + PyObject *__pyx_v_efile = NULL; + CYTHON_UNUSED PyObject *__pyx_v_trash = NULL; + PyObject *__pyx_v_erprobG = NULL; + PyObject *__pyx_v_goodprob = NULL; + PyObject *__pyx_v_erprobC = NULL; + PyObject *__pyx_v_erprobM = NULL; + PyObject *__pyx_v_mieprob = NULL; + PyObject *__pyx_v_i = NULL; + PyObject *__pyx_v_line = NULL; + PyObject *__pyx_v_linelist = NULL; + PyObject *__pyx_v_erprobHI = NULL; + PyObject *__pyx_v_erprobID = NULL; + PyObject *__pyx_v_goodprobID = NULL; + PyObject *__pyx_v_goodprobHI = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + Py_ssize_t __pyx_t_6; + PyObject *(*__pyx_t_7)(PyObject *); + PyObject *__pyx_t_8 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("load_emission", 0); + + /* "trioToolsNew/hmmUtils.pyx":63 + * + * #trio case + * if sub_ped == "t": # <<<<<<<<<<<<<< + * emat = np.zeros([3, 27], np.float) + * + */ + __pyx_t_1 = PyObject_RichCompare(__pyx_v_sub_ped, ((PyObject *)__pyx_n_s__t), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (__pyx_t_2) { + + /* "trioToolsNew/hmmUtils.pyx":64 + * #trio case + * if sub_ped == "t": + * emat = np.zeros([3, 27], np.float) # <<<<<<<<<<<<<< + * + * efile = open(path, "r") + */ + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_int_3); + PyList_SET_ITEM(__pyx_t_1, 0, __pyx_int_3); + __Pyx_GIVEREF(__pyx_int_3); + __Pyx_INCREF(__pyx_int_27); + PyList_SET_ITEM(__pyx_t_1, 1, __pyx_int_27); + __Pyx_GIVEREF(__pyx_int_27); + __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__float); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_1)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + __pyx_t_1 = 0; + __pyx_t_5 = 0; + __pyx_t_5 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __pyx_v_emat = __pyx_t_5; + __pyx_t_5 = 0; + + /* "trioToolsNew/hmmUtils.pyx":66 + * emat = np.zeros([3, 27], np.float) + * + * efile = open(path, "r") # <<<<<<<<<<<<<< + * trash = efile.readline() + * + */ + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_INCREF(__pyx_v_path); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_path); + __Pyx_GIVEREF(__pyx_v_path); + __Pyx_INCREF(((PyObject *)__pyx_n_s__r)); + PyTuple_SET_ITEM(__pyx_t_5, 1, ((PyObject *)__pyx_n_s__r)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__r)); + __pyx_t_4 = PyObject_Call(__pyx_builtin_open, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + __pyx_v_efile = __pyx_t_4; + __pyx_t_4 = 0; + + /* "trioToolsNew/hmmUtils.pyx":67 + * + * efile = open(path, "r") + * trash = efile.readline() # <<<<<<<<<<<<<< + * + * #alleles are in father, mother, child order + */ + __pyx_t_4 = PyObject_GetAttr(__pyx_v_efile, __pyx_n_s__readline); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_v_trash = __pyx_t_5; + __pyx_t_5 = 0; + + /* "trioToolsNew/hmmUtils.pyx":71 + * #alleles are in father, mother, child order + * #there are 12 allele assortments consistent with MIEs and one uniformly heterozygous position indicating possible compressions + * erprobG = np.float(err)/np.float(12) # <<<<<<<<<<<<<< + * goodprob = (1-np.float(err))/np.float(15) + * + */ + __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_4 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__float); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_INCREF(__pyx_v_err); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_err); + __Pyx_GIVEREF(__pyx_v_err); + __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_4 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__float); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_k_tuple_10), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_PyNumber_Divide(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_v_erprobG = __pyx_t_4; + __pyx_t_4 = 0; + + /* "trioToolsNew/hmmUtils.pyx":72 + * #there are 12 allele assortments consistent with MIEs and one uniformly heterozygous position indicating possible compressions + * erprobG = np.float(err)/np.float(12) + * goodprob = (1-np.float(err))/np.float(15) # <<<<<<<<<<<<<< + * + * erprobC = (1-np.float(comp))/np.float(26) + */ + __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__float); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(__pyx_v_err); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_err); + __Pyx_GIVEREF(__pyx_v_err); + __pyx_t_3 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __pyx_t_4 = PyNumber_Subtract(__pyx_int_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__float); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_k_tuple_11), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_PyNumber_Divide(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_goodprob = __pyx_t_5; + __pyx_t_5 = 0; + + /* "trioToolsNew/hmmUtils.pyx":74 + * goodprob = (1-np.float(err))/np.float(15) + * + * erprobC = (1-np.float(comp))/np.float(26) # <<<<<<<<<<<<<< + * + * erprobM = (1-np.float(mie))/np.float(15) + */ + __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__float); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_INCREF(__pyx_v_comp); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_comp); + __Pyx_GIVEREF(__pyx_v_comp); + __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + __pyx_t_5 = PyNumber_Subtract(__pyx_int_1, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__float); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_k_tuple_12), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyNumber_Divide(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_v_erprobC = __pyx_t_3; + __pyx_t_3 = 0; + + /* "trioToolsNew/hmmUtils.pyx":76 + * erprobC = (1-np.float(comp))/np.float(26) + * + * erprobM = (1-np.float(mie))/np.float(15) # <<<<<<<<<<<<<< + * mieprob = np.float(mie)/np.float(12) + * + */ + __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__float); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_v_mie); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_mie); + __Pyx_GIVEREF(__pyx_v_mie); + __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_t_3 = PyNumber_Subtract(__pyx_int_1, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_4 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__float); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_k_tuple_13), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_PyNumber_Divide(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_v_erprobM = __pyx_t_4; + __pyx_t_4 = 0; + + /* "trioToolsNew/hmmUtils.pyx":77 + * + * erprobM = (1-np.float(mie))/np.float(15) + * mieprob = np.float(mie)/np.float(12) # <<<<<<<<<<<<<< + * + * i = 0 + */ + __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__float); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(__pyx_v_mie); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_mie); + __Pyx_GIVEREF(__pyx_v_mie); + __pyx_t_3 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__float); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_k_tuple_14), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_PyNumber_Divide(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_v_mieprob = __pyx_t_5; + __pyx_t_5 = 0; + + /* "trioToolsNew/hmmUtils.pyx":79 + * mieprob = np.float(mie)/np.float(12) + * + * i = 0 # <<<<<<<<<<<<<< + * #0 is MIErich, 1 is compression, 2 is good data + * for line in efile.readlines(): + */ + __Pyx_INCREF(__pyx_int_0); + __pyx_v_i = __pyx_int_0; + + /* "trioToolsNew/hmmUtils.pyx":81 + * i = 0 + * #0 is MIErich, 1 is compression, 2 is good data + * for line in efile.readlines(): # <<<<<<<<<<<<<< + * linelist = line.replace("erprobM", str(erprobM)).replace("erprobG", str(erprobG)).replace("goodprob", str(goodprob)).replace("comprob", str(comp)).replace("erprobC", str(erprobC)).replace("mieprob", str(mieprob)).split("\t") + * emat[0][i] = math.log10(np.float(linelist[2])) + */ + __pyx_t_5 = PyObject_GetAttr(__pyx_v_efile, __pyx_n_s__readlines); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_4 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (PyList_CheckExact(__pyx_t_4) || PyTuple_CheckExact(__pyx_t_4)) { + __pyx_t_5 = __pyx_t_4; __Pyx_INCREF(__pyx_t_5); __pyx_t_6 = 0; + __pyx_t_7 = NULL; + } else { + __pyx_t_6 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_7 = Py_TYPE(__pyx_t_5)->tp_iternext; + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + for (;;) { + if (!__pyx_t_7 && PyList_CheckExact(__pyx_t_5)) { + if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_5)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_4 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_4); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_4 = PySequence_ITEM(__pyx_t_5, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + } else if (!__pyx_t_7 && PyTuple_CheckExact(__pyx_t_5)) { + if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_5)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_4); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_4 = PySequence_ITEM(__pyx_t_5, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + } else { + __pyx_t_4 = __pyx_t_7(__pyx_t_5); + if (unlikely(!__pyx_t_4)) { + if (PyErr_Occurred()) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); + else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + break; + } + __Pyx_GOTREF(__pyx_t_4); + } + __Pyx_XDECREF(__pyx_v_line); + __pyx_v_line = __pyx_t_4; + __pyx_t_4 = 0; + + /* "trioToolsNew/hmmUtils.pyx":82 + * #0 is MIErich, 1 is compression, 2 is good data + * for line in efile.readlines(): + * linelist = line.replace("erprobM", str(erprobM)).replace("erprobG", str(erprobG)).replace("goodprob", str(goodprob)).replace("comprob", str(comp)).replace("erprobC", str(erprobC)).replace("mieprob", str(mieprob)).split("\t") # <<<<<<<<<<<<<< + * emat[0][i] = math.log10(np.float(linelist[2])) + * emat[1][i] = math.log10(np.float(linelist[3])) + */ + __pyx_t_4 = PyObject_GetAttr(__pyx_v_line, __pyx_n_s__replace); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_v_erprobM); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_erprobM); + __Pyx_GIVEREF(__pyx_v_erprobM); + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(((PyObject *)__pyx_n_s__erprobM)); + PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_n_s__erprobM)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__erprobM)); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__replace); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_v_erprobG); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_erprobG); + __Pyx_GIVEREF(__pyx_v_erprobG); + __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)__pyx_n_s__erprobG)); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__erprobG)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__erprobG)); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_1 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__replace); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(__pyx_v_goodprob); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_goodprob); + __Pyx_GIVEREF(__pyx_v_goodprob); + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(((PyObject *)__pyx_n_s__goodprob)); + PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_n_s__goodprob)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__goodprob)); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __pyx_t_4 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__replace); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_v_comp); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_comp); + __Pyx_GIVEREF(__pyx_v_comp); + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(((PyObject *)__pyx_n_s__comprob)); + PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_n_s__comprob)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__comprob)); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__replace); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_v_erprobC); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_erprobC); + __Pyx_GIVEREF(__pyx_v_erprobC); + __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)__pyx_n_s__erprobC)); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__erprobC)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__erprobC)); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_1 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__replace); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(__pyx_v_mieprob); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_mieprob); + __Pyx_GIVEREF(__pyx_v_mieprob); + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(((PyObject *)__pyx_n_s__mieprob)); + PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_n_s__mieprob)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__mieprob)); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __pyx_t_4 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__split); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_k_tuple_15), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_XDECREF(__pyx_v_linelist); + __pyx_v_linelist = __pyx_t_3; + __pyx_t_3 = 0; + + /* "trioToolsNew/hmmUtils.pyx":83 + * for line in efile.readlines(): + * linelist = line.replace("erprobM", str(erprobM)).replace("erprobG", str(erprobG)).replace("goodprob", str(goodprob)).replace("comprob", str(comp)).replace("erprobC", str(erprobC)).replace("mieprob", str(mieprob)).split("\t") + * emat[0][i] = math.log10(np.float(linelist[2])) # <<<<<<<<<<<<<< + * emat[1][i] = math.log10(np.float(linelist[3])) + * emat[2][i] = math.log10(np.float(linelist[4])) + */ + __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__math); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__log10); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__float); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_linelist, 2, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0; + __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0; + __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_emat, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + if (PyObject_SetItem(__pyx_t_8, __pyx_v_i, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "trioToolsNew/hmmUtils.pyx":84 + * linelist = line.replace("erprobM", str(erprobM)).replace("erprobG", str(erprobG)).replace("goodprob", str(goodprob)).replace("comprob", str(comp)).replace("erprobC", str(erprobC)).replace("mieprob", str(mieprob)).split("\t") + * emat[0][i] = math.log10(np.float(linelist[2])) + * emat[1][i] = math.log10(np.float(linelist[3])) # <<<<<<<<<<<<<< + * emat[2][i] = math.log10(np.float(linelist[4])) + * i+=1 + */ + __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__math); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_8 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__log10); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__float); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_linelist, 3, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_3 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_emat, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (PyObject_SetItem(__pyx_t_1, __pyx_v_i, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "trioToolsNew/hmmUtils.pyx":85 + * emat[0][i] = math.log10(np.float(linelist[2])) + * emat[1][i] = math.log10(np.float(linelist[3])) + * emat[2][i] = math.log10(np.float(linelist[4])) # <<<<<<<<<<<<<< + * i+=1 + * return emat + */ + __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__math); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__log10); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_8 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__float); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_linelist, 4, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_3 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_emat, 2, sizeof(long), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + if (PyObject_SetItem(__pyx_t_4, __pyx_v_i, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "trioToolsNew/hmmUtils.pyx":86 + * emat[1][i] = math.log10(np.float(linelist[3])) + * emat[2][i] = math.log10(np.float(linelist[4])) + * i+=1 # <<<<<<<<<<<<<< + * return emat + * + */ + __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_i, __pyx_int_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_v_i); + __pyx_v_i = __pyx_t_3; + __pyx_t_3 = 0; + } + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + + /* "trioToolsNew/hmmUtils.pyx":87 + * emat[2][i] = math.log10(np.float(linelist[4])) + * i+=1 + * return emat # <<<<<<<<<<<<<< + * + * #quartet case + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_emat); + __pyx_r = __pyx_v_emat; + goto __pyx_L0; + goto __pyx_L3; + } + + /* "trioToolsNew/hmmUtils.pyx":90 + * + * #quartet case + * elif sub_ped == "q": # <<<<<<<<<<<<<< + * efile = open(path, "r") + * trash = efile.readline() + */ + __pyx_t_5 = PyObject_RichCompare(__pyx_v_sub_ped, ((PyObject *)__pyx_n_s__q), Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_2) { + + /* "trioToolsNew/hmmUtils.pyx":91 + * #quartet case + * elif sub_ped == "q": + * efile = open(path, "r") # <<<<<<<<<<<<<< + * trash = efile.readline() + * + */ + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_INCREF(__pyx_v_path); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_path); + __Pyx_GIVEREF(__pyx_v_path); + __Pyx_INCREF(((PyObject *)__pyx_n_s__r)); + PyTuple_SET_ITEM(__pyx_t_5, 1, ((PyObject *)__pyx_n_s__r)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__r)); + __pyx_t_3 = PyObject_Call(__pyx_builtin_open, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + __pyx_v_efile = __pyx_t_3; + __pyx_t_3 = 0; + + /* "trioToolsNew/hmmUtils.pyx":92 + * elif sub_ped == "q": + * efile = open(path, "r") + * trash = efile.readline() # <<<<<<<<<<<<<< + * + * emat = np.zeros([6, 81], np.float) + */ + __pyx_t_3 = PyObject_GetAttr(__pyx_v_efile, __pyx_n_s__readline); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_trash = __pyx_t_5; + __pyx_t_5 = 0; + + /* "trioToolsNew/hmmUtils.pyx":94 + * trash = efile.readline() + * + * emat = np.zeros([6, 81], np.float) # <<<<<<<<<<<<<< + * + * #alleles are in father, mother, child, child order + */ + __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyList_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_INCREF(__pyx_int_6); + PyList_SET_ITEM(__pyx_t_5, 0, __pyx_int_6); + __Pyx_GIVEREF(__pyx_int_6); + __Pyx_INCREF(__pyx_int_81); + PyList_SET_ITEM(__pyx_t_5, 1, __pyx_int_81); + __Pyx_GIVEREF(__pyx_int_81); + __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_1 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__float); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_5)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_5)); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_5 = 0; + __pyx_t_1 = 0; + __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __pyx_v_emat = __pyx_t_1; + __pyx_t_1 = 0; + + /* "trioToolsNew/hmmUtils.pyx":98 + * #alleles are in father, mother, child, child order + * #there are 52 allele assortments consistent with MIEs and one uniformly heterozygous position indicating possible compressions + * erprobHI = np.float(err)/np.float(65) # <<<<<<<<<<<<<< + * erprobID = np.float(err)/np.float(66) + * goodprobID = (1-np.float(err))/np.float(16) + */ + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__float); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_v_err); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_err); + __Pyx_GIVEREF(__pyx_v_err); + __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__float); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_k_tuple_16), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_PyNumber_Divide(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_erprobHI = __pyx_t_4; + __pyx_t_4 = 0; + + /* "trioToolsNew/hmmUtils.pyx":99 + * #there are 52 allele assortments consistent with MIEs and one uniformly heterozygous position indicating possible compressions + * erprobHI = np.float(err)/np.float(65) + * erprobID = np.float(err)/np.float(66) # <<<<<<<<<<<<<< + * goodprobID = (1-np.float(err))/np.float(16) + * goodprobHI = (1-np.float(err))/np.float(15) + */ + __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_1 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__float); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(__pyx_v_err); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_err); + __Pyx_GIVEREF(__pyx_v_err); + __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_1 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__float); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_17), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyNumber_Divide(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_v_erprobID = __pyx_t_1; + __pyx_t_1 = 0; + + /* "trioToolsNew/hmmUtils.pyx":100 + * erprobHI = np.float(err)/np.float(65) + * erprobID = np.float(err)/np.float(66) + * goodprobID = (1-np.float(err))/np.float(16) # <<<<<<<<<<<<<< + * goodprobHI = (1-np.float(err))/np.float(15) + * + */ + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__float); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_v_err); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_err); + __Pyx_GIVEREF(__pyx_v_err); + __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_1 = PyNumber_Subtract(__pyx_int_1, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__float); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_k_tuple_18), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_PyNumber_Divide(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_goodprobID = __pyx_t_4; + __pyx_t_4 = 0; + + /* "trioToolsNew/hmmUtils.pyx":101 + * erprobID = np.float(err)/np.float(66) + * goodprobID = (1-np.float(err))/np.float(16) + * goodprobHI = (1-np.float(err))/np.float(15) # <<<<<<<<<<<<<< + * + * erprobC = (1-np.float(comp))/np.float(80) + */ + __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__float); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(__pyx_v_err); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_err); + __Pyx_GIVEREF(__pyx_v_err); + __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __pyx_t_4 = PyNumber_Subtract(__pyx_int_1, __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__float); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_k_tuple_19), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyNumber_Divide(__pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_goodprobHI = __pyx_t_3; + __pyx_t_3 = 0; + + /* "trioToolsNew/hmmUtils.pyx":103 + * goodprobHI = (1-np.float(err))/np.float(15) + * + * erprobC = (1-np.float(comp))/np.float(80) # <<<<<<<<<<<<<< + * + * erprobM = (1-np.float(mie))/np.float(29) + */ + __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__float); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_v_comp); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_comp); + __Pyx_GIVEREF(__pyx_v_comp); + __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_t_3 = PyNumber_Subtract(__pyx_int_1, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_1 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__float); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_20), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyNumber_Divide(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_v_erprobC = __pyx_t_1; + __pyx_t_1 = 0; + + /* "trioToolsNew/hmmUtils.pyx":105 + * erprobC = (1-np.float(comp))/np.float(80) + * + * erprobM = (1-np.float(mie))/np.float(29) # <<<<<<<<<<<<<< + * + * mieprob = np.float(mie)/np.float(52) + */ + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__float); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_v_mie); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_mie); + __Pyx_GIVEREF(__pyx_v_mie); + __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_1 = PyNumber_Subtract(__pyx_int_1, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__float); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_k_tuple_21), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_PyNumber_Divide(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_erprobM = __pyx_t_4; + __pyx_t_4 = 0; + + /* "trioToolsNew/hmmUtils.pyx":107 + * erprobM = (1-np.float(mie))/np.float(29) + * + * mieprob = np.float(mie)/np.float(52) # <<<<<<<<<<<<<< + * + * i = 0 + */ + __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__float); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(__pyx_v_mie); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_mie); + __Pyx_GIVEREF(__pyx_v_mie); + __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__float); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_k_tuple_22), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyNumber_Divide(__pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_v_mieprob = __pyx_t_3; + __pyx_t_3 = 0; + + /* "trioToolsNew/hmmUtils.pyx":109 + * mieprob = np.float(mie)/np.float(52) + * + * i = 0 # <<<<<<<<<<<<<< + * #0 is MIErich, 1 is compression, 2 is good data + * for line in efile.readlines(): + */ + __Pyx_INCREF(__pyx_int_0); + __pyx_v_i = __pyx_int_0; + + /* "trioToolsNew/hmmUtils.pyx":111 + * i = 0 + * #0 is MIErich, 1 is compression, 2 is good data + * for line in efile.readlines(): # <<<<<<<<<<<<<< + * linelist = line.replace("erprobM", str(erprobM)).replace("erprobHI", str(erprobHI)).replace("erprobID", str(erprobID)).replace("goodprobHI", str(goodprobHI)).replace("goodprobID", str(goodprobID)).replace("comprob", str(comp)).replace("erprobC", str(erprobC)).replace("mieprob", str(mieprob)).split("\t") + * emat[0][i] = math.log10(np.float(linelist[2])) + */ + __pyx_t_3 = PyObject_GetAttr(__pyx_v_efile, __pyx_n_s__readlines); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (PyList_CheckExact(__pyx_t_4) || PyTuple_CheckExact(__pyx_t_4)) { + __pyx_t_3 = __pyx_t_4; __Pyx_INCREF(__pyx_t_3); __pyx_t_6 = 0; + __pyx_t_7 = NULL; + } else { + __pyx_t_6 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_7 = Py_TYPE(__pyx_t_3)->tp_iternext; + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + for (;;) { + if (!__pyx_t_7 && PyList_CheckExact(__pyx_t_3)) { + if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_3)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_4 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_4); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + } else if (!__pyx_t_7 && PyTuple_CheckExact(__pyx_t_3)) { + if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_3)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_4); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + } else { + __pyx_t_4 = __pyx_t_7(__pyx_t_3); + if (unlikely(!__pyx_t_4)) { + if (PyErr_Occurred()) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); + else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + break; + } + __Pyx_GOTREF(__pyx_t_4); + } + __Pyx_XDECREF(__pyx_v_line); + __pyx_v_line = __pyx_t_4; + __pyx_t_4 = 0; + + /* "trioToolsNew/hmmUtils.pyx":112 + * #0 is MIErich, 1 is compression, 2 is good data + * for line in efile.readlines(): + * linelist = line.replace("erprobM", str(erprobM)).replace("erprobHI", str(erprobHI)).replace("erprobID", str(erprobID)).replace("goodprobHI", str(goodprobHI)).replace("goodprobID", str(goodprobID)).replace("comprob", str(comp)).replace("erprobC", str(erprobC)).replace("mieprob", str(mieprob)).split("\t") # <<<<<<<<<<<<<< + * emat[0][i] = math.log10(np.float(linelist[2])) + * emat[1][i] = math.log10(np.float(linelist[3])) + */ + __pyx_t_4 = PyObject_GetAttr(__pyx_v_line, __pyx_n_s__replace); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_v_erprobM); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_erprobM); + __Pyx_GIVEREF(__pyx_v_erprobM); + __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)__pyx_n_s__erprobM)); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__erprobM)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__erprobM)); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + __pyx_t_5 = 0; + __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_1 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__replace); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_INCREF(__pyx_v_erprobHI); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_erprobHI); + __Pyx_GIVEREF(__pyx_v_erprobHI); + __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_INCREF(((PyObject *)__pyx_n_s__erprobHI)); + PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_n_s__erprobHI)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__erprobHI)); + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__replace); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(__pyx_v_erprobID); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_erprobID); + __Pyx_GIVEREF(__pyx_v_erprobID); + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(((PyObject *)__pyx_n_s__erprobID)); + PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_n_s__erprobID)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__erprobID)); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_1 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__replace); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_v_goodprobHI); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_goodprobHI); + __Pyx_GIVEREF(__pyx_v_goodprobHI); + __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)__pyx_n_s__goodprobHI)); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__goodprobHI)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__goodprobHI)); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + __pyx_t_5 = 0; + __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_1 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__replace); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_INCREF(__pyx_v_goodprobID); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_goodprobID); + __Pyx_GIVEREF(__pyx_v_goodprobID); + __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_INCREF(((PyObject *)__pyx_n_s__goodprobID)); + PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_n_s__goodprobID)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__goodprobID)); + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__replace); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(__pyx_v_comp); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_comp); + __Pyx_GIVEREF(__pyx_v_comp); + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(((PyObject *)__pyx_n_s__comprob)); + PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_n_s__comprob)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__comprob)); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_1 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__replace); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_v_erprobC); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_erprobC); + __Pyx_GIVEREF(__pyx_v_erprobC); + __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)__pyx_n_s__erprobC)); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__erprobC)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__erprobC)); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + __pyx_t_5 = 0; + __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_1 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__replace); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_INCREF(__pyx_v_mieprob); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_mieprob); + __Pyx_GIVEREF(__pyx_v_mieprob); + __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_INCREF(((PyObject *)__pyx_n_s__mieprob)); + PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_n_s__mieprob)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__mieprob)); + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__split); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_k_tuple_23), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_XDECREF(__pyx_v_linelist); + __pyx_v_linelist = __pyx_t_4; + __pyx_t_4 = 0; + + /* "trioToolsNew/hmmUtils.pyx":113 + * for line in efile.readlines(): + * linelist = line.replace("erprobM", str(erprobM)).replace("erprobHI", str(erprobHI)).replace("erprobID", str(erprobID)).replace("goodprobHI", str(goodprobHI)).replace("goodprobID", str(goodprobID)).replace("comprob", str(comp)).replace("erprobC", str(erprobC)).replace("mieprob", str(mieprob)).split("\t") + * emat[0][i] = math.log10(np.float(linelist[2])) # <<<<<<<<<<<<<< + * emat[1][i] = math.log10(np.float(linelist[3])) + * emat[2][i] = math.log10(np.float(linelist[4])) + */ + __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__math); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__log10); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_1 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__float); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_linelist, 2, sizeof(long), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0; + __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_4 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0; + __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_emat, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + if (PyObject_SetItem(__pyx_t_8, __pyx_v_i, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + + /* "trioToolsNew/hmmUtils.pyx":114 + * linelist = line.replace("erprobM", str(erprobM)).replace("erprobHI", str(erprobHI)).replace("erprobID", str(erprobID)).replace("goodprobHI", str(goodprobHI)).replace("goodprobID", str(goodprobID)).replace("comprob", str(comp)).replace("erprobC", str(erprobC)).replace("mieprob", str(mieprob)).split("\t") + * emat[0][i] = math.log10(np.float(linelist[2])) + * emat[1][i] = math.log10(np.float(linelist[3])) # <<<<<<<<<<<<<< + * emat[2][i] = math.log10(np.float(linelist[4])) + * emat[3][i] = math.log10(np.float(linelist[5])) + */ + __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__math); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_8 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__log10); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__float); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_linelist, 3, sizeof(long), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_4 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_4 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_emat, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (PyObject_SetItem(__pyx_t_1, __pyx_v_i, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + + /* "trioToolsNew/hmmUtils.pyx":115 + * emat[0][i] = math.log10(np.float(linelist[2])) + * emat[1][i] = math.log10(np.float(linelist[3])) + * emat[2][i] = math.log10(np.float(linelist[4])) # <<<<<<<<<<<<<< + * emat[3][i] = math.log10(np.float(linelist[5])) + * emat[4][i] = math.log10(np.float(linelist[6])) + */ + __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__math); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_1 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__log10); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_8 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__float); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_linelist, 4, sizeof(long), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_4 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_emat, 2, sizeof(long), PyInt_FromLong); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + if (PyObject_SetItem(__pyx_t_5, __pyx_v_i, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + + /* "trioToolsNew/hmmUtils.pyx":116 + * emat[1][i] = math.log10(np.float(linelist[3])) + * emat[2][i] = math.log10(np.float(linelist[4])) + * emat[3][i] = math.log10(np.float(linelist[5])) # <<<<<<<<<<<<<< + * emat[4][i] = math.log10(np.float(linelist[6])) + * emat[5][i] = math.log10(np.float(linelist[7])) + */ + __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__math); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__log10); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_1 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__float); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_linelist, 5, sizeof(long), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0; + __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_4 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0; + __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_emat, 3, sizeof(long), PyInt_FromLong); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + if (PyObject_SetItem(__pyx_t_8, __pyx_v_i, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + + /* "trioToolsNew/hmmUtils.pyx":117 + * emat[2][i] = math.log10(np.float(linelist[4])) + * emat[3][i] = math.log10(np.float(linelist[5])) + * emat[4][i] = math.log10(np.float(linelist[6])) # <<<<<<<<<<<<<< + * emat[5][i] = math.log10(np.float(linelist[7])) + * i+=1 + */ + __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__math); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_8 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__log10); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__float); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_linelist, 6, sizeof(long), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_4 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_4 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_emat, 4, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (PyObject_SetItem(__pyx_t_1, __pyx_v_i, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + + /* "trioToolsNew/hmmUtils.pyx":118 + * emat[3][i] = math.log10(np.float(linelist[5])) + * emat[4][i] = math.log10(np.float(linelist[6])) + * emat[5][i] = math.log10(np.float(linelist[7])) # <<<<<<<<<<<<<< + * i+=1 + * return emat + */ + __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__math); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_1 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__log10); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_8 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__float); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_linelist, 7, sizeof(long), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_4 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_emat, 5, sizeof(long), PyInt_FromLong); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + if (PyObject_SetItem(__pyx_t_5, __pyx_v_i, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + + /* "trioToolsNew/hmmUtils.pyx":119 + * emat[4][i] = math.log10(np.float(linelist[6])) + * emat[5][i] = math.log10(np.float(linelist[7])) + * i+=1 # <<<<<<<<<<<<<< + * return emat + * + */ + __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_i, __pyx_int_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_v_i); + __pyx_v_i = __pyx_t_4; + __pyx_t_4 = 0; + } + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "trioToolsNew/hmmUtils.pyx":120 + * emat[5][i] = math.log10(np.float(linelist[7])) + * i+=1 + * return emat # <<<<<<<<<<<<<< + * + * else: + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_emat); + __pyx_r = __pyx_v_emat; + goto __pyx_L0; + goto __pyx_L3; + } + /*else*/ { + + /* "trioToolsNew/hmmUtils.pyx":123 + * + * else: + * print >> sys.stderr, "Error in hmmUtils.load_emission: Unknown sub-pedigree format: "+sub_ped # <<<<<<<<<<<<<< + * exit(1) + * + */ + __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__sys); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__stderr); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyNumber_Add(((PyObject *)__pyx_kp_s_24), __pyx_v_sub_ped); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + if (__Pyx_PrintOne(__pyx_t_4, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + + /* "trioToolsNew/hmmUtils.pyx":124 + * else: + * print >> sys.stderr, "Error in hmmUtils.load_emission: Unknown sub-pedigree format: "+sub_ped + * exit(1) # <<<<<<<<<<<<<< + * + * #creates array of observations + */ + __pyx_t_4 = PyObject_Call(__pyx_builtin_exit, ((PyObject *)__pyx_k_tuple_25), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } + __pyx_L3:; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_AddTraceback("trioToolsNew.hmmUtils.load_emission", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_emat); + __Pyx_XDECREF(__pyx_v_efile); + __Pyx_XDECREF(__pyx_v_trash); + __Pyx_XDECREF(__pyx_v_erprobG); + __Pyx_XDECREF(__pyx_v_goodprob); + __Pyx_XDECREF(__pyx_v_erprobC); + __Pyx_XDECREF(__pyx_v_erprobM); + __Pyx_XDECREF(__pyx_v_mieprob); + __Pyx_XDECREF(__pyx_v_i); + __Pyx_XDECREF(__pyx_v_line); + __Pyx_XDECREF(__pyx_v_linelist); + __Pyx_XDECREF(__pyx_v_erprobHI); + __Pyx_XDECREF(__pyx_v_erprobID); + __Pyx_XDECREF(__pyx_v_goodprobID); + __Pyx_XDECREF(__pyx_v_goodprobHI); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_12trioToolsNew_8hmmUtils_5makeobs_set(PyObject *__pyx_self, PyObject *__pyx_v_numsubj); /*proto*/ +static PyMethodDef __pyx_mdef_12trioToolsNew_8hmmUtils_5makeobs_set = {__Pyx_NAMESTR("makeobs_set"), (PyCFunction)__pyx_pw_12trioToolsNew_8hmmUtils_5makeobs_set, METH_O, __Pyx_DOCSTR(0)}; +static PyObject *__pyx_pw_12trioToolsNew_8hmmUtils_5makeobs_set(PyObject *__pyx_self, PyObject *__pyx_v_numsubj) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("makeobs_set (wrapper)", 0); + __pyx_r = __pyx_pf_12trioToolsNew_8hmmUtils_4makeobs_set(__pyx_self, ((PyObject *)__pyx_v_numsubj)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "trioToolsNew/hmmUtils.pyx":127 + * + * #creates array of observations + * def makeobs_set(numsubj): # <<<<<<<<<<<<<< + * obs = [] + * n_assort = 3**numsubj + */ + +static PyObject *__pyx_pf_12trioToolsNew_8hmmUtils_4makeobs_set(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_numsubj) { + PyObject *__pyx_v_obs = NULL; + PyObject *__pyx_v_n_assort = NULL; + PyObject *__pyx_v_i = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + Py_ssize_t __pyx_t_3; + PyObject *(*__pyx_t_4)(PyObject *); + int __pyx_t_5; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("makeobs_set", 0); + + /* "trioToolsNew/hmmUtils.pyx":128 + * #creates array of observations + * def makeobs_set(numsubj): + * obs = [] # <<<<<<<<<<<<<< + * n_assort = 3**numsubj + * for i in range(0, n_assort): + */ + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_obs = __pyx_t_1; + __pyx_t_1 = 0; + + /* "trioToolsNew/hmmUtils.pyx":129 + * def makeobs_set(numsubj): + * obs = [] + * n_assort = 3**numsubj # <<<<<<<<<<<<<< + * for i in range(0, n_assort): + * obs.append(i) + */ + __pyx_t_1 = PyNumber_Power(__pyx_int_3, __pyx_v_numsubj, Py_None); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_n_assort = __pyx_t_1; + __pyx_t_1 = 0; + + /* "trioToolsNew/hmmUtils.pyx":130 + * obs = [] + * n_assort = 3**numsubj + * for i in range(0, n_assort): # <<<<<<<<<<<<<< + * obs.append(i) + * return obs + */ + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_int_0); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_int_0); + __Pyx_GIVEREF(__pyx_int_0); + __Pyx_INCREF(__pyx_v_n_assort); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_n_assort); + __Pyx_GIVEREF(__pyx_v_n_assort); + __pyx_t_2 = PyObject_Call(__pyx_builtin_range, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) { + __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0; + __pyx_t_4 = NULL; + } else { + __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext; + } + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + for (;;) { + if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_1)) { + if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_1)) { + if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + } else { + __pyx_t_2 = __pyx_t_4(__pyx_t_1); + if (unlikely(!__pyx_t_2)) { + if (PyErr_Occurred()) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); + else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + break; + } + __Pyx_GOTREF(__pyx_t_2); + } + __Pyx_XDECREF(__pyx_v_i); + __pyx_v_i = __pyx_t_2; + __pyx_t_2 = 0; + + /* "trioToolsNew/hmmUtils.pyx":131 + * n_assort = 3**numsubj + * for i in range(0, n_assort): + * obs.append(i) # <<<<<<<<<<<<<< + * return obs + * + */ + __pyx_t_5 = PyList_Append(__pyx_v_obs, __pyx_v_i); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "trioToolsNew/hmmUtils.pyx":132 + * for i in range(0, n_assort): + * obs.append(i) + * return obs # <<<<<<<<<<<<<< + * + * #returns map of allele assortments to allele codes for hmm, allele order father, mother, child + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_obs)); + __pyx_r = ((PyObject *)__pyx_v_obs); + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("trioToolsNew.hmmUtils.makeobs_set", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_obs); + __Pyx_XDECREF(__pyx_v_n_assort); + __Pyx_XDECREF(__pyx_v_i); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_12trioToolsNew_8hmmUtils_7input_map(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyMethodDef __pyx_mdef_12trioToolsNew_8hmmUtils_7input_map = {__Pyx_NAMESTR("input_map"), (PyCFunction)__pyx_pw_12trioToolsNew_8hmmUtils_7input_map, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}; +static PyObject *__pyx_pw_12trioToolsNew_8hmmUtils_7input_map(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_path_efile = 0; + PyObject *__pyx_v_sub_ped = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("input_map (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__path_efile,&__pyx_n_s__sub_ped,0}; + PyObject* values[2] = {0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__path_efile)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__sub_ped)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("input_map", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "input_map") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + } + __pyx_v_path_efile = values[0]; + __pyx_v_sub_ped = values[1]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("input_map", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("trioToolsNew.hmmUtils.input_map", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_12trioToolsNew_8hmmUtils_6input_map(__pyx_self, __pyx_v_path_efile, __pyx_v_sub_ped); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "trioToolsNew/hmmUtils.pyx":135 + * + * #returns map of allele assortments to allele codes for hmm, allele order father, mother, child + * def input_map(path_efile, sub_ped): # <<<<<<<<<<<<<< + * imap = {} + * + */ + +static PyObject *__pyx_pf_12trioToolsNew_8hmmUtils_6input_map(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_path_efile, PyObject *__pyx_v_sub_ped) { + PyObject *__pyx_v_imap = NULL; + PyObject *__pyx_v_tempin = NULL; + CYTHON_UNUSED PyObject *__pyx_v_trash = NULL; + PyObject *__pyx_v_line = NULL; + PyObject *__pyx_v_linelist = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + Py_ssize_t __pyx_t_4; + PyObject *(*__pyx_t_5)(PyObject *); + PyObject *__pyx_t_6 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("input_map", 0); + + /* "trioToolsNew/hmmUtils.pyx":136 + * #returns map of allele assortments to allele codes for hmm, allele order father, mother, child + * def input_map(path_efile, sub_ped): + * imap = {} # <<<<<<<<<<<<<< + * + * #trio case + */ + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_1)); + __pyx_v_imap = __pyx_t_1; + __pyx_t_1 = 0; + + /* "trioToolsNew/hmmUtils.pyx":139 + * + * #trio case + * if sub_ped == "t": # <<<<<<<<<<<<<< + * tempin = open(path_efile+"EmissionTrioGen.txt", "r") + * elif sub_ped == "q": + */ + __pyx_t_1 = PyObject_RichCompare(__pyx_v_sub_ped, ((PyObject *)__pyx_n_s__t), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (__pyx_t_2) { + + /* "trioToolsNew/hmmUtils.pyx":140 + * #trio case + * if sub_ped == "t": + * tempin = open(path_efile+"EmissionTrioGen.txt", "r") # <<<<<<<<<<<<<< + * elif sub_ped == "q": + * tempin = open(path_efile+"EmissionQuartetGen.txt", "r") + */ + __pyx_t_1 = PyNumber_Add(__pyx_v_path_efile, ((PyObject *)__pyx_kp_s_26)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)__pyx_n_s__r)); + PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_n_s__r)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__r)); + __pyx_t_1 = 0; + __pyx_t_1 = PyObject_Call(__pyx_builtin_open, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_v_tempin = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L3; + } + + /* "trioToolsNew/hmmUtils.pyx":141 + * if sub_ped == "t": + * tempin = open(path_efile+"EmissionTrioGen.txt", "r") + * elif sub_ped == "q": # <<<<<<<<<<<<<< + * tempin = open(path_efile+"EmissionQuartetGen.txt", "r") + * else: + */ + __pyx_t_1 = PyObject_RichCompare(__pyx_v_sub_ped, ((PyObject *)__pyx_n_s__q), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (__pyx_t_2) { + + /* "trioToolsNew/hmmUtils.pyx":142 + * tempin = open(path_efile+"EmissionTrioGen.txt", "r") + * elif sub_ped == "q": + * tempin = open(path_efile+"EmissionQuartetGen.txt", "r") # <<<<<<<<<<<<<< + * else: + * print >> sys.stderr, "Error in hmmUtils.input_map: Unknown sub-pedigree format: "+sub_ped + */ + __pyx_t_1 = PyNumber_Add(__pyx_v_path_efile, ((PyObject *)__pyx_kp_s_27)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)__pyx_n_s__r)); + PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_n_s__r)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__r)); + __pyx_t_1 = 0; + __pyx_t_1 = PyObject_Call(__pyx_builtin_open, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_v_tempin = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L3; + } + /*else*/ { + + /* "trioToolsNew/hmmUtils.pyx":144 + * tempin = open(path_efile+"EmissionQuartetGen.txt", "r") + * else: + * print >> sys.stderr, "Error in hmmUtils.input_map: Unknown sub-pedigree format: "+sub_ped # <<<<<<<<<<<<<< + * exit(1) + * + */ + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__sys); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__stderr); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyNumber_Add(((PyObject *)__pyx_kp_s_28), __pyx_v_sub_ped); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (__Pyx_PrintOne(__pyx_t_3, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "trioToolsNew/hmmUtils.pyx":145 + * else: + * print >> sys.stderr, "Error in hmmUtils.input_map: Unknown sub-pedigree format: "+sub_ped + * exit(1) # <<<<<<<<<<<<<< + * + * trash = tempin.readline() + */ + __pyx_t_3 = PyObject_Call(__pyx_builtin_exit, ((PyObject *)__pyx_k_tuple_29), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } + __pyx_L3:; + + /* "trioToolsNew/hmmUtils.pyx":147 + * exit(1) + * + * trash = tempin.readline() # <<<<<<<<<<<<<< + * for line in tempin.readlines(): + * linelist = line.split("\t") + */ + if (unlikely(!__pyx_v_tempin)) { __Pyx_RaiseUnboundLocalError("tempin"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } + __pyx_t_3 = PyObject_GetAttr(__pyx_v_tempin, __pyx_n_s__readline); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_trash = __pyx_t_1; + __pyx_t_1 = 0; + + /* "trioToolsNew/hmmUtils.pyx":148 + * + * trash = tempin.readline() + * for line in tempin.readlines(): # <<<<<<<<<<<<<< + * linelist = line.split("\t") + * imap[linelist[1]] = linelist[0] + */ + __pyx_t_1 = PyObject_GetAttr(__pyx_v_tempin, __pyx_n_s__readlines); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (PyList_CheckExact(__pyx_t_3) || PyTuple_CheckExact(__pyx_t_3)) { + __pyx_t_1 = __pyx_t_3; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0; + __pyx_t_5 = NULL; + } else { + __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_5 = Py_TYPE(__pyx_t_1)->tp_iternext; + } + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + for (;;) { + if (!__pyx_t_5 && PyList_CheckExact(__pyx_t_1)) { + if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + } else if (!__pyx_t_5 && PyTuple_CheckExact(__pyx_t_1)) { + if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + } else { + __pyx_t_3 = __pyx_t_5(__pyx_t_1); + if (unlikely(!__pyx_t_3)) { + if (PyErr_Occurred()) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); + else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + break; + } + __Pyx_GOTREF(__pyx_t_3); + } + __Pyx_XDECREF(__pyx_v_line); + __pyx_v_line = __pyx_t_3; + __pyx_t_3 = 0; + + /* "trioToolsNew/hmmUtils.pyx":149 + * trash = tempin.readline() + * for line in tempin.readlines(): + * linelist = line.split("\t") # <<<<<<<<<<<<<< + * imap[linelist[1]] = linelist[0] + * return imap + */ + __pyx_t_3 = PyObject_GetAttr(__pyx_v_line, __pyx_n_s__split); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_6 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_k_tuple_30), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_XDECREF(__pyx_v_linelist); + __pyx_v_linelist = __pyx_t_6; + __pyx_t_6 = 0; + + /* "trioToolsNew/hmmUtils.pyx":150 + * for line in tempin.readlines(): + * linelist = line.split("\t") + * imap[linelist[1]] = linelist[0] # <<<<<<<<<<<<<< + * return imap + * + */ + __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_linelist, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_linelist, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + if (PyDict_SetItem(((PyObject *)__pyx_v_imap), __pyx_t_3, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "trioToolsNew/hmmUtils.pyx":151 + * linelist = line.split("\t") + * imap[linelist[1]] = linelist[0] + * return imap # <<<<<<<<<<<<<< + * + * #creates and returns as a tuple emission, transition, start, state, and observation matrices + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_imap)); + __pyx_r = ((PyObject *)__pyx_v_imap); + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("trioToolsNew.hmmUtils.input_map", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_imap); + __Pyx_XDECREF(__pyx_v_tempin); + __Pyx_XDECREF(__pyx_v_trash); + __Pyx_XDECREF(__pyx_v_line); + __Pyx_XDECREF(__pyx_v_linelist); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_12trioToolsNew_8hmmUtils_9make_hmm(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyMethodDef __pyx_mdef_12trioToolsNew_8hmmUtils_9make_hmm = {__Pyx_NAMESTR("make_hmm"), (PyCFunction)__pyx_pw_12trioToolsNew_8hmmUtils_9make_hmm, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}; +static PyObject *__pyx_pw_12trioToolsNew_8hmmUtils_9make_hmm(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_mpath = 0; + PyObject *__pyx_v_sprob = 0; + PyObject *__pyx_v_comp = 0; + PyObject *__pyx_v_mprob = 0; + PyObject *__pyx_v_errprob = 0; + PyObject *__pyx_v_sub_ped = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("make_hmm (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__mpath,&__pyx_n_s__sprob,&__pyx_n_s__comp,&__pyx_n_s__mprob,&__pyx_n_s__errprob,&__pyx_n_s__sub_ped,0}; + PyObject* values[6] = {0,0,0,0,0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); + case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__mpath)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__sprob)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("make_hmm", 1, 6, 6, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__comp)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("make_hmm", 1, 6, 6, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 3: + if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__mprob)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("make_hmm", 1, 6, 6, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 4: + if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__errprob)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("make_hmm", 1, 6, 6, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 5: + if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__sub_ped)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("make_hmm", 1, 6, 6, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "make_hmm") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 6) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + values[5] = PyTuple_GET_ITEM(__pyx_args, 5); + } + __pyx_v_mpath = values[0]; + __pyx_v_sprob = values[1]; + __pyx_v_comp = values[2]; + __pyx_v_mprob = values[3]; + __pyx_v_errprob = values[4]; + __pyx_v_sub_ped = values[5]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("make_hmm", 1, 6, 6, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("trioToolsNew.hmmUtils.make_hmm", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_12trioToolsNew_8hmmUtils_8make_hmm(__pyx_self, __pyx_v_mpath, __pyx_v_sprob, __pyx_v_comp, __pyx_v_mprob, __pyx_v_errprob, __pyx_v_sub_ped); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "trioToolsNew/hmmUtils.pyx":154 + * + * #creates and returns as a tuple emission, transition, start, state, and observation matrices + * def make_hmm(mpath, sprob, comp, mprob, errprob, sub_ped): # <<<<<<<<<<<<<< + * if sub_ped == "t": + * #distribute non-self transition probability to non-self states + */ + +static PyObject *__pyx_pf_12trioToolsNew_8hmmUtils_8make_hmm(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_mpath, PyObject *__pyx_v_sprob, PyObject *__pyx_v_comp, PyObject *__pyx_v_mprob, PyObject *__pyx_v_errprob, PyObject *__pyx_v_sub_ped) { + PyObject *__pyx_v_nprob = NULL; + PyObject *__pyx_v_transmat = NULL; + PyObject *__pyx_v_emitmat = NULL; + PyObject *__pyx_v_startp = NULL; + PyObject *__pyx_v_states = NULL; + PyObject *__pyx_v_inmap = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + PyObject *__pyx_t_9 = NULL; + PyObject *__pyx_t_10 = NULL; + PyObject *__pyx_t_11 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("make_hmm", 0); + + /* "trioToolsNew/hmmUtils.pyx":155 + * #creates and returns as a tuple emission, transition, start, state, and observation matrices + * def make_hmm(mpath, sprob, comp, mprob, errprob, sub_ped): + * if sub_ped == "t": # <<<<<<<<<<<<<< + * #distribute non-self transition probability to non-self states + * nprob = (1-np.float(sprob))/np.float(2) + */ + __pyx_t_1 = PyObject_RichCompare(__pyx_v_sub_ped, ((PyObject *)__pyx_n_s__t), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (__pyx_t_2) { + + /* "trioToolsNew/hmmUtils.pyx":157 + * if sub_ped == "t": + * #distribute non-self transition probability to non-self states + * nprob = (1-np.float(sprob))/np.float(2) # <<<<<<<<<<<<<< + * + * #create matrices for HMM, all probabilities in log10 space to avoid underflow from np.floating point + */ + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__float); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_v_sprob); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_sprob); + __Pyx_GIVEREF(__pyx_v_sprob); + __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_1 = PyNumber_Subtract(__pyx_int_1, __pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__float); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_k_tuple_31), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyNumber_Divide(__pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_v_nprob = __pyx_t_3; + __pyx_t_3 = 0; + + /* "trioToolsNew/hmmUtils.pyx":160 + * + * #create matrices for HMM, all probabilities in log10 space to avoid underflow from np.floating point + * transmat = load_transition(mpath+"TransitionTrioGen.txt", sprob, nprob, "t") # <<<<<<<<<<<<<< + * emitmat = load_emission(mpath+"EmissionTrioGen.txt", comp, mprob, errprob, "t") + * startp = np.array([math.log10(np.float(1)/np.float(3)), math.log10(np.float(1)/np.float(3)), math.log10(np.float(1)/np.float(3))]) + */ + __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__load_transition); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyNumber_Add(__pyx_v_mpath, ((PyObject *)__pyx_kp_s_32)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + __Pyx_INCREF(__pyx_v_sprob); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_sprob); + __Pyx_GIVEREF(__pyx_v_sprob); + __Pyx_INCREF(__pyx_v_nprob); + PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_nprob); + __Pyx_GIVEREF(__pyx_v_nprob); + __Pyx_INCREF(((PyObject *)__pyx_n_s__t)); + PyTuple_SET_ITEM(__pyx_t_1, 3, ((PyObject *)__pyx_n_s__t)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__t)); + __pyx_t_4 = 0; + __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_v_transmat = __pyx_t_4; + __pyx_t_4 = 0; + + /* "trioToolsNew/hmmUtils.pyx":161 + * #create matrices for HMM, all probabilities in log10 space to avoid underflow from np.floating point + * transmat = load_transition(mpath+"TransitionTrioGen.txt", sprob, nprob, "t") + * emitmat = load_emission(mpath+"EmissionTrioGen.txt", comp, mprob, errprob, "t") # <<<<<<<<<<<<<< + * startp = np.array([math.log10(np.float(1)/np.float(3)), math.log10(np.float(1)/np.float(3)), math.log10(np.float(1)/np.float(3))]) + * states = np.array([0, 1, 2]) + */ + __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__load_emission); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_1 = PyNumber_Add(__pyx_v_mpath, ((PyObject *)__pyx_kp_s_26)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = PyTuple_New(5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_INCREF(__pyx_v_comp); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_comp); + __Pyx_GIVEREF(__pyx_v_comp); + __Pyx_INCREF(__pyx_v_mprob); + PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_mprob); + __Pyx_GIVEREF(__pyx_v_mprob); + __Pyx_INCREF(__pyx_v_errprob); + PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_v_errprob); + __Pyx_GIVEREF(__pyx_v_errprob); + __Pyx_INCREF(((PyObject *)__pyx_n_s__t)); + PyTuple_SET_ITEM(__pyx_t_3, 4, ((PyObject *)__pyx_n_s__t)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__t)); + __pyx_t_1 = 0; + __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_v_emitmat = __pyx_t_1; + __pyx_t_1 = 0; + + /* "trioToolsNew/hmmUtils.pyx":162 + * transmat = load_transition(mpath+"TransitionTrioGen.txt", sprob, nprob, "t") + * emitmat = load_emission(mpath+"EmissionTrioGen.txt", comp, mprob, errprob, "t") + * startp = np.array([math.log10(np.float(1)/np.float(3)), math.log10(np.float(1)/np.float(3)), math.log10(np.float(1)/np.float(3))]) # <<<<<<<<<<<<<< + * states = np.array([0, 1, 2]) + * inmap = input_map(mpath, "t") + */ + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__array); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__math); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__log10); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_5 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__float); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_k_tuple_33), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_6 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__float); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_k_tuple_34), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_6 = __Pyx_PyNumber_Divide(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); + __Pyx_GIVEREF(__pyx_t_6); + __pyx_t_6 = 0; + __pyx_t_6 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__math); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_4 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__log10); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_1 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__float); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_35), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_7 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__float); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_k_tuple_36), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_7 = __Pyx_PyNumber_Divide(__pyx_t_5, __pyx_t_1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_7); + __Pyx_GIVEREF(__pyx_t_7); + __pyx_t_7 = 0; + __pyx_t_7 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__math); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__log10); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_5 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__float); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_k_tuple_37), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_8 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__float); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_k_tuple_38), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_8 = __Pyx_PyNumber_Divide(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_8); + __Pyx_GIVEREF(__pyx_t_8); + __pyx_t_8 = 0; + __pyx_t_8 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + __pyx_t_5 = PyList_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + PyList_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); + __Pyx_GIVEREF(__pyx_t_6); + PyList_SET_ITEM(__pyx_t_5, 1, __pyx_t_7); + __Pyx_GIVEREF(__pyx_t_7); + PyList_SET_ITEM(__pyx_t_5, 2, __pyx_t_8); + __Pyx_GIVEREF(__pyx_t_8); + __pyx_t_6 = 0; + __pyx_t_7 = 0; + __pyx_t_8 = 0; + __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_t_5)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_5)); + __pyx_t_5 = 0; + __pyx_t_5 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0; + __pyx_v_startp = __pyx_t_5; + __pyx_t_5 = 0; + + /* "trioToolsNew/hmmUtils.pyx":163 + * emitmat = load_emission(mpath+"EmissionTrioGen.txt", comp, mprob, errprob, "t") + * startp = np.array([math.log10(np.float(1)/np.float(3)), math.log10(np.float(1)/np.float(3)), math.log10(np.float(1)/np.float(3))]) + * states = np.array([0, 1, 2]) # <<<<<<<<<<<<<< + * inmap = input_map(mpath, "t") + * + */ + __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_8 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__array); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyList_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_INCREF(__pyx_int_0); + PyList_SET_ITEM(__pyx_t_5, 0, __pyx_int_0); + __Pyx_GIVEREF(__pyx_int_0); + __Pyx_INCREF(__pyx_int_1); + PyList_SET_ITEM(__pyx_t_5, 1, __pyx_int_1); + __Pyx_GIVEREF(__pyx_int_1); + __Pyx_INCREF(__pyx_int_2); + PyList_SET_ITEM(__pyx_t_5, 2, __pyx_int_2); + __Pyx_GIVEREF(__pyx_int_2); + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_5)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_5)); + __pyx_t_5 = 0; + __pyx_t_5 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_v_states = __pyx_t_5; + __pyx_t_5 = 0; + + /* "trioToolsNew/hmmUtils.pyx":164 + * startp = np.array([math.log10(np.float(1)/np.float(3)), math.log10(np.float(1)/np.float(3)), math.log10(np.float(1)/np.float(3))]) + * states = np.array([0, 1, 2]) + * inmap = input_map(mpath, "t") # <<<<<<<<<<<<<< + * + * elif sub_ped == "q": + */ + __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__input_map); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_v_mpath); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_mpath); + __Pyx_GIVEREF(__pyx_v_mpath); + __Pyx_INCREF(((PyObject *)__pyx_n_s__t)); + PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_n_s__t)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__t)); + __pyx_t_8 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_v_inmap = __pyx_t_8; + __pyx_t_8 = 0; + goto __pyx_L3; + } + + /* "trioToolsNew/hmmUtils.pyx":166 + * inmap = input_map(mpath, "t") + * + * elif sub_ped == "q": # <<<<<<<<<<<<<< + * #distribute non-self transition probability to non-self states + * nprob = (1-np.float(sprob))/np.float(5) + */ + __pyx_t_8 = PyObject_RichCompare(__pyx_v_sub_ped, ((PyObject *)__pyx_n_s__q), Py_EQ); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + if (__pyx_t_2) { + + /* "trioToolsNew/hmmUtils.pyx":168 + * elif sub_ped == "q": + * #distribute non-self transition probability to non-self states + * nprob = (1-np.float(sprob))/np.float(5) # <<<<<<<<<<<<<< + * + * #create matrices for HMM, all probabilities in log10 space to avoid underflow from np.floating point + */ + __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_3 = PyObject_GetAttr(__pyx_t_8, __pyx_n_s__float); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_INCREF(__pyx_v_sprob); + PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_sprob); + __Pyx_GIVEREF(__pyx_v_sprob); + __pyx_t_5 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0; + __pyx_t_8 = PyNumber_Subtract(__pyx_int_1, __pyx_t_5); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__float); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_k_tuple_39), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyNumber_Divide(__pyx_t_8, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_v_nprob = __pyx_t_3; + __pyx_t_3 = 0; + + /* "trioToolsNew/hmmUtils.pyx":171 + * + * #create matrices for HMM, all probabilities in log10 space to avoid underflow from np.floating point + * transmat = load_transition(mpath+"TransitionQuartetGen.txt", sprob, nprob, "q") # <<<<<<<<<<<<<< + * emitmat = load_emission(mpath+"EmissionQuartetGen.txt", comp, mprob, errprob, "q") + * startp = np.array([math.log10(np.float(1)/np.float(6)), math.log10(np.float(1)/np.float(6)), math.log10(np.float(1)/np.float(6)), math.log10(np.float(1)/np.float(6)), math.log10(np.float(1)/np.float(6)), math.log10(np.float(1)/np.float(6))]) + */ + __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__load_transition); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyNumber_Add(__pyx_v_mpath, ((PyObject *)__pyx_kp_s_40)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_8 = PyTuple_New(4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + __Pyx_INCREF(__pyx_v_sprob); + PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_v_sprob); + __Pyx_GIVEREF(__pyx_v_sprob); + __Pyx_INCREF(__pyx_v_nprob); + PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_v_nprob); + __Pyx_GIVEREF(__pyx_v_nprob); + __Pyx_INCREF(((PyObject *)__pyx_n_s__q)); + PyTuple_SET_ITEM(__pyx_t_8, 3, ((PyObject *)__pyx_n_s__q)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__q)); + __pyx_t_5 = 0; + __pyx_t_5 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0; + __pyx_v_transmat = __pyx_t_5; + __pyx_t_5 = 0; + + /* "trioToolsNew/hmmUtils.pyx":172 + * #create matrices for HMM, all probabilities in log10 space to avoid underflow from np.floating point + * transmat = load_transition(mpath+"TransitionQuartetGen.txt", sprob, nprob, "q") + * emitmat = load_emission(mpath+"EmissionQuartetGen.txt", comp, mprob, errprob, "q") # <<<<<<<<<<<<<< + * startp = np.array([math.log10(np.float(1)/np.float(6)), math.log10(np.float(1)/np.float(6)), math.log10(np.float(1)/np.float(6)), math.log10(np.float(1)/np.float(6)), math.log10(np.float(1)/np.float(6)), math.log10(np.float(1)/np.float(6))]) + * states = np.array([0, 1, 2, 3, 4, 5]) + */ + __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__load_emission); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_8 = PyNumber_Add(__pyx_v_mpath, ((PyObject *)__pyx_kp_s_27)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_3 = PyTuple_New(5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_8); + __Pyx_GIVEREF(__pyx_t_8); + __Pyx_INCREF(__pyx_v_comp); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_comp); + __Pyx_GIVEREF(__pyx_v_comp); + __Pyx_INCREF(__pyx_v_mprob); + PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_mprob); + __Pyx_GIVEREF(__pyx_v_mprob); + __Pyx_INCREF(__pyx_v_errprob); + PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_v_errprob); + __Pyx_GIVEREF(__pyx_v_errprob); + __Pyx_INCREF(((PyObject *)__pyx_n_s__q)); + PyTuple_SET_ITEM(__pyx_t_3, 4, ((PyObject *)__pyx_n_s__q)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__q)); + __pyx_t_8 = 0; + __pyx_t_8 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_v_emitmat = __pyx_t_8; + __pyx_t_8 = 0; + + /* "trioToolsNew/hmmUtils.pyx":173 + * transmat = load_transition(mpath+"TransitionQuartetGen.txt", sprob, nprob, "q") + * emitmat = load_emission(mpath+"EmissionQuartetGen.txt", comp, mprob, errprob, "q") + * startp = np.array([math.log10(np.float(1)/np.float(6)), math.log10(np.float(1)/np.float(6)), math.log10(np.float(1)/np.float(6)), math.log10(np.float(1)/np.float(6)), math.log10(np.float(1)/np.float(6)), math.log10(np.float(1)/np.float(6))]) # <<<<<<<<<<<<<< + * states = np.array([0, 1, 2, 3, 4, 5]) + * inmap = input_map(mpath, "q") + */ + __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_3 = PyObject_GetAttr(__pyx_t_8, __pyx_n_s__array); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__math); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_5 = PyObject_GetAttr(__pyx_t_8, __pyx_n_s__log10); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_7 = PyObject_GetAttr(__pyx_t_8, __pyx_n_s__float); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_8 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_k_tuple_41), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_7 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_6 = PyObject_GetAttr(__pyx_t_7, __pyx_n_s__float); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_7 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_k_tuple_42), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_6 = __Pyx_PyNumber_Divide(__pyx_t_8, __pyx_t_7); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); + __Pyx_GIVEREF(__pyx_t_6); + __pyx_t_6 = 0; + __pyx_t_6 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0; + __pyx_t_7 = __Pyx_GetName(__pyx_m, __pyx_n_s__math); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_5 = PyObject_GetAttr(__pyx_t_7, __pyx_n_s__log10); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_7 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_8 = PyObject_GetAttr(__pyx_t_7, __pyx_n_s__float); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_7 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_k_tuple_43), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_4 = PyObject_GetAttr(__pyx_t_8, __pyx_n_s__float); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_8 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_k_tuple_44), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_PyNumber_Divide(__pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_4 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0; + __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__math); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_5 = PyObject_GetAttr(__pyx_t_8, __pyx_n_s__log10); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_7 = PyObject_GetAttr(__pyx_t_8, __pyx_n_s__float); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_8 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_k_tuple_45), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_7 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_1 = PyObject_GetAttr(__pyx_t_7, __pyx_n_s__float); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_7 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_46), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyNumber_Divide(__pyx_t_8, __pyx_t_7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_1 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0; + __pyx_t_7 = __Pyx_GetName(__pyx_m, __pyx_n_s__math); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_5 = PyObject_GetAttr(__pyx_t_7, __pyx_n_s__log10); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_7 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_8 = PyObject_GetAttr(__pyx_t_7, __pyx_n_s__float); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_7 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_k_tuple_47), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_9 = PyObject_GetAttr(__pyx_t_8, __pyx_n_s__float); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_8 = PyObject_Call(__pyx_t_9, ((PyObject *)__pyx_k_tuple_48), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_9 = __Pyx_PyNumber_Divide(__pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_9); + __Pyx_GIVEREF(__pyx_t_9); + __pyx_t_9 = 0; + __pyx_t_9 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0; + __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__math); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_5 = PyObject_GetAttr(__pyx_t_8, __pyx_n_s__log10); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_7 = PyObject_GetAttr(__pyx_t_8, __pyx_n_s__float); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_8 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_k_tuple_49), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_7 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_10 = PyObject_GetAttr(__pyx_t_7, __pyx_n_s__float); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_7 = PyObject_Call(__pyx_t_10, ((PyObject *)__pyx_k_tuple_50), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_10 = __Pyx_PyNumber_Divide(__pyx_t_8, __pyx_t_7); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_10); + __Pyx_GIVEREF(__pyx_t_10); + __pyx_t_10 = 0; + __pyx_t_10 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0; + __pyx_t_7 = __Pyx_GetName(__pyx_m, __pyx_n_s__math); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_5 = PyObject_GetAttr(__pyx_t_7, __pyx_n_s__log10); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_7 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_8 = PyObject_GetAttr(__pyx_t_7, __pyx_n_s__float); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_7 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_k_tuple_51), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_11 = PyObject_GetAttr(__pyx_t_8, __pyx_n_s__float); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_8 = PyObject_Call(__pyx_t_11, ((PyObject *)__pyx_k_tuple_52), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __pyx_t_11 = __Pyx_PyNumber_Divide(__pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_11); + __Pyx_GIVEREF(__pyx_t_11); + __pyx_t_11 = 0; + __pyx_t_11 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0; + __pyx_t_8 = PyList_New(6); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + PyList_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); + __Pyx_GIVEREF(__pyx_t_6); + PyList_SET_ITEM(__pyx_t_8, 1, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + PyList_SET_ITEM(__pyx_t_8, 2, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + PyList_SET_ITEM(__pyx_t_8, 3, __pyx_t_9); + __Pyx_GIVEREF(__pyx_t_9); + PyList_SET_ITEM(__pyx_t_8, 4, __pyx_t_10); + __Pyx_GIVEREF(__pyx_t_10); + PyList_SET_ITEM(__pyx_t_8, 5, __pyx_t_11); + __Pyx_GIVEREF(__pyx_t_11); + __pyx_t_6 = 0; + __pyx_t_4 = 0; + __pyx_t_1 = 0; + __pyx_t_9 = 0; + __pyx_t_10 = 0; + __pyx_t_11 = 0; + __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + PyTuple_SET_ITEM(__pyx_t_11, 0, ((PyObject *)__pyx_t_8)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_8)); + __pyx_t_8 = 0; + __pyx_t_8 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_11), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_11)); __pyx_t_11 = 0; + __pyx_v_startp = __pyx_t_8; + __pyx_t_8 = 0; + + /* "trioToolsNew/hmmUtils.pyx":174 + * emitmat = load_emission(mpath+"EmissionQuartetGen.txt", comp, mprob, errprob, "q") + * startp = np.array([math.log10(np.float(1)/np.float(6)), math.log10(np.float(1)/np.float(6)), math.log10(np.float(1)/np.float(6)), math.log10(np.float(1)/np.float(6)), math.log10(np.float(1)/np.float(6)), math.log10(np.float(1)/np.float(6))]) + * states = np.array([0, 1, 2, 3, 4, 5]) # <<<<<<<<<<<<<< + * inmap = input_map(mpath, "q") + * else: + */ + __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_11 = PyObject_GetAttr(__pyx_t_8, __pyx_n_s__array); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_8 = PyList_New(6); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_INCREF(__pyx_int_0); + PyList_SET_ITEM(__pyx_t_8, 0, __pyx_int_0); + __Pyx_GIVEREF(__pyx_int_0); + __Pyx_INCREF(__pyx_int_1); + PyList_SET_ITEM(__pyx_t_8, 1, __pyx_int_1); + __Pyx_GIVEREF(__pyx_int_1); + __Pyx_INCREF(__pyx_int_2); + PyList_SET_ITEM(__pyx_t_8, 2, __pyx_int_2); + __Pyx_GIVEREF(__pyx_int_2); + __Pyx_INCREF(__pyx_int_3); + PyList_SET_ITEM(__pyx_t_8, 3, __pyx_int_3); + __Pyx_GIVEREF(__pyx_int_3); + __Pyx_INCREF(__pyx_int_4); + PyList_SET_ITEM(__pyx_t_8, 4, __pyx_int_4); + __Pyx_GIVEREF(__pyx_int_4); + __Pyx_INCREF(__pyx_int_5); + PyList_SET_ITEM(__pyx_t_8, 5, __pyx_int_5); + __Pyx_GIVEREF(__pyx_int_5); + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_8)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_8)); + __pyx_t_8 = 0; + __pyx_t_8 = PyObject_Call(__pyx_t_11, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_v_states = __pyx_t_8; + __pyx_t_8 = 0; + + /* "trioToolsNew/hmmUtils.pyx":175 + * startp = np.array([math.log10(np.float(1)/np.float(6)), math.log10(np.float(1)/np.float(6)), math.log10(np.float(1)/np.float(6)), math.log10(np.float(1)/np.float(6)), math.log10(np.float(1)/np.float(6)), math.log10(np.float(1)/np.float(6))]) + * states = np.array([0, 1, 2, 3, 4, 5]) + * inmap = input_map(mpath, "q") # <<<<<<<<<<<<<< + * else: + * print >> sys.stderr, "Error in hmmUtils.make_hmm: Unknown sub-pedigree format: "+sub_ped + */ + __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__input_map); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_v_mpath); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_mpath); + __Pyx_GIVEREF(__pyx_v_mpath); + __Pyx_INCREF(((PyObject *)__pyx_n_s__q)); + PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_n_s__q)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__q)); + __pyx_t_11 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_v_inmap = __pyx_t_11; + __pyx_t_11 = 0; + goto __pyx_L3; + } + /*else*/ { + + /* "trioToolsNew/hmmUtils.pyx":177 + * inmap = input_map(mpath, "q") + * else: + * print >> sys.stderr, "Error in hmmUtils.make_hmm: Unknown sub-pedigree format: "+sub_ped # <<<<<<<<<<<<<< + * exit(1) + * return transmat, emitmat, startp, states, inmap + */ + __pyx_t_11 = __Pyx_GetName(__pyx_m, __pyx_n_s__sys); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __pyx_t_3 = PyObject_GetAttr(__pyx_t_11, __pyx_n_s__stderr); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __pyx_t_11 = PyNumber_Add(((PyObject *)__pyx_kp_s_53), __pyx_v_sub_ped); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + if (__Pyx_PrintOne(__pyx_t_3, __pyx_t_11) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "trioToolsNew/hmmUtils.pyx":178 + * else: + * print >> sys.stderr, "Error in hmmUtils.make_hmm: Unknown sub-pedigree format: "+sub_ped + * exit(1) # <<<<<<<<<<<<<< + * return transmat, emitmat, startp, states, inmap + * + */ + __pyx_t_3 = PyObject_Call(__pyx_builtin_exit, ((PyObject *)__pyx_k_tuple_54), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } + __pyx_L3:; + + /* "trioToolsNew/hmmUtils.pyx":179 + * print >> sys.stderr, "Error in hmmUtils.make_hmm: Unknown sub-pedigree format: "+sub_ped + * exit(1) + * return transmat, emitmat, startp, states, inmap # <<<<<<<<<<<<<< + * + * #uses sums of log-transformed probabilities to avoid np.floating point underflow problems + */ + __Pyx_XDECREF(__pyx_r); + if (unlikely(!__pyx_v_transmat)) { __Pyx_RaiseUnboundLocalError("transmat"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } + if (unlikely(!__pyx_v_emitmat)) { __Pyx_RaiseUnboundLocalError("emitmat"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } + if (unlikely(!__pyx_v_startp)) { __Pyx_RaiseUnboundLocalError("startp"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } + if (unlikely(!__pyx_v_states)) { __Pyx_RaiseUnboundLocalError("states"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } + if (unlikely(!__pyx_v_inmap)) { __Pyx_RaiseUnboundLocalError("inmap"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } + __pyx_t_3 = PyTuple_New(5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_v_transmat); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_transmat); + __Pyx_GIVEREF(__pyx_v_transmat); + __Pyx_INCREF(__pyx_v_emitmat); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_emitmat); + __Pyx_GIVEREF(__pyx_v_emitmat); + __Pyx_INCREF(__pyx_v_startp); + PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_startp); + __Pyx_GIVEREF(__pyx_v_startp); + __Pyx_INCREF(__pyx_v_states); + PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_v_states); + __Pyx_GIVEREF(__pyx_v_states); + __Pyx_INCREF(__pyx_v_inmap); + PyTuple_SET_ITEM(__pyx_t_3, 4, __pyx_v_inmap); + __Pyx_GIVEREF(__pyx_v_inmap); + __pyx_r = ((PyObject *)__pyx_t_3); + __pyx_t_3 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_XDECREF(__pyx_t_9); + __Pyx_XDECREF(__pyx_t_10); + __Pyx_XDECREF(__pyx_t_11); + __Pyx_AddTraceback("trioToolsNew.hmmUtils.make_hmm", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_nprob); + __Pyx_XDECREF(__pyx_v_transmat); + __Pyx_XDECREF(__pyx_v_emitmat); + __Pyx_XDECREF(__pyx_v_startp); + __Pyx_XDECREF(__pyx_v_states); + __Pyx_XDECREF(__pyx_v_inmap); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_12trioToolsNew_8hmmUtils_11viterbi(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyMethodDef __pyx_mdef_12trioToolsNew_8hmmUtils_11viterbi = {__Pyx_NAMESTR("viterbi"), (PyCFunction)__pyx_pw_12trioToolsNew_8hmmUtils_11viterbi, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}; +static PyObject *__pyx_pw_12trioToolsNew_8hmmUtils_11viterbi(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_obs = 0; + PyArrayObject *__pyx_v_states = 0; + PyArrayObject *__pyx_v_start_p = 0; + PyArrayObject *__pyx_v_trans_p = 0; + PyArrayObject *__pyx_v_emit_p = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("viterbi (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__obs,&__pyx_n_s__states,&__pyx_n_s__start_p,&__pyx_n_s__trans_p,&__pyx_n_s__emit_p,0}; + PyObject* values[5] = {0,0,0,0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__obs)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__states)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("viterbi", 1, 5, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__start_p)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("viterbi", 1, 5, 5, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 3: + if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__trans_p)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("viterbi", 1, 5, 5, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 4: + if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__emit_p)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("viterbi", 1, 5, 5, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "viterbi") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 5) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + } + __pyx_v_obs = ((PyArrayObject *)values[0]); + __pyx_v_states = ((PyArrayObject *)values[1]); + __pyx_v_start_p = ((PyArrayObject *)values[2]); + __pyx_v_trans_p = ((PyArrayObject *)values[3]); + __pyx_v_emit_p = ((PyArrayObject *)values[4]); + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("viterbi", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("trioToolsNew.hmmUtils.viterbi", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_obs), __pyx_ptype_5numpy_ndarray, 1, "obs", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_states), __pyx_ptype_5numpy_ndarray, 1, "states", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_start_p), __pyx_ptype_5numpy_ndarray, 1, "start_p", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_trans_p), __pyx_ptype_5numpy_ndarray, 1, "trans_p", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_emit_p), __pyx_ptype_5numpy_ndarray, 1, "emit_p", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_12trioToolsNew_8hmmUtils_10viterbi(__pyx_self, __pyx_v_obs, __pyx_v_states, __pyx_v_start_p, __pyx_v_trans_p, __pyx_v_emit_p); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "trioToolsNew/hmmUtils.pyx":182 + * + * #uses sums of log-transformed probabilities to avoid np.floating point underflow problems + * def viterbi(np.ndarray[DTYPEi_t] obs, np.ndarray[DTYPEi_t] states, np.ndarray[DTYPEf_t] start_p, np.ndarray[DTYPEf_t, ndim = 2] trans_p, np.ndarray[DTYPEf_t, ndim = 2] emit_p): # <<<<<<<<<<<<<< + * cdef int y, y0, t, state + * cdef double prob + */ + +static PyObject *__pyx_pf_12trioToolsNew_8hmmUtils_10viterbi(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_obs, PyArrayObject *__pyx_v_states, PyArrayObject *__pyx_v_start_p, PyArrayObject *__pyx_v_trans_p, PyArrayObject *__pyx_v_emit_p) { + int __pyx_v_y; + int __pyx_v_y0; + int __pyx_v_t; + int __pyx_v_state; + double __pyx_v_prob; + PyArrayObject *__pyx_v_V = 0; + PyArrayObject *__pyx_v_path = 0; + __Pyx_LocalBuf_ND __pyx_pybuffernd_V; + __Pyx_Buffer __pyx_pybuffer_V; + __Pyx_LocalBuf_ND __pyx_pybuffernd_emit_p; + __Pyx_Buffer __pyx_pybuffer_emit_p; + __Pyx_LocalBuf_ND __pyx_pybuffernd_obs; + __Pyx_Buffer __pyx_pybuffer_obs; + __Pyx_LocalBuf_ND __pyx_pybuffernd_path; + __Pyx_Buffer __pyx_pybuffer_path; + __Pyx_LocalBuf_ND __pyx_pybuffernd_start_p; + __Pyx_Buffer __pyx_pybuffer_start_p; + __Pyx_LocalBuf_ND __pyx_pybuffernd_states; + __Pyx_Buffer __pyx_pybuffer_states; + __Pyx_LocalBuf_ND __pyx_pybuffernd_trans_p; + __Pyx_Buffer __pyx_pybuffer_trans_p; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + Py_ssize_t __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyArrayObject *__pyx_t_6 = NULL; + PyArrayObject *__pyx_t_7 = NULL; + PyObject *(*__pyx_t_8)(PyObject *); + int __pyx_t_9; + int __pyx_t_10; + long __pyx_t_11; + PyObject *__pyx_t_12 = NULL; + __pyx_t_12trioToolsNew_8hmmUtils_DTYPEf_t __pyx_t_13; + long __pyx_t_14; + int __pyx_t_15; + long __pyx_t_16; + int __pyx_t_17; + Py_ssize_t __pyx_t_18; + int __pyx_t_19; + Py_ssize_t __pyx_t_20; + PyObject *(*__pyx_t_21)(PyObject *); + long __pyx_t_22; + int __pyx_t_23; + int __pyx_t_24; + int __pyx_t_25; + int __pyx_t_26; + __pyx_t_12trioToolsNew_8hmmUtils_DTYPEi_t __pyx_t_27; + int __pyx_t_28; + PyObject *__pyx_t_29 = NULL; + PyObject *(*__pyx_t_30)(PyObject *); + double __pyx_t_31; + int __pyx_t_32; + int __pyx_t_33; + int __pyx_t_34; + int __pyx_t_35; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("viterbi", 0); + __pyx_pybuffer_V.pybuffer.buf = NULL; + __pyx_pybuffer_V.refcount = 0; + __pyx_pybuffernd_V.data = NULL; + __pyx_pybuffernd_V.rcbuffer = &__pyx_pybuffer_V; + __pyx_pybuffer_path.pybuffer.buf = NULL; + __pyx_pybuffer_path.refcount = 0; + __pyx_pybuffernd_path.data = NULL; + __pyx_pybuffernd_path.rcbuffer = &__pyx_pybuffer_path; + __pyx_pybuffer_obs.pybuffer.buf = NULL; + __pyx_pybuffer_obs.refcount = 0; + __pyx_pybuffernd_obs.data = NULL; + __pyx_pybuffernd_obs.rcbuffer = &__pyx_pybuffer_obs; + __pyx_pybuffer_states.pybuffer.buf = NULL; + __pyx_pybuffer_states.refcount = 0; + __pyx_pybuffernd_states.data = NULL; + __pyx_pybuffernd_states.rcbuffer = &__pyx_pybuffer_states; + __pyx_pybuffer_start_p.pybuffer.buf = NULL; + __pyx_pybuffer_start_p.refcount = 0; + __pyx_pybuffernd_start_p.data = NULL; + __pyx_pybuffernd_start_p.rcbuffer = &__pyx_pybuffer_start_p; + __pyx_pybuffer_trans_p.pybuffer.buf = NULL; + __pyx_pybuffer_trans_p.refcount = 0; + __pyx_pybuffernd_trans_p.data = NULL; + __pyx_pybuffernd_trans_p.rcbuffer = &__pyx_pybuffer_trans_p; + __pyx_pybuffer_emit_p.pybuffer.buf = NULL; + __pyx_pybuffer_emit_p.refcount = 0; + __pyx_pybuffernd_emit_p.data = NULL; + __pyx_pybuffernd_emit_p.rcbuffer = &__pyx_pybuffer_emit_p; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_obs.rcbuffer->pybuffer, (PyObject*)__pyx_v_obs, &__Pyx_TypeInfo_nn___pyx_t_12trioToolsNew_8hmmUtils_DTYPEi_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_obs.diminfo[0].strides = __pyx_pybuffernd_obs.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_obs.diminfo[0].shape = __pyx_pybuffernd_obs.rcbuffer->pybuffer.shape[0]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_states.rcbuffer->pybuffer, (PyObject*)__pyx_v_states, &__Pyx_TypeInfo_nn___pyx_t_12trioToolsNew_8hmmUtils_DTYPEi_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_states.diminfo[0].strides = __pyx_pybuffernd_states.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_states.diminfo[0].shape = __pyx_pybuffernd_states.rcbuffer->pybuffer.shape[0]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_start_p.rcbuffer->pybuffer, (PyObject*)__pyx_v_start_p, &__Pyx_TypeInfo_nn___pyx_t_12trioToolsNew_8hmmUtils_DTYPEf_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_start_p.diminfo[0].strides = __pyx_pybuffernd_start_p.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_start_p.diminfo[0].shape = __pyx_pybuffernd_start_p.rcbuffer->pybuffer.shape[0]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_trans_p.rcbuffer->pybuffer, (PyObject*)__pyx_v_trans_p, &__Pyx_TypeInfo_nn___pyx_t_12trioToolsNew_8hmmUtils_DTYPEf_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_trans_p.diminfo[0].strides = __pyx_pybuffernd_trans_p.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_trans_p.diminfo[0].shape = __pyx_pybuffernd_trans_p.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_trans_p.diminfo[1].strides = __pyx_pybuffernd_trans_p.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_trans_p.diminfo[1].shape = __pyx_pybuffernd_trans_p.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_emit_p.rcbuffer->pybuffer, (PyObject*)__pyx_v_emit_p, &__Pyx_TypeInfo_nn___pyx_t_12trioToolsNew_8hmmUtils_DTYPEf_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_emit_p.diminfo[0].strides = __pyx_pybuffernd_emit_p.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_emit_p.diminfo[0].shape = __pyx_pybuffernd_emit_p.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_emit_p.diminfo[1].strides = __pyx_pybuffernd_emit_p.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_emit_p.diminfo[1].shape = __pyx_pybuffernd_emit_p.rcbuffer->pybuffer.shape[1]; + + /* "trioToolsNew/hmmUtils.pyx":185 + * cdef int y, y0, t, state + * cdef double prob + * cdef np.ndarray[DTYPEf_t, ndim = 2] V = np.zeros([len(obs), len(states)], np.float) # <<<<<<<<<<<<<< + * cdef np.ndarray[DTYPEi_t, ndim = 2] path = np.zeros([len(states), len(obs)], np.int) + * + */ + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__zeros); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_3 = PyObject_Length(((PyObject *)__pyx_v_obs)); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = PyObject_Length(((PyObject *)__pyx_v_states)); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = PyList_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + PyList_SET_ITEM(__pyx_t_5, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + PyList_SET_ITEM(__pyx_t_5, 1, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + __pyx_t_1 = 0; + __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_1 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__float); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_5)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_5)); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_5 = 0; + __pyx_t_1 = 0; + __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = ((PyArrayObject *)__pyx_t_1); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_V.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_12trioToolsNew_8hmmUtils_DTYPEf_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) { + __pyx_v_V = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_V.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_V.diminfo[0].strides = __pyx_pybuffernd_V.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_V.diminfo[0].shape = __pyx_pybuffernd_V.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_V.diminfo[1].strides = __pyx_pybuffernd_V.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_V.diminfo[1].shape = __pyx_pybuffernd_V.rcbuffer->pybuffer.shape[1]; + } + } + __pyx_t_6 = 0; + __pyx_v_V = ((PyArrayObject *)__pyx_t_1); + __pyx_t_1 = 0; + + /* "trioToolsNew/hmmUtils.pyx":186 + * cdef double prob + * cdef np.ndarray[DTYPEf_t, ndim = 2] V = np.zeros([len(obs), len(states)], np.float) + * cdef np.ndarray[DTYPEi_t, ndim = 2] path = np.zeros([len(states), len(obs)], np.int) # <<<<<<<<<<<<<< + * + * # Initialize base cases (t == 0) + */ + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__zeros); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_3 = PyObject_Length(((PyObject *)__pyx_v_states)); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = PyObject_Length(((PyObject *)__pyx_v_obs)); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_5 = PyList_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + PyList_SET_ITEM(__pyx_t_5, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + PyList_SET_ITEM(__pyx_t_5, 1, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_1 = 0; + __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__int); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_5)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_5)); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_5 = 0; + __pyx_t_1 = 0; + __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = ((PyArrayObject *)__pyx_t_1); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_path.rcbuffer->pybuffer, (PyObject*)__pyx_t_7, &__Pyx_TypeInfo_nn___pyx_t_12trioToolsNew_8hmmUtils_DTYPEi_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) { + __pyx_v_path = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_path.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_path.diminfo[0].strides = __pyx_pybuffernd_path.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_path.diminfo[0].shape = __pyx_pybuffernd_path.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_path.diminfo[1].strides = __pyx_pybuffernd_path.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_path.diminfo[1].shape = __pyx_pybuffernd_path.rcbuffer->pybuffer.shape[1]; + } + } + __pyx_t_7 = 0; + __pyx_v_path = ((PyArrayObject *)__pyx_t_1); + __pyx_t_1 = 0; + + /* "trioToolsNew/hmmUtils.pyx":189 + * + * # Initialize base cases (t == 0) + * for y in states: # <<<<<<<<<<<<<< + * V[0,y] = start_p[y] + emit_p[y,int(obs[0])] + * path[y,0] = y + */ + if (PyList_CheckExact(((PyObject *)__pyx_v_states)) || PyTuple_CheckExact(((PyObject *)__pyx_v_states))) { + __pyx_t_1 = ((PyObject *)__pyx_v_states); __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0; + __pyx_t_8 = NULL; + } else { + __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(((PyObject *)__pyx_v_states)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_8 = Py_TYPE(__pyx_t_1)->tp_iternext; + } + for (;;) { + if (!__pyx_t_8 && PyList_CheckExact(__pyx_t_1)) { + if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + } else if (!__pyx_t_8 && PyTuple_CheckExact(__pyx_t_1)) { + if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + } else { + __pyx_t_2 = __pyx_t_8(__pyx_t_1); + if (unlikely(!__pyx_t_2)) { + if (PyErr_Occurred()) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); + else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + break; + } + __Pyx_GOTREF(__pyx_t_2); + } + __pyx_t_9 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_v_y = __pyx_t_9; + + /* "trioToolsNew/hmmUtils.pyx":190 + * # Initialize base cases (t == 0) + * for y in states: + * V[0,y] = start_p[y] + emit_p[y,int(obs[0])] # <<<<<<<<<<<<<< + * path[y,0] = y + * + */ + __pyx_t_9 = __pyx_v_y; + __pyx_t_10 = -1; + if (__pyx_t_9 < 0) { + __pyx_t_9 += __pyx_pybuffernd_start_p.diminfo[0].shape; + if (unlikely(__pyx_t_9 < 0)) __pyx_t_10 = 0; + } else if (unlikely(__pyx_t_9 >= __pyx_pybuffernd_start_p.diminfo[0].shape)) __pyx_t_10 = 0; + if (unlikely(__pyx_t_10 != -1)) { + __Pyx_RaiseBufferIndexError(__pyx_t_10); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_2 = PyFloat_FromDouble((*__Pyx_BufPtrStrided1d(__pyx_t_12trioToolsNew_8hmmUtils_DTYPEf_t *, __pyx_pybuffernd_start_p.rcbuffer->pybuffer.buf, __pyx_t_9, __pyx_pybuffernd_start_p.diminfo[0].strides))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = PyInt_FromLong(__pyx_v_y); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_11 = 0; + __pyx_t_10 = -1; + if (__pyx_t_11 < 0) { + __pyx_t_11 += __pyx_pybuffernd_obs.diminfo[0].shape; + if (unlikely(__pyx_t_11 < 0)) __pyx_t_10 = 0; + } else if (unlikely(__pyx_t_11 >= __pyx_pybuffernd_obs.diminfo[0].shape)) __pyx_t_10 = 0; + if (unlikely(__pyx_t_10 != -1)) { + __Pyx_RaiseBufferIndexError(__pyx_t_10); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_5 = __Pyx_PyInt_to_py_npy_long((*__Pyx_BufPtrStrided1d(__pyx_t_12trioToolsNew_8hmmUtils_DTYPEi_t *, __pyx_pybuffernd_obs.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_obs.diminfo[0].strides))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + __pyx_t_5 = 0; + __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)(&PyInt_Type))), ((PyObject *)__pyx_t_12), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(((PyObject *)__pyx_t_12)); __pyx_t_12 = 0; + __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + __pyx_t_4 = 0; + __pyx_t_5 = 0; + __pyx_t_5 = PyObject_GetItem(((PyObject *)__pyx_v_emit_p), ((PyObject *)__pyx_t_12)); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(((PyObject *)__pyx_t_12)); __pyx_t_12 = 0; + __pyx_t_12 = PyNumber_Add(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_13 = __pyx_PyFloat_AsDouble(__pyx_t_12); if (unlikely((__pyx_t_13 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __pyx_t_14 = 0; + __pyx_t_10 = __pyx_v_y; + __pyx_t_15 = -1; + if (__pyx_t_14 < 0) { + __pyx_t_14 += __pyx_pybuffernd_V.diminfo[0].shape; + if (unlikely(__pyx_t_14 < 0)) __pyx_t_15 = 0; + } else if (unlikely(__pyx_t_14 >= __pyx_pybuffernd_V.diminfo[0].shape)) __pyx_t_15 = 0; + if (__pyx_t_10 < 0) { + __pyx_t_10 += __pyx_pybuffernd_V.diminfo[1].shape; + if (unlikely(__pyx_t_10 < 0)) __pyx_t_15 = 1; + } else if (unlikely(__pyx_t_10 >= __pyx_pybuffernd_V.diminfo[1].shape)) __pyx_t_15 = 1; + if (unlikely(__pyx_t_15 != -1)) { + __Pyx_RaiseBufferIndexError(__pyx_t_15); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + *__Pyx_BufPtrStrided2d(__pyx_t_12trioToolsNew_8hmmUtils_DTYPEf_t *, __pyx_pybuffernd_V.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_V.diminfo[0].strides, __pyx_t_10, __pyx_pybuffernd_V.diminfo[1].strides) = __pyx_t_13; + + /* "trioToolsNew/hmmUtils.pyx":191 + * for y in states: + * V[0,y] = start_p[y] + emit_p[y,int(obs[0])] + * path[y,0] = y # <<<<<<<<<<<<<< + * + * # Run Viterbi for t > 0 + */ + __pyx_t_15 = __pyx_v_y; + __pyx_t_16 = 0; + __pyx_t_17 = -1; + if (__pyx_t_15 < 0) { + __pyx_t_15 += __pyx_pybuffernd_path.diminfo[0].shape; + if (unlikely(__pyx_t_15 < 0)) __pyx_t_17 = 0; + } else if (unlikely(__pyx_t_15 >= __pyx_pybuffernd_path.diminfo[0].shape)) __pyx_t_17 = 0; + if (__pyx_t_16 < 0) { + __pyx_t_16 += __pyx_pybuffernd_path.diminfo[1].shape; + if (unlikely(__pyx_t_16 < 0)) __pyx_t_17 = 1; + } else if (unlikely(__pyx_t_16 >= __pyx_pybuffernd_path.diminfo[1].shape)) __pyx_t_17 = 1; + if (unlikely(__pyx_t_17 != -1)) { + __Pyx_RaiseBufferIndexError(__pyx_t_17); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + *__Pyx_BufPtrStrided2d(__pyx_t_12trioToolsNew_8hmmUtils_DTYPEi_t *, __pyx_pybuffernd_path.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_path.diminfo[0].strides, __pyx_t_16, __pyx_pybuffernd_path.diminfo[1].strides) = __pyx_v_y; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "trioToolsNew/hmmUtils.pyx":194 + * + * # Run Viterbi for t > 0 + * for t in range(1,len(obs)): # <<<<<<<<<<<<<< + * + * for y in states: + */ + __pyx_t_3 = PyObject_Length(((PyObject *)__pyx_v_obs)); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + for (__pyx_t_17 = 1; __pyx_t_17 < __pyx_t_3; __pyx_t_17+=1) { + __pyx_v_t = __pyx_t_17; + + /* "trioToolsNew/hmmUtils.pyx":196 + * for t in range(1,len(obs)): + * + * for y in states: # <<<<<<<<<<<<<< + * (prob, state) = max([(V[t-1,y0] + trans_p[y0,y] + emit_p[y,obs[t]], y0) for y0 in states]) + * V[t,y] = prob + */ + if (PyList_CheckExact(((PyObject *)__pyx_v_states)) || PyTuple_CheckExact(((PyObject *)__pyx_v_states))) { + __pyx_t_1 = ((PyObject *)__pyx_v_states); __Pyx_INCREF(__pyx_t_1); __pyx_t_18 = 0; + __pyx_t_8 = NULL; + } else { + __pyx_t_18 = -1; __pyx_t_1 = PyObject_GetIter(((PyObject *)__pyx_v_states)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_8 = Py_TYPE(__pyx_t_1)->tp_iternext; + } + for (;;) { + if (!__pyx_t_8 && PyList_CheckExact(__pyx_t_1)) { + if (__pyx_t_18 >= PyList_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_12 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_18); __Pyx_INCREF(__pyx_t_12); __pyx_t_18++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_12 = PySequence_ITEM(__pyx_t_1, __pyx_t_18); __pyx_t_18++; if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + } else if (!__pyx_t_8 && PyTuple_CheckExact(__pyx_t_1)) { + if (__pyx_t_18 >= PyTuple_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_12 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_18); __Pyx_INCREF(__pyx_t_12); __pyx_t_18++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_12 = PySequence_ITEM(__pyx_t_1, __pyx_t_18); __pyx_t_18++; if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + } else { + __pyx_t_12 = __pyx_t_8(__pyx_t_1); + if (unlikely(!__pyx_t_12)) { + if (PyErr_Occurred()) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); + else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + break; + } + __Pyx_GOTREF(__pyx_t_12); + } + __pyx_t_19 = __Pyx_PyInt_AsInt(__pyx_t_12); if (unlikely((__pyx_t_19 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __pyx_v_y = __pyx_t_19; + + /* "trioToolsNew/hmmUtils.pyx":197 + * + * for y in states: + * (prob, state) = max([(V[t-1,y0] + trans_p[y0,y] + emit_p[y,obs[t]], y0) for y0 in states]) # <<<<<<<<<<<<<< + * V[t,y] = prob + * path[y,0:t] = path[state,0:t] + */ + __pyx_t_12 = PyList_New(0); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + if (PyList_CheckExact(((PyObject *)__pyx_v_states)) || PyTuple_CheckExact(((PyObject *)__pyx_v_states))) { + __pyx_t_5 = ((PyObject *)__pyx_v_states); __Pyx_INCREF(__pyx_t_5); __pyx_t_20 = 0; + __pyx_t_21 = NULL; + } else { + __pyx_t_20 = -1; __pyx_t_5 = PyObject_GetIter(((PyObject *)__pyx_v_states)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_21 = Py_TYPE(__pyx_t_5)->tp_iternext; + } + for (;;) { + if (!__pyx_t_21 && PyList_CheckExact(__pyx_t_5)) { + if (__pyx_t_20 >= PyList_GET_SIZE(__pyx_t_5)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_2 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_20); __Pyx_INCREF(__pyx_t_2); __pyx_t_20++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_2 = PySequence_ITEM(__pyx_t_5, __pyx_t_20); __pyx_t_20++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + } else if (!__pyx_t_21 && PyTuple_CheckExact(__pyx_t_5)) { + if (__pyx_t_20 >= PyTuple_GET_SIZE(__pyx_t_5)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_20); __Pyx_INCREF(__pyx_t_2); __pyx_t_20++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_2 = PySequence_ITEM(__pyx_t_5, __pyx_t_20); __pyx_t_20++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + } else { + __pyx_t_2 = __pyx_t_21(__pyx_t_5); + if (unlikely(!__pyx_t_2)) { + if (PyErr_Occurred()) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); + else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + break; + } + __Pyx_GOTREF(__pyx_t_2); + } + __pyx_t_19 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_19 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_v_y0 = __pyx_t_19; + __pyx_t_22 = (__pyx_v_t - 1); + __pyx_t_19 = __pyx_v_y0; + __pyx_t_23 = -1; + if (__pyx_t_22 < 0) { + __pyx_t_22 += __pyx_pybuffernd_V.diminfo[0].shape; + if (unlikely(__pyx_t_22 < 0)) __pyx_t_23 = 0; + } else if (unlikely(__pyx_t_22 >= __pyx_pybuffernd_V.diminfo[0].shape)) __pyx_t_23 = 0; + if (__pyx_t_19 < 0) { + __pyx_t_19 += __pyx_pybuffernd_V.diminfo[1].shape; + if (unlikely(__pyx_t_19 < 0)) __pyx_t_23 = 1; + } else if (unlikely(__pyx_t_19 >= __pyx_pybuffernd_V.diminfo[1].shape)) __pyx_t_23 = 1; + if (unlikely(__pyx_t_23 != -1)) { + __Pyx_RaiseBufferIndexError(__pyx_t_23); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_23 = __pyx_v_y0; + __pyx_t_24 = __pyx_v_y; + __pyx_t_25 = -1; + if (__pyx_t_23 < 0) { + __pyx_t_23 += __pyx_pybuffernd_trans_p.diminfo[0].shape; + if (unlikely(__pyx_t_23 < 0)) __pyx_t_25 = 0; + } else if (unlikely(__pyx_t_23 >= __pyx_pybuffernd_trans_p.diminfo[0].shape)) __pyx_t_25 = 0; + if (__pyx_t_24 < 0) { + __pyx_t_24 += __pyx_pybuffernd_trans_p.diminfo[1].shape; + if (unlikely(__pyx_t_24 < 0)) __pyx_t_25 = 1; + } else if (unlikely(__pyx_t_24 >= __pyx_pybuffernd_trans_p.diminfo[1].shape)) __pyx_t_25 = 1; + if (unlikely(__pyx_t_25 != -1)) { + __Pyx_RaiseBufferIndexError(__pyx_t_25); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_25 = __pyx_v_t; + __pyx_t_26 = -1; + if (__pyx_t_25 < 0) { + __pyx_t_25 += __pyx_pybuffernd_obs.diminfo[0].shape; + if (unlikely(__pyx_t_25 < 0)) __pyx_t_26 = 0; + } else if (unlikely(__pyx_t_25 >= __pyx_pybuffernd_obs.diminfo[0].shape)) __pyx_t_26 = 0; + if (unlikely(__pyx_t_26 != -1)) { + __Pyx_RaiseBufferIndexError(__pyx_t_26); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_26 = __pyx_v_y; + __pyx_t_27 = (*__Pyx_BufPtrStrided1d(__pyx_t_12trioToolsNew_8hmmUtils_DTYPEi_t *, __pyx_pybuffernd_obs.rcbuffer->pybuffer.buf, __pyx_t_25, __pyx_pybuffernd_obs.diminfo[0].strides)); + __pyx_t_28 = -1; + if (__pyx_t_26 < 0) { + __pyx_t_26 += __pyx_pybuffernd_emit_p.diminfo[0].shape; + if (unlikely(__pyx_t_26 < 0)) __pyx_t_28 = 0; + } else if (unlikely(__pyx_t_26 >= __pyx_pybuffernd_emit_p.diminfo[0].shape)) __pyx_t_28 = 0; + if (__pyx_t_27 < 0) { + __pyx_t_27 += __pyx_pybuffernd_emit_p.diminfo[1].shape; + if (unlikely(__pyx_t_27 < 0)) __pyx_t_28 = 1; + } else if (unlikely(__pyx_t_27 >= __pyx_pybuffernd_emit_p.diminfo[1].shape)) __pyx_t_28 = 1; + if (unlikely(__pyx_t_28 != -1)) { + __Pyx_RaiseBufferIndexError(__pyx_t_28); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_2 = PyFloat_FromDouble((((*__Pyx_BufPtrStrided2d(__pyx_t_12trioToolsNew_8hmmUtils_DTYPEf_t *, __pyx_pybuffernd_V.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_V.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_V.diminfo[1].strides)) + (*__Pyx_BufPtrStrided2d(__pyx_t_12trioToolsNew_8hmmUtils_DTYPEf_t *, __pyx_pybuffernd_trans_p.rcbuffer->pybuffer.buf, __pyx_t_23, __pyx_pybuffernd_trans_p.diminfo[0].strides, __pyx_t_24, __pyx_pybuffernd_trans_p.diminfo[1].strides))) + (*__Pyx_BufPtrStrided2d(__pyx_t_12trioToolsNew_8hmmUtils_DTYPEf_t *, __pyx_pybuffernd_emit_p.rcbuffer->pybuffer.buf, __pyx_t_26, __pyx_pybuffernd_emit_p.diminfo[0].strides, __pyx_t_27, __pyx_pybuffernd_emit_p.diminfo[1].strides)))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = PyInt_FromLong(__pyx_v_y0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_29 = PyTuple_New(2); if (unlikely(!__pyx_t_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_29); + PyTuple_SET_ITEM(__pyx_t_29, 0, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_29, 1, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + __pyx_t_2 = 0; + __pyx_t_4 = 0; + if (unlikely(__Pyx_PyList_Append(__pyx_t_12, (PyObject*)__pyx_t_29))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(((PyObject *)__pyx_t_29)); __pyx_t_29 = 0; + } + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_INCREF(((PyObject *)__pyx_t_12)); + PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_12)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_12)); + __Pyx_DECREF(((PyObject *)__pyx_t_12)); __pyx_t_12 = 0; + __pyx_t_12 = PyObject_Call(__pyx_builtin_max, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + if ((likely(PyTuple_CheckExact(__pyx_t_12))) || (PyList_CheckExact(__pyx_t_12))) { + PyObject* sequence = __pyx_t_12; + #if CYTHON_COMPILING_IN_CPYTHON + Py_ssize_t size = Py_SIZE(sequence); + #else + Py_ssize_t size = PySequence_Size(sequence); + #endif + if (unlikely(size != 2)) { + if (size > 2) __Pyx_RaiseTooManyValuesError(2); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + #if CYTHON_COMPILING_IN_CPYTHON + if (likely(PyTuple_CheckExact(sequence))) { + __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_29 = PyTuple_GET_ITEM(sequence, 1); + } else { + __pyx_t_5 = PyList_GET_ITEM(sequence, 0); + __pyx_t_29 = PyList_GET_ITEM(sequence, 1); + } + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(__pyx_t_29); + #else + __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_29 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + } else + { + Py_ssize_t index = -1; + __pyx_t_4 = PyObject_GetIter(__pyx_t_12); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __pyx_t_30 = Py_TYPE(__pyx_t_4)->tp_iternext; + index = 0; __pyx_t_5 = __pyx_t_30(__pyx_t_4); if (unlikely(!__pyx_t_5)) goto __pyx_L11_unpacking_failed; + __Pyx_GOTREF(__pyx_t_5); + index = 1; __pyx_t_29 = __pyx_t_30(__pyx_t_4); if (unlikely(!__pyx_t_29)) goto __pyx_L11_unpacking_failed; + __Pyx_GOTREF(__pyx_t_29); + if (__Pyx_IternextUnpackEndCheck(__pyx_t_30(__pyx_t_4), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_30 = NULL; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + goto __pyx_L12_unpacking_done; + __pyx_L11_unpacking_failed:; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_30 = NULL; + if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_L12_unpacking_done:; + } + __pyx_t_31 = __pyx_PyFloat_AsDouble(__pyx_t_5); if (unlikely((__pyx_t_31 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_28 = __Pyx_PyInt_AsInt(__pyx_t_29); if (unlikely((__pyx_t_28 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0; + __pyx_v_prob = __pyx_t_31; + __pyx_v_state = __pyx_t_28; + + /* "trioToolsNew/hmmUtils.pyx":198 + * for y in states: + * (prob, state) = max([(V[t-1,y0] + trans_p[y0,y] + emit_p[y,obs[t]], y0) for y0 in states]) + * V[t,y] = prob # <<<<<<<<<<<<<< + * path[y,0:t] = path[state,0:t] + * path[y,t] = y + */ + __pyx_t_28 = __pyx_v_t; + __pyx_t_32 = __pyx_v_y; + __pyx_t_33 = -1; + if (__pyx_t_28 < 0) { + __pyx_t_28 += __pyx_pybuffernd_V.diminfo[0].shape; + if (unlikely(__pyx_t_28 < 0)) __pyx_t_33 = 0; + } else if (unlikely(__pyx_t_28 >= __pyx_pybuffernd_V.diminfo[0].shape)) __pyx_t_33 = 0; + if (__pyx_t_32 < 0) { + __pyx_t_32 += __pyx_pybuffernd_V.diminfo[1].shape; + if (unlikely(__pyx_t_32 < 0)) __pyx_t_33 = 1; + } else if (unlikely(__pyx_t_32 >= __pyx_pybuffernd_V.diminfo[1].shape)) __pyx_t_33 = 1; + if (unlikely(__pyx_t_33 != -1)) { + __Pyx_RaiseBufferIndexError(__pyx_t_33); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + *__Pyx_BufPtrStrided2d(__pyx_t_12trioToolsNew_8hmmUtils_DTYPEf_t *, __pyx_pybuffernd_V.rcbuffer->pybuffer.buf, __pyx_t_28, __pyx_pybuffernd_V.diminfo[0].strides, __pyx_t_32, __pyx_pybuffernd_V.diminfo[1].strides) = __pyx_v_prob; + + /* "trioToolsNew/hmmUtils.pyx":199 + * (prob, state) = max([(V[t-1,y0] + trans_p[y0,y] + emit_p[y,obs[t]], y0) for y0 in states]) + * V[t,y] = prob + * path[y,0:t] = path[state,0:t] # <<<<<<<<<<<<<< + * path[y,t] = y + * + */ + __pyx_t_12 = PyInt_FromLong(__pyx_v_state); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_29 = PyInt_FromLong(__pyx_v_t); if (unlikely(!__pyx_t_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_29); + __pyx_t_5 = PySlice_New(__pyx_int_0, __pyx_t_29, Py_None); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0; + __pyx_t_29 = PyTuple_New(2); if (unlikely(!__pyx_t_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_29); + PyTuple_SET_ITEM(__pyx_t_29, 0, __pyx_t_12); + __Pyx_GIVEREF(__pyx_t_12); + PyTuple_SET_ITEM(__pyx_t_29, 1, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + __pyx_t_12 = 0; + __pyx_t_5 = 0; + __pyx_t_5 = PyObject_GetItem(((PyObject *)__pyx_v_path), ((PyObject *)__pyx_t_29)); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(((PyObject *)__pyx_t_29)); __pyx_t_29 = 0; + __pyx_t_29 = PyInt_FromLong(__pyx_v_y); if (unlikely(!__pyx_t_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_29); + __pyx_t_12 = PyInt_FromLong(__pyx_v_t); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_4 = PySlice_New(__pyx_int_0, __pyx_t_12, Py_None); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_29); + __Pyx_GIVEREF(__pyx_t_29); + PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + __pyx_t_29 = 0; + __pyx_t_4 = 0; + if (PyObject_SetItem(((PyObject *)__pyx_v_path), ((PyObject *)__pyx_t_12), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(((PyObject *)__pyx_t_12)); __pyx_t_12 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + + /* "trioToolsNew/hmmUtils.pyx":200 + * V[t,y] = prob + * path[y,0:t] = path[state,0:t] + * path[y,t] = y # <<<<<<<<<<<<<< + * + * (prob, state) = max([(V[len(obs) - 1,y], y) for y in states]) + */ + __pyx_t_33 = __pyx_v_y; + __pyx_t_34 = __pyx_v_t; + __pyx_t_35 = -1; + if (__pyx_t_33 < 0) { + __pyx_t_33 += __pyx_pybuffernd_path.diminfo[0].shape; + if (unlikely(__pyx_t_33 < 0)) __pyx_t_35 = 0; + } else if (unlikely(__pyx_t_33 >= __pyx_pybuffernd_path.diminfo[0].shape)) __pyx_t_35 = 0; + if (__pyx_t_34 < 0) { + __pyx_t_34 += __pyx_pybuffernd_path.diminfo[1].shape; + if (unlikely(__pyx_t_34 < 0)) __pyx_t_35 = 1; + } else if (unlikely(__pyx_t_34 >= __pyx_pybuffernd_path.diminfo[1].shape)) __pyx_t_35 = 1; + if (unlikely(__pyx_t_35 != -1)) { + __Pyx_RaiseBufferIndexError(__pyx_t_35); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + *__Pyx_BufPtrStrided2d(__pyx_t_12trioToolsNew_8hmmUtils_DTYPEi_t *, __pyx_pybuffernd_path.rcbuffer->pybuffer.buf, __pyx_t_33, __pyx_pybuffernd_path.diminfo[0].strides, __pyx_t_34, __pyx_pybuffernd_path.diminfo[1].strides) = __pyx_v_y; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "trioToolsNew/hmmUtils.pyx":202 + * path[y,t] = y + * + * (prob, state) = max([(V[len(obs) - 1,y], y) for y in states]) # <<<<<<<<<<<<<< + * return (prob, path[state]) + */ + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (PyList_CheckExact(((PyObject *)__pyx_v_states)) || PyTuple_CheckExact(((PyObject *)__pyx_v_states))) { + __pyx_t_5 = ((PyObject *)__pyx_v_states); __Pyx_INCREF(__pyx_t_5); __pyx_t_3 = 0; + __pyx_t_8 = NULL; + } else { + __pyx_t_3 = -1; __pyx_t_5 = PyObject_GetIter(((PyObject *)__pyx_v_states)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_8 = Py_TYPE(__pyx_t_5)->tp_iternext; + } + for (;;) { + if (!__pyx_t_8 && PyList_CheckExact(__pyx_t_5)) { + if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_5)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_12 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_3); __Pyx_INCREF(__pyx_t_12); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_12 = PySequence_ITEM(__pyx_t_5, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + } else if (!__pyx_t_8 && PyTuple_CheckExact(__pyx_t_5)) { + if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_5)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_12 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_3); __Pyx_INCREF(__pyx_t_12); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_12 = PySequence_ITEM(__pyx_t_5, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + } else { + __pyx_t_12 = __pyx_t_8(__pyx_t_5); + if (unlikely(!__pyx_t_12)) { + if (PyErr_Occurred()) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); + else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + break; + } + __Pyx_GOTREF(__pyx_t_12); + } + __pyx_t_17 = __Pyx_PyInt_AsInt(__pyx_t_12); if (unlikely((__pyx_t_17 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __pyx_v_y = __pyx_t_17; + __pyx_t_18 = PyObject_Length(((PyObject *)__pyx_v_obs)); if (unlikely(__pyx_t_18 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_20 = (__pyx_t_18 - 1); + __pyx_t_17 = __pyx_v_y; + __pyx_t_35 = -1; + if (__pyx_t_20 < 0) { + __pyx_t_20 += __pyx_pybuffernd_V.diminfo[0].shape; + if (unlikely(__pyx_t_20 < 0)) __pyx_t_35 = 0; + } else if (unlikely(__pyx_t_20 >= __pyx_pybuffernd_V.diminfo[0].shape)) __pyx_t_35 = 0; + if (__pyx_t_17 < 0) { + __pyx_t_17 += __pyx_pybuffernd_V.diminfo[1].shape; + if (unlikely(__pyx_t_17 < 0)) __pyx_t_35 = 1; + } else if (unlikely(__pyx_t_17 >= __pyx_pybuffernd_V.diminfo[1].shape)) __pyx_t_35 = 1; + if (unlikely(__pyx_t_35 != -1)) { + __Pyx_RaiseBufferIndexError(__pyx_t_35); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_12 = PyFloat_FromDouble((*__Pyx_BufPtrStrided2d(__pyx_t_12trioToolsNew_8hmmUtils_DTYPEf_t *, __pyx_pybuffernd_V.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_V.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_V.diminfo[1].strides))); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_4 = PyInt_FromLong(__pyx_v_y); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_29 = PyTuple_New(2); if (unlikely(!__pyx_t_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_29); + PyTuple_SET_ITEM(__pyx_t_29, 0, __pyx_t_12); + __Pyx_GIVEREF(__pyx_t_12); + PyTuple_SET_ITEM(__pyx_t_29, 1, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + __pyx_t_12 = 0; + __pyx_t_4 = 0; + if (unlikely(__Pyx_PyList_Append(__pyx_t_1, (PyObject*)__pyx_t_29))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(((PyObject *)__pyx_t_29)); __pyx_t_29 = 0; + } + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_INCREF(((PyObject *)__pyx_t_1)); + PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_1)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_1 = PyObject_Call(__pyx_builtin_max, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) { + PyObject* sequence = __pyx_t_1; + #if CYTHON_COMPILING_IN_CPYTHON + Py_ssize_t size = Py_SIZE(sequence); + #else + Py_ssize_t size = PySequence_Size(sequence); + #endif + if (unlikely(size != 2)) { + if (size > 2) __Pyx_RaiseTooManyValuesError(2); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + #if CYTHON_COMPILING_IN_CPYTHON + if (likely(PyTuple_CheckExact(sequence))) { + __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_29 = PyTuple_GET_ITEM(sequence, 1); + } else { + __pyx_t_5 = PyList_GET_ITEM(sequence, 0); + __pyx_t_29 = PyList_GET_ITEM(sequence, 1); + } + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(__pyx_t_29); + #else + __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_29 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } else + { + Py_ssize_t index = -1; + __pyx_t_4 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_30 = Py_TYPE(__pyx_t_4)->tp_iternext; + index = 0; __pyx_t_5 = __pyx_t_30(__pyx_t_4); if (unlikely(!__pyx_t_5)) goto __pyx_L15_unpacking_failed; + __Pyx_GOTREF(__pyx_t_5); + index = 1; __pyx_t_29 = __pyx_t_30(__pyx_t_4); if (unlikely(!__pyx_t_29)) goto __pyx_L15_unpacking_failed; + __Pyx_GOTREF(__pyx_t_29); + if (__Pyx_IternextUnpackEndCheck(__pyx_t_30(__pyx_t_4), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_30 = NULL; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + goto __pyx_L16_unpacking_done; + __pyx_L15_unpacking_failed:; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_30 = NULL; + if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_L16_unpacking_done:; + } + __pyx_t_31 = __pyx_PyFloat_AsDouble(__pyx_t_5); if (unlikely((__pyx_t_31 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_35 = __Pyx_PyInt_AsInt(__pyx_t_29); if (unlikely((__pyx_t_35 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0; + __pyx_v_prob = __pyx_t_31; + __pyx_v_state = __pyx_t_35; + + /* "trioToolsNew/hmmUtils.pyx":203 + * + * (prob, state) = max([(V[len(obs) - 1,y], y) for y in states]) + * return (prob, path[state]) # <<<<<<<<<<<<<< + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyFloat_FromDouble(__pyx_v_prob); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_29 = __Pyx_GetItemInt(((PyObject *)__pyx_v_path), __pyx_v_state, sizeof(int), PyInt_FromLong); if (!__pyx_t_29) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_29); + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_29); + __Pyx_GIVEREF(__pyx_t_29); + __pyx_t_1 = 0; + __pyx_t_29 = 0; + __pyx_r = ((PyObject *)__pyx_t_5); + __pyx_t_5 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_12); + __Pyx_XDECREF(__pyx_t_29); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_V.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_emit_p.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_obs.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_path.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_start_p.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_states.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_trans_p.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("trioToolsNew.hmmUtils.viterbi", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_V.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_emit_p.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_obs.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_path.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_start_p.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_states.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_trans_p.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XDECREF((PyObject *)__pyx_v_V); + __Pyx_XDECREF((PyObject *)__pyx_v_path); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/ +static int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0); + __pyx_r = __pyx_pf_5numpy_7ndarray___getbuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "numpy.pxd":194 + * # experimental exception made for __getbuffer__ and __releasebuffer__ + * # -- the details of this may change. + * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< + * # This implementation of getbuffer is geared towards Cython + * # requirements, and does not yet fullfill the PEP. + */ + +static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { + int __pyx_v_copy_shape; + int __pyx_v_i; + int __pyx_v_ndim; + int __pyx_v_endian_detector; + int __pyx_v_little_endian; + int __pyx_v_t; + char *__pyx_v_f; + PyArray_Descr *__pyx_v_descr = 0; + int __pyx_v_offset; + int __pyx_v_hasfields; + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + int __pyx_t_5; + int __pyx_t_6; + int __pyx_t_7; + PyObject *__pyx_t_8 = NULL; + char *__pyx_t_9; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__getbuffer__", 0); + if (__pyx_v_info != NULL) { + __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(__pyx_v_info->obj); + } + + /* "numpy.pxd":200 + * # of flags + * + * if info == NULL: return # <<<<<<<<<<<<<< + * + * cdef int copy_shape, i, ndim + */ + __pyx_t_1 = (__pyx_v_info == NULL); + if (__pyx_t_1) { + __pyx_r = 0; + goto __pyx_L0; + goto __pyx_L3; + } + __pyx_L3:; + + /* "numpy.pxd":203 + * + * cdef int copy_shape, i, ndim + * cdef int endian_detector = 1 # <<<<<<<<<<<<<< + * cdef bint little_endian = ((&endian_detector)[0] != 0) + * + */ + __pyx_v_endian_detector = 1; + + /* "numpy.pxd":204 + * cdef int copy_shape, i, ndim + * cdef int endian_detector = 1 + * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< + * + * ndim = PyArray_NDIM(self) + */ + __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); + + /* "numpy.pxd":206 + * cdef bint little_endian = ((&endian_detector)[0] != 0) + * + * ndim = PyArray_NDIM(self) # <<<<<<<<<<<<<< + * + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + */ + __pyx_v_ndim = PyArray_NDIM(__pyx_v_self); + + /* "numpy.pxd":208 + * ndim = PyArray_NDIM(self) + * + * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< + * copy_shape = 1 + * else: + */ + __pyx_t_1 = ((sizeof(npy_intp)) != (sizeof(Py_ssize_t))); + if (__pyx_t_1) { + + /* "numpy.pxd":209 + * + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + * copy_shape = 1 # <<<<<<<<<<<<<< + * else: + * copy_shape = 0 + */ + __pyx_v_copy_shape = 1; + goto __pyx_L4; + } + /*else*/ { + + /* "numpy.pxd":211 + * copy_shape = 1 + * else: + * copy_shape = 0 # <<<<<<<<<<<<<< + * + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) + */ + __pyx_v_copy_shape = 0; + } + __pyx_L4:; + + /* "numpy.pxd":213 + * copy_shape = 0 + * + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): + * raise ValueError(u"ndarray is not C contiguous") + */ + __pyx_t_1 = ((__pyx_v_flags & PyBUF_C_CONTIGUOUS) == PyBUF_C_CONTIGUOUS); + if (__pyx_t_1) { + + /* "numpy.pxd":214 + * + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): # <<<<<<<<<<<<<< + * raise ValueError(u"ndarray is not C contiguous") + * + */ + __pyx_t_2 = (!PyArray_CHKFLAGS(__pyx_v_self, NPY_C_CONTIGUOUS)); + __pyx_t_3 = __pyx_t_2; + } else { + __pyx_t_3 = __pyx_t_1; + } + if (__pyx_t_3) { + + /* "numpy.pxd":215 + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): + * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + */ + __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_56), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_Raise(__pyx_t_4, 0, 0, 0); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L5; + } + __pyx_L5:; + + /* "numpy.pxd":217 + * raise ValueError(u"ndarray is not C contiguous") + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): + * raise ValueError(u"ndarray is not Fortran contiguous") + */ + __pyx_t_3 = ((__pyx_v_flags & PyBUF_F_CONTIGUOUS) == PyBUF_F_CONTIGUOUS); + if (__pyx_t_3) { + + /* "numpy.pxd":218 + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): # <<<<<<<<<<<<<< + * raise ValueError(u"ndarray is not Fortran contiguous") + * + */ + __pyx_t_1 = (!PyArray_CHKFLAGS(__pyx_v_self, NPY_F_CONTIGUOUS)); + __pyx_t_2 = __pyx_t_1; + } else { + __pyx_t_2 = __pyx_t_3; + } + if (__pyx_t_2) { + + /* "numpy.pxd":219 + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): + * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< + * + * info.buf = PyArray_DATA(self) + */ + __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_58), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_Raise(__pyx_t_4, 0, 0, 0); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L6; + } + __pyx_L6:; + + /* "numpy.pxd":221 + * raise ValueError(u"ndarray is not Fortran contiguous") + * + * info.buf = PyArray_DATA(self) # <<<<<<<<<<<<<< + * info.ndim = ndim + * if copy_shape: + */ + __pyx_v_info->buf = PyArray_DATA(__pyx_v_self); + + /* "numpy.pxd":222 + * + * info.buf = PyArray_DATA(self) + * info.ndim = ndim # <<<<<<<<<<<<<< + * if copy_shape: + * # Allocate new buffer for strides and shape info. + */ + __pyx_v_info->ndim = __pyx_v_ndim; + + /* "numpy.pxd":223 + * info.buf = PyArray_DATA(self) + * info.ndim = ndim + * if copy_shape: # <<<<<<<<<<<<<< + * # Allocate new buffer for strides and shape info. + * # This is allocated as one block, strides first. + */ + if (__pyx_v_copy_shape) { + + /* "numpy.pxd":226 + * # Allocate new buffer for strides and shape info. + * # This is allocated as one block, strides first. + * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) # <<<<<<<<<<<<<< + * info.shape = info.strides + ndim + * for i in range(ndim): + */ + __pyx_v_info->strides = ((Py_ssize_t *)malloc((((sizeof(Py_ssize_t)) * ((size_t)__pyx_v_ndim)) * 2))); + + /* "numpy.pxd":227 + * # This is allocated as one block, strides first. + * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) + * info.shape = info.strides + ndim # <<<<<<<<<<<<<< + * for i in range(ndim): + * info.strides[i] = PyArray_STRIDES(self)[i] + */ + __pyx_v_info->shape = (__pyx_v_info->strides + __pyx_v_ndim); + + /* "numpy.pxd":228 + * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) + * info.shape = info.strides + ndim + * for i in range(ndim): # <<<<<<<<<<<<<< + * info.strides[i] = PyArray_STRIDES(self)[i] + * info.shape[i] = PyArray_DIMS(self)[i] + */ + __pyx_t_5 = __pyx_v_ndim; + for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { + __pyx_v_i = __pyx_t_6; + + /* "numpy.pxd":229 + * info.shape = info.strides + ndim + * for i in range(ndim): + * info.strides[i] = PyArray_STRIDES(self)[i] # <<<<<<<<<<<<<< + * info.shape[i] = PyArray_DIMS(self)[i] + * else: + */ + (__pyx_v_info->strides[__pyx_v_i]) = (PyArray_STRIDES(__pyx_v_self)[__pyx_v_i]); + + /* "numpy.pxd":230 + * for i in range(ndim): + * info.strides[i] = PyArray_STRIDES(self)[i] + * info.shape[i] = PyArray_DIMS(self)[i] # <<<<<<<<<<<<<< + * else: + * info.strides = PyArray_STRIDES(self) + */ + (__pyx_v_info->shape[__pyx_v_i]) = (PyArray_DIMS(__pyx_v_self)[__pyx_v_i]); + } + goto __pyx_L7; + } + /*else*/ { + + /* "numpy.pxd":232 + * info.shape[i] = PyArray_DIMS(self)[i] + * else: + * info.strides = PyArray_STRIDES(self) # <<<<<<<<<<<<<< + * info.shape = PyArray_DIMS(self) + * info.suboffsets = NULL + */ + __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(__pyx_v_self)); + + /* "numpy.pxd":233 + * else: + * info.strides = PyArray_STRIDES(self) + * info.shape = PyArray_DIMS(self) # <<<<<<<<<<<<<< + * info.suboffsets = NULL + * info.itemsize = PyArray_ITEMSIZE(self) + */ + __pyx_v_info->shape = ((Py_ssize_t *)PyArray_DIMS(__pyx_v_self)); + } + __pyx_L7:; + + /* "numpy.pxd":234 + * info.strides = PyArray_STRIDES(self) + * info.shape = PyArray_DIMS(self) + * info.suboffsets = NULL # <<<<<<<<<<<<<< + * info.itemsize = PyArray_ITEMSIZE(self) + * info.readonly = not PyArray_ISWRITEABLE(self) + */ + __pyx_v_info->suboffsets = NULL; + + /* "numpy.pxd":235 + * info.shape = PyArray_DIMS(self) + * info.suboffsets = NULL + * info.itemsize = PyArray_ITEMSIZE(self) # <<<<<<<<<<<<<< + * info.readonly = not PyArray_ISWRITEABLE(self) + * + */ + __pyx_v_info->itemsize = PyArray_ITEMSIZE(__pyx_v_self); + + /* "numpy.pxd":236 + * info.suboffsets = NULL + * info.itemsize = PyArray_ITEMSIZE(self) + * info.readonly = not PyArray_ISWRITEABLE(self) # <<<<<<<<<<<<<< + * + * cdef int t + */ + __pyx_v_info->readonly = (!PyArray_ISWRITEABLE(__pyx_v_self)); + + /* "numpy.pxd":239 + * + * cdef int t + * cdef char* f = NULL # <<<<<<<<<<<<<< + * cdef dtype descr = self.descr + * cdef list stack + */ + __pyx_v_f = NULL; + + /* "numpy.pxd":240 + * cdef int t + * cdef char* f = NULL + * cdef dtype descr = self.descr # <<<<<<<<<<<<<< + * cdef list stack + * cdef int offset + */ + __Pyx_INCREF(((PyObject *)__pyx_v_self->descr)); + __pyx_v_descr = __pyx_v_self->descr; + + /* "numpy.pxd":244 + * cdef int offset + * + * cdef bint hasfields = PyDataType_HASFIELDS(descr) # <<<<<<<<<<<<<< + * + * if not hasfields and not copy_shape: + */ + __pyx_v_hasfields = PyDataType_HASFIELDS(__pyx_v_descr); + + /* "numpy.pxd":246 + * cdef bint hasfields = PyDataType_HASFIELDS(descr) + * + * if not hasfields and not copy_shape: # <<<<<<<<<<<<<< + * # do not call releasebuffer + * info.obj = None + */ + __pyx_t_2 = (!__pyx_v_hasfields); + if (__pyx_t_2) { + __pyx_t_3 = (!__pyx_v_copy_shape); + __pyx_t_1 = __pyx_t_3; + } else { + __pyx_t_1 = __pyx_t_2; + } + if (__pyx_t_1) { + + /* "numpy.pxd":248 + * if not hasfields and not copy_shape: + * # do not call releasebuffer + * info.obj = None # <<<<<<<<<<<<<< + * else: + * # need to call releasebuffer + */ + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); + __pyx_v_info->obj = Py_None; + goto __pyx_L10; + } + /*else*/ { + + /* "numpy.pxd":251 + * else: + * # need to call releasebuffer + * info.obj = self # <<<<<<<<<<<<<< + * + * if not hasfields: + */ + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); + __pyx_v_info->obj = ((PyObject *)__pyx_v_self); + } + __pyx_L10:; + + /* "numpy.pxd":253 + * info.obj = self + * + * if not hasfields: # <<<<<<<<<<<<<< + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or + */ + __pyx_t_1 = (!__pyx_v_hasfields); + if (__pyx_t_1) { + + /* "numpy.pxd":254 + * + * if not hasfields: + * t = descr.type_num # <<<<<<<<<<<<<< + * if ((descr.byteorder == c'>' and little_endian) or + * (descr.byteorder == c'<' and not little_endian)): + */ + __pyx_v_t = __pyx_v_descr->type_num; + + /* "numpy.pxd":255 + * if not hasfields: + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") + */ + __pyx_t_1 = (__pyx_v_descr->byteorder == '>'); + if (__pyx_t_1) { + __pyx_t_2 = __pyx_v_little_endian; + } else { + __pyx_t_2 = __pyx_t_1; + } + if (!__pyx_t_2) { + + /* "numpy.pxd":256 + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or + * (descr.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< + * raise ValueError(u"Non-native byte order not supported") + * if t == NPY_BYTE: f = "b" + */ + __pyx_t_1 = (__pyx_v_descr->byteorder == '<'); + if (__pyx_t_1) { + __pyx_t_3 = (!__pyx_v_little_endian); + __pyx_t_7 = __pyx_t_3; + } else { + __pyx_t_7 = __pyx_t_1; + } + __pyx_t_1 = __pyx_t_7; + } else { + __pyx_t_1 = __pyx_t_2; + } + if (__pyx_t_1) { + + /* "numpy.pxd":257 + * if ((descr.byteorder == c'>' and little_endian) or + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< + * if t == NPY_BYTE: f = "b" + * elif t == NPY_UBYTE: f = "B" + */ + __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_60), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_Raise(__pyx_t_4, 0, 0, 0); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L12; + } + __pyx_L12:; + + /* "numpy.pxd":258 + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") + * if t == NPY_BYTE: f = "b" # <<<<<<<<<<<<<< + * elif t == NPY_UBYTE: f = "B" + * elif t == NPY_SHORT: f = "h" + */ + __pyx_t_1 = (__pyx_v_t == NPY_BYTE); + if (__pyx_t_1) { + __pyx_v_f = __pyx_k__b; + goto __pyx_L13; + } + + /* "numpy.pxd":259 + * raise ValueError(u"Non-native byte order not supported") + * if t == NPY_BYTE: f = "b" + * elif t == NPY_UBYTE: f = "B" # <<<<<<<<<<<<<< + * elif t == NPY_SHORT: f = "h" + * elif t == NPY_USHORT: f = "H" + */ + __pyx_t_1 = (__pyx_v_t == NPY_UBYTE); + if (__pyx_t_1) { + __pyx_v_f = __pyx_k__B; + goto __pyx_L13; + } + + /* "numpy.pxd":260 + * if t == NPY_BYTE: f = "b" + * elif t == NPY_UBYTE: f = "B" + * elif t == NPY_SHORT: f = "h" # <<<<<<<<<<<<<< + * elif t == NPY_USHORT: f = "H" + * elif t == NPY_INT: f = "i" + */ + __pyx_t_1 = (__pyx_v_t == NPY_SHORT); + if (__pyx_t_1) { + __pyx_v_f = __pyx_k__h; + goto __pyx_L13; + } + + /* "numpy.pxd":261 + * elif t == NPY_UBYTE: f = "B" + * elif t == NPY_SHORT: f = "h" + * elif t == NPY_USHORT: f = "H" # <<<<<<<<<<<<<< + * elif t == NPY_INT: f = "i" + * elif t == NPY_UINT: f = "I" + */ + __pyx_t_1 = (__pyx_v_t == NPY_USHORT); + if (__pyx_t_1) { + __pyx_v_f = __pyx_k__H; + goto __pyx_L13; + } + + /* "numpy.pxd":262 + * elif t == NPY_SHORT: f = "h" + * elif t == NPY_USHORT: f = "H" + * elif t == NPY_INT: f = "i" # <<<<<<<<<<<<<< + * elif t == NPY_UINT: f = "I" + * elif t == NPY_LONG: f = "l" + */ + __pyx_t_1 = (__pyx_v_t == NPY_INT); + if (__pyx_t_1) { + __pyx_v_f = __pyx_k__i; + goto __pyx_L13; + } + + /* "numpy.pxd":263 + * elif t == NPY_USHORT: f = "H" + * elif t == NPY_INT: f = "i" + * elif t == NPY_UINT: f = "I" # <<<<<<<<<<<<<< + * elif t == NPY_LONG: f = "l" + * elif t == NPY_ULONG: f = "L" + */ + __pyx_t_1 = (__pyx_v_t == NPY_UINT); + if (__pyx_t_1) { + __pyx_v_f = __pyx_k__I; + goto __pyx_L13; + } + + /* "numpy.pxd":264 + * elif t == NPY_INT: f = "i" + * elif t == NPY_UINT: f = "I" + * elif t == NPY_LONG: f = "l" # <<<<<<<<<<<<<< + * elif t == NPY_ULONG: f = "L" + * elif t == NPY_LONGLONG: f = "q" + */ + __pyx_t_1 = (__pyx_v_t == NPY_LONG); + if (__pyx_t_1) { + __pyx_v_f = __pyx_k__l; + goto __pyx_L13; + } + + /* "numpy.pxd":265 + * elif t == NPY_UINT: f = "I" + * elif t == NPY_LONG: f = "l" + * elif t == NPY_ULONG: f = "L" # <<<<<<<<<<<<<< + * elif t == NPY_LONGLONG: f = "q" + * elif t == NPY_ULONGLONG: f = "Q" + */ + __pyx_t_1 = (__pyx_v_t == NPY_ULONG); + if (__pyx_t_1) { + __pyx_v_f = __pyx_k__L; + goto __pyx_L13; + } + + /* "numpy.pxd":266 + * elif t == NPY_LONG: f = "l" + * elif t == NPY_ULONG: f = "L" + * elif t == NPY_LONGLONG: f = "q" # <<<<<<<<<<<<<< + * elif t == NPY_ULONGLONG: f = "Q" + * elif t == NPY_FLOAT: f = "f" + */ + __pyx_t_1 = (__pyx_v_t == NPY_LONGLONG); + if (__pyx_t_1) { + __pyx_v_f = __pyx_k__q; + goto __pyx_L13; + } + + /* "numpy.pxd":267 + * elif t == NPY_ULONG: f = "L" + * elif t == NPY_LONGLONG: f = "q" + * elif t == NPY_ULONGLONG: f = "Q" # <<<<<<<<<<<<<< + * elif t == NPY_FLOAT: f = "f" + * elif t == NPY_DOUBLE: f = "d" + */ + __pyx_t_1 = (__pyx_v_t == NPY_ULONGLONG); + if (__pyx_t_1) { + __pyx_v_f = __pyx_k__Q; + goto __pyx_L13; + } + + /* "numpy.pxd":268 + * elif t == NPY_LONGLONG: f = "q" + * elif t == NPY_ULONGLONG: f = "Q" + * elif t == NPY_FLOAT: f = "f" # <<<<<<<<<<<<<< + * elif t == NPY_DOUBLE: f = "d" + * elif t == NPY_LONGDOUBLE: f = "g" + */ + __pyx_t_1 = (__pyx_v_t == NPY_FLOAT); + if (__pyx_t_1) { + __pyx_v_f = __pyx_k__f; + goto __pyx_L13; + } + + /* "numpy.pxd":269 + * elif t == NPY_ULONGLONG: f = "Q" + * elif t == NPY_FLOAT: f = "f" + * elif t == NPY_DOUBLE: f = "d" # <<<<<<<<<<<<<< + * elif t == NPY_LONGDOUBLE: f = "g" + * elif t == NPY_CFLOAT: f = "Zf" + */ + __pyx_t_1 = (__pyx_v_t == NPY_DOUBLE); + if (__pyx_t_1) { + __pyx_v_f = __pyx_k__d; + goto __pyx_L13; + } + + /* "numpy.pxd":270 + * elif t == NPY_FLOAT: f = "f" + * elif t == NPY_DOUBLE: f = "d" + * elif t == NPY_LONGDOUBLE: f = "g" # <<<<<<<<<<<<<< + * elif t == NPY_CFLOAT: f = "Zf" + * elif t == NPY_CDOUBLE: f = "Zd" + */ + __pyx_t_1 = (__pyx_v_t == NPY_LONGDOUBLE); + if (__pyx_t_1) { + __pyx_v_f = __pyx_k__g; + goto __pyx_L13; + } + + /* "numpy.pxd":271 + * elif t == NPY_DOUBLE: f = "d" + * elif t == NPY_LONGDOUBLE: f = "g" + * elif t == NPY_CFLOAT: f = "Zf" # <<<<<<<<<<<<<< + * elif t == NPY_CDOUBLE: f = "Zd" + * elif t == NPY_CLONGDOUBLE: f = "Zg" + */ + __pyx_t_1 = (__pyx_v_t == NPY_CFLOAT); + if (__pyx_t_1) { + __pyx_v_f = __pyx_k__Zf; + goto __pyx_L13; + } + + /* "numpy.pxd":272 + * elif t == NPY_LONGDOUBLE: f = "g" + * elif t == NPY_CFLOAT: f = "Zf" + * elif t == NPY_CDOUBLE: f = "Zd" # <<<<<<<<<<<<<< + * elif t == NPY_CLONGDOUBLE: f = "Zg" + * elif t == NPY_OBJECT: f = "O" + */ + __pyx_t_1 = (__pyx_v_t == NPY_CDOUBLE); + if (__pyx_t_1) { + __pyx_v_f = __pyx_k__Zd; + goto __pyx_L13; + } + + /* "numpy.pxd":273 + * elif t == NPY_CFLOAT: f = "Zf" + * elif t == NPY_CDOUBLE: f = "Zd" + * elif t == NPY_CLONGDOUBLE: f = "Zg" # <<<<<<<<<<<<<< + * elif t == NPY_OBJECT: f = "O" + * else: + */ + __pyx_t_1 = (__pyx_v_t == NPY_CLONGDOUBLE); + if (__pyx_t_1) { + __pyx_v_f = __pyx_k__Zg; + goto __pyx_L13; + } + + /* "numpy.pxd":274 + * elif t == NPY_CDOUBLE: f = "Zd" + * elif t == NPY_CLONGDOUBLE: f = "Zg" + * elif t == NPY_OBJECT: f = "O" # <<<<<<<<<<<<<< + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + */ + __pyx_t_1 = (__pyx_v_t == NPY_OBJECT); + if (__pyx_t_1) { + __pyx_v_f = __pyx_k__O; + goto __pyx_L13; + } + /*else*/ { + + /* "numpy.pxd":276 + * elif t == NPY_OBJECT: f = "O" + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< + * info.format = f + * return + */ + __pyx_t_4 = PyInt_FromLong(__pyx_v_t); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_8 = PyNumber_Remainder(((PyObject *)__pyx_kp_u_61), __pyx_t_4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_8)); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_8)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_8)); + __pyx_t_8 = 0; + __pyx_t_8 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __Pyx_Raise(__pyx_t_8, 0, 0, 0); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_L13:; + + /* "numpy.pxd":277 + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + * info.format = f # <<<<<<<<<<<<<< + * return + * else: + */ + __pyx_v_info->format = __pyx_v_f; + + /* "numpy.pxd":278 + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + * info.format = f + * return # <<<<<<<<<<<<<< + * else: + * info.format = stdlib.malloc(_buffer_format_string_len) + */ + __pyx_r = 0; + goto __pyx_L0; + goto __pyx_L11; + } + /*else*/ { + + /* "numpy.pxd":280 + * return + * else: + * info.format = stdlib.malloc(_buffer_format_string_len) # <<<<<<<<<<<<<< + * info.format[0] = c'^' # Native data types, manual alignment + * offset = 0 + */ + __pyx_v_info->format = ((char *)malloc(255)); + + /* "numpy.pxd":281 + * else: + * info.format = stdlib.malloc(_buffer_format_string_len) + * info.format[0] = c'^' # Native data types, manual alignment # <<<<<<<<<<<<<< + * offset = 0 + * f = _util_dtypestring(descr, info.format + 1, + */ + (__pyx_v_info->format[0]) = '^'; + + /* "numpy.pxd":282 + * info.format = stdlib.malloc(_buffer_format_string_len) + * info.format[0] = c'^' # Native data types, manual alignment + * offset = 0 # <<<<<<<<<<<<<< + * f = _util_dtypestring(descr, info.format + 1, + * info.format + _buffer_format_string_len, + */ + __pyx_v_offset = 0; + + /* "numpy.pxd":285 + * f = _util_dtypestring(descr, info.format + 1, + * info.format + _buffer_format_string_len, + * &offset) # <<<<<<<<<<<<<< + * f[0] = c'\0' # Terminate format string + * + */ + __pyx_t_9 = __pyx_f_5numpy__util_dtypestring(__pyx_v_descr, (__pyx_v_info->format + 1), (__pyx_v_info->format + 255), (&__pyx_v_offset)); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_f = __pyx_t_9; + + /* "numpy.pxd":286 + * info.format + _buffer_format_string_len, + * &offset) + * f[0] = c'\0' # Terminate format string # <<<<<<<<<<<<<< + * + * def __releasebuffer__(ndarray self, Py_buffer* info): + */ + (__pyx_v_f[0]) = '\x00'; + } + __pyx_L11:; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_AddTraceback("numpy.ndarray.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + if (__pyx_v_info != NULL && __pyx_v_info->obj != NULL) { + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = NULL; + } + goto __pyx_L2; + __pyx_L0:; + if (__pyx_v_info != NULL && __pyx_v_info->obj == Py_None) { + __Pyx_GOTREF(Py_None); + __Pyx_DECREF(Py_None); __pyx_v_info->obj = NULL; + } + __pyx_L2:; + __Pyx_XDECREF((PyObject *)__pyx_v_descr); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info); /*proto*/ +static void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__releasebuffer__ (wrapper)", 0); + __pyx_pf_5numpy_7ndarray_2__releasebuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info)); + __Pyx_RefNannyFinishContext(); +} + +/* "numpy.pxd":288 + * f[0] = c'\0' # Terminate format string + * + * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< + * if PyArray_HASFIELDS(self): + * stdlib.free(info.format) + */ + +static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info) { + __Pyx_RefNannyDeclarations + int __pyx_t_1; + __Pyx_RefNannySetupContext("__releasebuffer__", 0); + + /* "numpy.pxd":289 + * + * def __releasebuffer__(ndarray self, Py_buffer* info): + * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<< + * stdlib.free(info.format) + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + */ + __pyx_t_1 = PyArray_HASFIELDS(__pyx_v_self); + if (__pyx_t_1) { + + /* "numpy.pxd":290 + * def __releasebuffer__(ndarray self, Py_buffer* info): + * if PyArray_HASFIELDS(self): + * stdlib.free(info.format) # <<<<<<<<<<<<<< + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + * stdlib.free(info.strides) + */ + free(__pyx_v_info->format); + goto __pyx_L3; + } + __pyx_L3:; + + /* "numpy.pxd":291 + * if PyArray_HASFIELDS(self): + * stdlib.free(info.format) + * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< + * stdlib.free(info.strides) + * # info.shape was stored after info.strides in the same block + */ + __pyx_t_1 = ((sizeof(npy_intp)) != (sizeof(Py_ssize_t))); + if (__pyx_t_1) { + + /* "numpy.pxd":292 + * stdlib.free(info.format) + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + * stdlib.free(info.strides) # <<<<<<<<<<<<<< + * # info.shape was stored after info.strides in the same block + * + */ + free(__pyx_v_info->strides); + goto __pyx_L4; + } + __pyx_L4:; + + __Pyx_RefNannyFinishContext(); +} + +/* "numpy.pxd":768 + * ctypedef npy_cdouble complex_t + * + * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(1, a) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__pyx_v_a) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0); + + /* "numpy.pxd":769 + * + * cdef inline object PyArray_MultiIterNew1(a): + * return PyArray_MultiIterNew(1, a) # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew2(a, b): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 769; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew1", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "numpy.pxd":771 + * return PyArray_MultiIterNew(1, a) + * + * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(2, a, b) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__pyx_v_a, PyObject *__pyx_v_b) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0); + + /* "numpy.pxd":772 + * + * cdef inline object PyArray_MultiIterNew2(a, b): + * return PyArray_MultiIterNew(2, a, b) # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew3(a, b, c): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 772; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew2", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "numpy.pxd":774 + * return PyArray_MultiIterNew(2, a, b) + * + * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(3, a, b, c) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0); + + /* "numpy.pxd":775 + * + * cdef inline object PyArray_MultiIterNew3(a, b, c): + * return PyArray_MultiIterNew(3, a, b, c) # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew4(a, b, c, d): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 775; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew3", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "numpy.pxd":777 + * return PyArray_MultiIterNew(3, a, b, c) + * + * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(4, a, b, c, d) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0); + + /* "numpy.pxd":778 + * + * cdef inline object PyArray_MultiIterNew4(a, b, c, d): + * return PyArray_MultiIterNew(4, a, b, c, d) # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew4", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "numpy.pxd":780 + * return PyArray_MultiIterNew(4, a, b, c, d) + * + * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(5, a, b, c, d, e) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d, PyObject *__pyx_v_e) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0); + + /* "numpy.pxd":781 + * + * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): + * return PyArray_MultiIterNew(5, a, b, c, d, e) # <<<<<<<<<<<<<< + * + * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew5", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "numpy.pxd":783 + * return PyArray_MultiIterNew(5, a, b, c, d, e) + * + * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< + * # Recursive utility function used in __getbuffer__ to get format + * # string. The new location in the format string is returned. + */ + +static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_descr, char *__pyx_v_f, char *__pyx_v_end, int *__pyx_v_offset) { + PyArray_Descr *__pyx_v_child = 0; + int __pyx_v_endian_detector; + int __pyx_v_little_endian; + PyObject *__pyx_v_fields = 0; + PyObject *__pyx_v_childname = NULL; + PyObject *__pyx_v_new_offset = NULL; + PyObject *__pyx_v_t = NULL; + char *__pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + Py_ssize_t __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *(*__pyx_t_6)(PyObject *); + int __pyx_t_7; + int __pyx_t_8; + int __pyx_t_9; + int __pyx_t_10; + long __pyx_t_11; + char *__pyx_t_12; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("_util_dtypestring", 0); + + /* "numpy.pxd":790 + * cdef int delta_offset + * cdef tuple i + * cdef int endian_detector = 1 # <<<<<<<<<<<<<< + * cdef bint little_endian = ((&endian_detector)[0] != 0) + * cdef tuple fields + */ + __pyx_v_endian_detector = 1; + + /* "numpy.pxd":791 + * cdef tuple i + * cdef int endian_detector = 1 + * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< + * cdef tuple fields + * + */ + __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); + + /* "numpy.pxd":794 + * cdef tuple fields + * + * for childname in descr.names: # <<<<<<<<<<<<<< + * fields = descr.fields[childname] + * child, new_offset = fields + */ + if (unlikely(((PyObject *)__pyx_v_descr->names) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_1 = ((PyObject *)__pyx_v_descr->names); __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; + for (;;) { + if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + __Pyx_XDECREF(__pyx_v_childname); + __pyx_v_childname = __pyx_t_3; + __pyx_t_3 = 0; + + /* "numpy.pxd":795 + * + * for childname in descr.names: + * fields = descr.fields[childname] # <<<<<<<<<<<<<< + * child, new_offset = fields + * + */ + __pyx_t_3 = PyObject_GetItem(__pyx_v_descr->fields, __pyx_v_childname); if (!__pyx_t_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected tuple, got %.200s", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_XDECREF(((PyObject *)__pyx_v_fields)); + __pyx_v_fields = ((PyObject*)__pyx_t_3); + __pyx_t_3 = 0; + + /* "numpy.pxd":796 + * for childname in descr.names: + * fields = descr.fields[childname] + * child, new_offset = fields # <<<<<<<<<<<<<< + * + * if (end - f) - (new_offset - offset[0]) < 15: + */ + if (likely(PyTuple_CheckExact(((PyObject *)__pyx_v_fields)))) { + PyObject* sequence = ((PyObject *)__pyx_v_fields); + #if CYTHON_COMPILING_IN_CPYTHON + Py_ssize_t size = Py_SIZE(sequence); + #else + Py_ssize_t size = PySequence_Size(sequence); + #endif + if (unlikely(size != 2)) { + if (size > 2) __Pyx_RaiseTooManyValuesError(2); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); + #else + __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + } else if (1) { + __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else + { + Py_ssize_t index = -1; + __pyx_t_5 = PyObject_GetIter(((PyObject *)__pyx_v_fields)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_6 = Py_TYPE(__pyx_t_5)->tp_iternext; + index = 0; __pyx_t_3 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L5_unpacking_failed; + __Pyx_GOTREF(__pyx_t_3); + index = 1; __pyx_t_4 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L5_unpacking_failed; + __Pyx_GOTREF(__pyx_t_4); + if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = NULL; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + goto __pyx_L6_unpacking_done; + __pyx_L5_unpacking_failed:; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_6 = NULL; + if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_L6_unpacking_done:; + } + if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_dtype))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_XDECREF(((PyObject *)__pyx_v_child)); + __pyx_v_child = ((PyArray_Descr *)__pyx_t_3); + __pyx_t_3 = 0; + __Pyx_XDECREF(__pyx_v_new_offset); + __pyx_v_new_offset = __pyx_t_4; + __pyx_t_4 = 0; + + /* "numpy.pxd":798 + * child, new_offset = fields + * + * if (end - f) - (new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") + * + */ + __pyx_t_4 = PyInt_FromLong((__pyx_v_end - __pyx_v_f)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyInt_FromLong((__pyx_v_offset[0])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyNumber_Subtract(__pyx_v_new_offset, __pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyNumber_Subtract(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyObject_RichCompare(__pyx_t_3, __pyx_int_15, Py_LT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + + /* "numpy.pxd":799 + * + * if (end - f) - (new_offset - offset[0]) < 15: + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< + * + * if ((child.byteorder == c'>' and little_endian) or + */ + __pyx_t_5 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_63), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_Raise(__pyx_t_5, 0, 0, 0); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L7; + } + __pyx_L7:; + + /* "numpy.pxd":801 + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") + * + * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< + * (child.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") + */ + __pyx_t_7 = (__pyx_v_child->byteorder == '>'); + if (__pyx_t_7) { + __pyx_t_8 = __pyx_v_little_endian; + } else { + __pyx_t_8 = __pyx_t_7; + } + if (!__pyx_t_8) { + + /* "numpy.pxd":802 + * + * if ((child.byteorder == c'>' and little_endian) or + * (child.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< + * raise ValueError(u"Non-native byte order not supported") + * # One could encode it in the format string and have Cython + */ + __pyx_t_7 = (__pyx_v_child->byteorder == '<'); + if (__pyx_t_7) { + __pyx_t_9 = (!__pyx_v_little_endian); + __pyx_t_10 = __pyx_t_9; + } else { + __pyx_t_10 = __pyx_t_7; + } + __pyx_t_7 = __pyx_t_10; + } else { + __pyx_t_7 = __pyx_t_8; + } + if (__pyx_t_7) { + + /* "numpy.pxd":803 + * if ((child.byteorder == c'>' and little_endian) or + * (child.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< + * # One could encode it in the format string and have Cython + * # complain instead, BUT: < and > in format strings also imply + */ + __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_64), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_Raise(__pyx_t_5, 0, 0, 0); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L8; + } + __pyx_L8:; + + /* "numpy.pxd":813 + * + * # Output padding bytes + * while offset[0] < new_offset: # <<<<<<<<<<<<<< + * f[0] = 120 # "x"; pad byte + * f += 1 + */ + while (1) { + __pyx_t_5 = PyInt_FromLong((__pyx_v_offset[0])); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_t_5, __pyx_v_new_offset, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (!__pyx_t_7) break; + + /* "numpy.pxd":814 + * # Output padding bytes + * while offset[0] < new_offset: + * f[0] = 120 # "x"; pad byte # <<<<<<<<<<<<<< + * f += 1 + * offset[0] += 1 + */ + (__pyx_v_f[0]) = 120; + + /* "numpy.pxd":815 + * while offset[0] < new_offset: + * f[0] = 120 # "x"; pad byte + * f += 1 # <<<<<<<<<<<<<< + * offset[0] += 1 + * + */ + __pyx_v_f = (__pyx_v_f + 1); + + /* "numpy.pxd":816 + * f[0] = 120 # "x"; pad byte + * f += 1 + * offset[0] += 1 # <<<<<<<<<<<<<< + * + * offset[0] += child.itemsize + */ + __pyx_t_11 = 0; + (__pyx_v_offset[__pyx_t_11]) = ((__pyx_v_offset[__pyx_t_11]) + 1); + } + + /* "numpy.pxd":818 + * offset[0] += 1 + * + * offset[0] += child.itemsize # <<<<<<<<<<<<<< + * + * if not PyDataType_HASFIELDS(child): + */ + __pyx_t_11 = 0; + (__pyx_v_offset[__pyx_t_11]) = ((__pyx_v_offset[__pyx_t_11]) + __pyx_v_child->elsize); + + /* "numpy.pxd":820 + * offset[0] += child.itemsize + * + * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< + * t = child.type_num + * if end - f < 5: + */ + __pyx_t_7 = (!PyDataType_HASFIELDS(__pyx_v_child)); + if (__pyx_t_7) { + + /* "numpy.pxd":821 + * + * if not PyDataType_HASFIELDS(child): + * t = child.type_num # <<<<<<<<<<<<<< + * if end - f < 5: + * raise RuntimeError(u"Format string allocated too short.") + */ + __pyx_t_3 = PyInt_FromLong(__pyx_v_child->type_num); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_v_t); + __pyx_v_t = __pyx_t_3; + __pyx_t_3 = 0; + + /* "numpy.pxd":822 + * if not PyDataType_HASFIELDS(child): + * t = child.type_num + * if end - f < 5: # <<<<<<<<<<<<<< + * raise RuntimeError(u"Format string allocated too short.") + * + */ + __pyx_t_7 = ((__pyx_v_end - __pyx_v_f) < 5); + if (__pyx_t_7) { + + /* "numpy.pxd":823 + * t = child.type_num + * if end - f < 5: + * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< + * + * # Until ticket #99 is fixed, use integers to avoid warnings + */ + __pyx_t_3 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_66), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L12; + } + __pyx_L12:; + + /* "numpy.pxd":826 + * + * # Until ticket #99 is fixed, use integers to avoid warnings + * if t == NPY_BYTE: f[0] = 98 #"b" # <<<<<<<<<<<<<< + * elif t == NPY_UBYTE: f[0] = 66 #"B" + * elif t == NPY_SHORT: f[0] = 104 #"h" + */ + __pyx_t_3 = PyInt_FromLong(NPY_BYTE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 98; + goto __pyx_L13; + } + + /* "numpy.pxd":827 + * # Until ticket #99 is fixed, use integers to avoid warnings + * if t == NPY_BYTE: f[0] = 98 #"b" + * elif t == NPY_UBYTE: f[0] = 66 #"B" # <<<<<<<<<<<<<< + * elif t == NPY_SHORT: f[0] = 104 #"h" + * elif t == NPY_USHORT: f[0] = 72 #"H" + */ + __pyx_t_5 = PyInt_FromLong(NPY_UBYTE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 66; + goto __pyx_L13; + } + + /* "numpy.pxd":828 + * if t == NPY_BYTE: f[0] = 98 #"b" + * elif t == NPY_UBYTE: f[0] = 66 #"B" + * elif t == NPY_SHORT: f[0] = 104 #"h" # <<<<<<<<<<<<<< + * elif t == NPY_USHORT: f[0] = 72 #"H" + * elif t == NPY_INT: f[0] = 105 #"i" + */ + __pyx_t_3 = PyInt_FromLong(NPY_SHORT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 104; + goto __pyx_L13; + } + + /* "numpy.pxd":829 + * elif t == NPY_UBYTE: f[0] = 66 #"B" + * elif t == NPY_SHORT: f[0] = 104 #"h" + * elif t == NPY_USHORT: f[0] = 72 #"H" # <<<<<<<<<<<<<< + * elif t == NPY_INT: f[0] = 105 #"i" + * elif t == NPY_UINT: f[0] = 73 #"I" + */ + __pyx_t_5 = PyInt_FromLong(NPY_USHORT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 72; + goto __pyx_L13; + } + + /* "numpy.pxd":830 + * elif t == NPY_SHORT: f[0] = 104 #"h" + * elif t == NPY_USHORT: f[0] = 72 #"H" + * elif t == NPY_INT: f[0] = 105 #"i" # <<<<<<<<<<<<<< + * elif t == NPY_UINT: f[0] = 73 #"I" + * elif t == NPY_LONG: f[0] = 108 #"l" + */ + __pyx_t_3 = PyInt_FromLong(NPY_INT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 105; + goto __pyx_L13; + } + + /* "numpy.pxd":831 + * elif t == NPY_USHORT: f[0] = 72 #"H" + * elif t == NPY_INT: f[0] = 105 #"i" + * elif t == NPY_UINT: f[0] = 73 #"I" # <<<<<<<<<<<<<< + * elif t == NPY_LONG: f[0] = 108 #"l" + * elif t == NPY_ULONG: f[0] = 76 #"L" + */ + __pyx_t_5 = PyInt_FromLong(NPY_UINT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 73; + goto __pyx_L13; + } + + /* "numpy.pxd":832 + * elif t == NPY_INT: f[0] = 105 #"i" + * elif t == NPY_UINT: f[0] = 73 #"I" + * elif t == NPY_LONG: f[0] = 108 #"l" # <<<<<<<<<<<<<< + * elif t == NPY_ULONG: f[0] = 76 #"L" + * elif t == NPY_LONGLONG: f[0] = 113 #"q" + */ + __pyx_t_3 = PyInt_FromLong(NPY_LONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 108; + goto __pyx_L13; + } + + /* "numpy.pxd":833 + * elif t == NPY_UINT: f[0] = 73 #"I" + * elif t == NPY_LONG: f[0] = 108 #"l" + * elif t == NPY_ULONG: f[0] = 76 #"L" # <<<<<<<<<<<<<< + * elif t == NPY_LONGLONG: f[0] = 113 #"q" + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" + */ + __pyx_t_5 = PyInt_FromLong(NPY_ULONG); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 76; + goto __pyx_L13; + } + + /* "numpy.pxd":834 + * elif t == NPY_LONG: f[0] = 108 #"l" + * elif t == NPY_ULONG: f[0] = 76 #"L" + * elif t == NPY_LONGLONG: f[0] = 113 #"q" # <<<<<<<<<<<<<< + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" + * elif t == NPY_FLOAT: f[0] = 102 #"f" + */ + __pyx_t_3 = PyInt_FromLong(NPY_LONGLONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 113; + goto __pyx_L13; + } + + /* "numpy.pxd":835 + * elif t == NPY_ULONG: f[0] = 76 #"L" + * elif t == NPY_LONGLONG: f[0] = 113 #"q" + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" # <<<<<<<<<<<<<< + * elif t == NPY_FLOAT: f[0] = 102 #"f" + * elif t == NPY_DOUBLE: f[0] = 100 #"d" + */ + __pyx_t_5 = PyInt_FromLong(NPY_ULONGLONG); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 81; + goto __pyx_L13; + } + + /* "numpy.pxd":836 + * elif t == NPY_LONGLONG: f[0] = 113 #"q" + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" + * elif t == NPY_FLOAT: f[0] = 102 #"f" # <<<<<<<<<<<<<< + * elif t == NPY_DOUBLE: f[0] = 100 #"d" + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" + */ + __pyx_t_3 = PyInt_FromLong(NPY_FLOAT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 102; + goto __pyx_L13; + } + + /* "numpy.pxd":837 + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" + * elif t == NPY_FLOAT: f[0] = 102 #"f" + * elif t == NPY_DOUBLE: f[0] = 100 #"d" # <<<<<<<<<<<<<< + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf + */ + __pyx_t_5 = PyInt_FromLong(NPY_DOUBLE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 100; + goto __pyx_L13; + } + + /* "numpy.pxd":838 + * elif t == NPY_FLOAT: f[0] = 102 #"f" + * elif t == NPY_DOUBLE: f[0] = 100 #"d" + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" # <<<<<<<<<<<<<< + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd + */ + __pyx_t_3 = PyInt_FromLong(NPY_LONGDOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 103; + goto __pyx_L13; + } + + /* "numpy.pxd":839 + * elif t == NPY_DOUBLE: f[0] = 100 #"d" + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf # <<<<<<<<<<<<<< + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd + * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg + */ + __pyx_t_5 = PyInt_FromLong(NPY_CFLOAT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 90; + (__pyx_v_f[1]) = 102; + __pyx_v_f = (__pyx_v_f + 1); + goto __pyx_L13; + } + + /* "numpy.pxd":840 + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd # <<<<<<<<<<<<<< + * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg + * elif t == NPY_OBJECT: f[0] = 79 #"O" + */ + __pyx_t_3 = PyInt_FromLong(NPY_CDOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 90; + (__pyx_v_f[1]) = 100; + __pyx_v_f = (__pyx_v_f + 1); + goto __pyx_L13; + } + + /* "numpy.pxd":841 + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd + * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg # <<<<<<<<<<<<<< + * elif t == NPY_OBJECT: f[0] = 79 #"O" + * else: + */ + __pyx_t_5 = PyInt_FromLong(NPY_CLONGDOUBLE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 90; + (__pyx_v_f[1]) = 103; + __pyx_v_f = (__pyx_v_f + 1); + goto __pyx_L13; + } + + /* "numpy.pxd":842 + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd + * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg + * elif t == NPY_OBJECT: f[0] = 79 #"O" # <<<<<<<<<<<<<< + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + */ + __pyx_t_3 = PyInt_FromLong(NPY_OBJECT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 79; + goto __pyx_L13; + } + /*else*/ { + + /* "numpy.pxd":844 + * elif t == NPY_OBJECT: f[0] = 79 #"O" + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< + * f += 1 + * else: + */ + __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_u_61), __pyx_v_t); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_5)); + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_5)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_5)); + __pyx_t_5 = 0; + __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __Pyx_Raise(__pyx_t_5, 0, 0, 0); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_L13:; + + /* "numpy.pxd":845 + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + * f += 1 # <<<<<<<<<<<<<< + * else: + * # Cython ignores struct boundary information ("T{...}"), + */ + __pyx_v_f = (__pyx_v_f + 1); + goto __pyx_L11; + } + /*else*/ { + + /* "numpy.pxd":849 + * # Cython ignores struct boundary information ("T{...}"), + * # so don't output it + * f = _util_dtypestring(child, f, end, offset) # <<<<<<<<<<<<<< + * return f + * + */ + __pyx_t_12 = __pyx_f_5numpy__util_dtypestring(__pyx_v_child, __pyx_v_f, __pyx_v_end, __pyx_v_offset); if (unlikely(__pyx_t_12 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_f = __pyx_t_12; + } + __pyx_L11:; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "numpy.pxd":850 + * # so don't output it + * f = _util_dtypestring(child, f, end, offset) + * return f # <<<<<<<<<<<<<< + * + * + */ + __pyx_r = __pyx_v_f; + goto __pyx_L0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("numpy._util_dtypestring", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_child); + __Pyx_XDECREF(__pyx_v_fields); + __Pyx_XDECREF(__pyx_v_childname); + __Pyx_XDECREF(__pyx_v_new_offset); + __Pyx_XDECREF(__pyx_v_t); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "numpy.pxd":965 + * + * + * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< + * cdef PyObject* baseptr + * if base is None: + */ + +static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_base) { + PyObject *__pyx_v_baseptr; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + __Pyx_RefNannySetupContext("set_array_base", 0); + + /* "numpy.pxd":967 + * cdef inline void set_array_base(ndarray arr, object base): + * cdef PyObject* baseptr + * if base is None: # <<<<<<<<<<<<<< + * baseptr = NULL + * else: + */ + __pyx_t_1 = (__pyx_v_base == Py_None); + if (__pyx_t_1) { + + /* "numpy.pxd":968 + * cdef PyObject* baseptr + * if base is None: + * baseptr = NULL # <<<<<<<<<<<<<< + * else: + * Py_INCREF(base) # important to do this before decref below! + */ + __pyx_v_baseptr = NULL; + goto __pyx_L3; + } + /*else*/ { + + /* "numpy.pxd":970 + * baseptr = NULL + * else: + * Py_INCREF(base) # important to do this before decref below! # <<<<<<<<<<<<<< + * baseptr = base + * Py_XDECREF(arr.base) + */ + Py_INCREF(__pyx_v_base); + + /* "numpy.pxd":971 + * else: + * Py_INCREF(base) # important to do this before decref below! + * baseptr = base # <<<<<<<<<<<<<< + * Py_XDECREF(arr.base) + * arr.base = baseptr + */ + __pyx_v_baseptr = ((PyObject *)__pyx_v_base); + } + __pyx_L3:; + + /* "numpy.pxd":972 + * Py_INCREF(base) # important to do this before decref below! + * baseptr = base + * Py_XDECREF(arr.base) # <<<<<<<<<<<<<< + * arr.base = baseptr + * + */ + Py_XDECREF(__pyx_v_arr->base); + + /* "numpy.pxd":973 + * baseptr = base + * Py_XDECREF(arr.base) + * arr.base = baseptr # <<<<<<<<<<<<<< + * + * cdef inline object get_array_base(ndarray arr): + */ + __pyx_v_arr->base = __pyx_v_baseptr; + + __Pyx_RefNannyFinishContext(); +} + +/* "numpy.pxd":975 + * arr.base = baseptr + * + * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< + * if arr.base is NULL: + * return None + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__pyx_v_arr) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + __Pyx_RefNannySetupContext("get_array_base", 0); + + /* "numpy.pxd":976 + * + * cdef inline object get_array_base(ndarray arr): + * if arr.base is NULL: # <<<<<<<<<<<<<< + * return None + * else: + */ + __pyx_t_1 = (__pyx_v_arr->base == NULL); + if (__pyx_t_1) { + + /* "numpy.pxd":977 + * cdef inline object get_array_base(ndarray arr): + * if arr.base is NULL: + * return None # <<<<<<<<<<<<<< + * else: + * return arr.base + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(Py_None); + __pyx_r = Py_None; + goto __pyx_L0; + goto __pyx_L3; + } + /*else*/ { + + /* "numpy.pxd":979 + * return None + * else: + * return arr.base # <<<<<<<<<<<<<< + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_arr->base)); + __pyx_r = ((PyObject *)__pyx_v_arr->base); + goto __pyx_L0; + } + __pyx_L3:; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyMethodDef __pyx_methods[] = { + {0, 0, 0, 0} +}; + +#if PY_MAJOR_VERSION >= 3 +static struct PyModuleDef __pyx_moduledef = { + PyModuleDef_HEAD_INIT, + __Pyx_NAMESTR("hmmUtils"), + 0, /* m_doc */ + -1, /* m_size */ + __pyx_methods /* m_methods */, + NULL, /* m_reload */ + NULL, /* m_traverse */ + NULL, /* m_clear */ + NULL /* m_free */ +}; +#endif + +static __Pyx_StringTabEntry __pyx_string_tab[] = { + {&__pyx_kp_s_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 1, 0}, + {&__pyx_kp_s_2, __pyx_k_2, sizeof(__pyx_k_2), 0, 0, 1, 0}, + {&__pyx_kp_s_24, __pyx_k_24, sizeof(__pyx_k_24), 0, 0, 1, 0}, + {&__pyx_kp_s_26, __pyx_k_26, sizeof(__pyx_k_26), 0, 0, 1, 0}, + {&__pyx_kp_s_27, __pyx_k_27, sizeof(__pyx_k_27), 0, 0, 1, 0}, + {&__pyx_kp_s_28, __pyx_k_28, sizeof(__pyx_k_28), 0, 0, 1, 0}, + {&__pyx_kp_s_32, __pyx_k_32, sizeof(__pyx_k_32), 0, 0, 1, 0}, + {&__pyx_kp_s_4, __pyx_k_4, sizeof(__pyx_k_4), 0, 0, 1, 0}, + {&__pyx_kp_s_40, __pyx_k_40, sizeof(__pyx_k_40), 0, 0, 1, 0}, + {&__pyx_kp_s_53, __pyx_k_53, sizeof(__pyx_k_53), 0, 0, 1, 0}, + {&__pyx_kp_u_55, __pyx_k_55, sizeof(__pyx_k_55), 0, 1, 0, 0}, + {&__pyx_kp_u_57, __pyx_k_57, sizeof(__pyx_k_57), 0, 1, 0, 0}, + {&__pyx_kp_u_59, __pyx_k_59, sizeof(__pyx_k_59), 0, 1, 0, 0}, + {&__pyx_kp_u_61, __pyx_k_61, sizeof(__pyx_k_61), 0, 1, 0, 0}, + {&__pyx_kp_u_62, __pyx_k_62, sizeof(__pyx_k_62), 0, 1, 0, 0}, + {&__pyx_kp_u_65, __pyx_k_65, sizeof(__pyx_k_65), 0, 1, 0, 0}, + {&__pyx_kp_s_69, __pyx_k_69, sizeof(__pyx_k_69), 0, 0, 1, 0}, + {&__pyx_n_s_70, __pyx_k_70, sizeof(__pyx_k_70), 0, 0, 1, 1}, + {&__pyx_kp_s_8, __pyx_k_8, sizeof(__pyx_k_8), 0, 0, 1, 0}, + {&__pyx_n_s__DTYPEf, __pyx_k__DTYPEf, sizeof(__pyx_k__DTYPEf), 0, 0, 1, 1}, + {&__pyx_n_s__DTYPEi, __pyx_k__DTYPEi, sizeof(__pyx_k__DTYPEi), 0, 0, 1, 1}, + {&__pyx_n_s__RuntimeError, __pyx_k__RuntimeError, sizeof(__pyx_k__RuntimeError), 0, 0, 1, 1}, + {&__pyx_n_s__V, __pyx_k__V, sizeof(__pyx_k__V), 0, 0, 1, 1}, + {&__pyx_n_s__ValueError, __pyx_k__ValueError, sizeof(__pyx_k__ValueError), 0, 0, 1, 1}, + {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1}, + {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1}, + {&__pyx_n_s__argparse, __pyx_k__argparse, sizeof(__pyx_k__argparse), 0, 0, 1, 1}, + {&__pyx_n_s__array, __pyx_k__array, sizeof(__pyx_k__array), 0, 0, 1, 1}, + {&__pyx_n_s__comp, __pyx_k__comp, sizeof(__pyx_k__comp), 0, 0, 1, 1}, + {&__pyx_n_s__comprob, __pyx_k__comprob, sizeof(__pyx_k__comprob), 0, 0, 1, 1}, + {&__pyx_n_s__efile, __pyx_k__efile, sizeof(__pyx_k__efile), 0, 0, 1, 1}, + {&__pyx_n_s__emat, __pyx_k__emat, sizeof(__pyx_k__emat), 0, 0, 1, 1}, + {&__pyx_n_s__emit_p, __pyx_k__emit_p, sizeof(__pyx_k__emit_p), 0, 0, 1, 1}, + {&__pyx_n_s__emitmat, __pyx_k__emitmat, sizeof(__pyx_k__emitmat), 0, 0, 1, 1}, + {&__pyx_n_s__erprobC, __pyx_k__erprobC, sizeof(__pyx_k__erprobC), 0, 0, 1, 1}, + {&__pyx_n_s__erprobG, __pyx_k__erprobG, sizeof(__pyx_k__erprobG), 0, 0, 1, 1}, + {&__pyx_n_s__erprobHI, __pyx_k__erprobHI, sizeof(__pyx_k__erprobHI), 0, 0, 1, 1}, + {&__pyx_n_s__erprobID, __pyx_k__erprobID, sizeof(__pyx_k__erprobID), 0, 0, 1, 1}, + {&__pyx_n_s__erprobM, __pyx_k__erprobM, sizeof(__pyx_k__erprobM), 0, 0, 1, 1}, + {&__pyx_n_s__err, __pyx_k__err, sizeof(__pyx_k__err), 0, 0, 1, 1}, + {&__pyx_n_s__errprob, __pyx_k__errprob, sizeof(__pyx_k__errprob), 0, 0, 1, 1}, + {&__pyx_n_s__exit, __pyx_k__exit, sizeof(__pyx_k__exit), 0, 0, 1, 1}, + {&__pyx_n_s__fileinput, __pyx_k__fileinput, sizeof(__pyx_k__fileinput), 0, 0, 1, 1}, + {&__pyx_n_s__float, __pyx_k__float, sizeof(__pyx_k__float), 0, 0, 1, 1}, + {&__pyx_n_s__getopt, __pyx_k__getopt, sizeof(__pyx_k__getopt), 0, 0, 1, 1}, + {&__pyx_n_s__goodprob, __pyx_k__goodprob, sizeof(__pyx_k__goodprob), 0, 0, 1, 1}, + {&__pyx_n_s__goodprobHI, __pyx_k__goodprobHI, sizeof(__pyx_k__goodprobHI), 0, 0, 1, 1}, + {&__pyx_n_s__goodprobID, __pyx_k__goodprobID, sizeof(__pyx_k__goodprobID), 0, 0, 1, 1}, + {&__pyx_n_s__i, __pyx_k__i, sizeof(__pyx_k__i), 0, 0, 1, 1}, + {&__pyx_n_s__imap, __pyx_k__imap, sizeof(__pyx_k__imap), 0, 0, 1, 1}, + {&__pyx_n_s__inmap, __pyx_k__inmap, sizeof(__pyx_k__inmap), 0, 0, 1, 1}, + {&__pyx_n_s__input_map, __pyx_k__input_map, sizeof(__pyx_k__input_map), 0, 0, 1, 1}, + {&__pyx_n_s__int, __pyx_k__int, sizeof(__pyx_k__int), 0, 0, 1, 1}, + {&__pyx_n_s__line, __pyx_k__line, sizeof(__pyx_k__line), 0, 0, 1, 1}, + {&__pyx_n_s__linelist, __pyx_k__linelist, sizeof(__pyx_k__linelist), 0, 0, 1, 1}, + {&__pyx_n_s__load_emission, __pyx_k__load_emission, sizeof(__pyx_k__load_emission), 0, 0, 1, 1}, + {&__pyx_n_s__load_transition, __pyx_k__load_transition, sizeof(__pyx_k__load_transition), 0, 0, 1, 1}, + {&__pyx_n_s__log10, __pyx_k__log10, sizeof(__pyx_k__log10), 0, 0, 1, 1}, + {&__pyx_n_s__make_hmm, __pyx_k__make_hmm, sizeof(__pyx_k__make_hmm), 0, 0, 1, 1}, + {&__pyx_n_s__makeobs_set, __pyx_k__makeobs_set, sizeof(__pyx_k__makeobs_set), 0, 0, 1, 1}, + {&__pyx_n_s__math, __pyx_k__math, sizeof(__pyx_k__math), 0, 0, 1, 1}, + {&__pyx_n_s__max, __pyx_k__max, sizeof(__pyx_k__max), 0, 0, 1, 1}, + {&__pyx_n_s__mie, __pyx_k__mie, sizeof(__pyx_k__mie), 0, 0, 1, 1}, + {&__pyx_n_s__mieprob, __pyx_k__mieprob, sizeof(__pyx_k__mieprob), 0, 0, 1, 1}, + {&__pyx_n_s__mpath, __pyx_k__mpath, sizeof(__pyx_k__mpath), 0, 0, 1, 1}, + {&__pyx_n_s__mprob, __pyx_k__mprob, sizeof(__pyx_k__mprob), 0, 0, 1, 1}, + {&__pyx_n_s__n_assort, __pyx_k__n_assort, sizeof(__pyx_k__n_assort), 0, 0, 1, 1}, + {&__pyx_n_s__nonself, __pyx_k__nonself, sizeof(__pyx_k__nonself), 0, 0, 1, 1}, + {&__pyx_n_s__nonselftrans, __pyx_k__nonselftrans, sizeof(__pyx_k__nonselftrans), 0, 0, 1, 1}, + {&__pyx_n_s__np, __pyx_k__np, sizeof(__pyx_k__np), 0, 0, 1, 1}, + {&__pyx_n_s__nprob, __pyx_k__nprob, sizeof(__pyx_k__nprob), 0, 0, 1, 1}, + {&__pyx_n_s__numpy, __pyx_k__numpy, sizeof(__pyx_k__numpy), 0, 0, 1, 1}, + {&__pyx_n_s__numsubj, __pyx_k__numsubj, sizeof(__pyx_k__numsubj), 0, 0, 1, 1}, + {&__pyx_n_s__obs, __pyx_k__obs, sizeof(__pyx_k__obs), 0, 0, 1, 1}, + {&__pyx_n_s__open, __pyx_k__open, sizeof(__pyx_k__open), 0, 0, 1, 1}, + {&__pyx_n_s__os, __pyx_k__os, sizeof(__pyx_k__os), 0, 0, 1, 1}, + {&__pyx_n_s__path, __pyx_k__path, sizeof(__pyx_k__path), 0, 0, 1, 1}, + {&__pyx_n_s__path_efile, __pyx_k__path_efile, sizeof(__pyx_k__path_efile), 0, 0, 1, 1}, + {&__pyx_n_s__prob, __pyx_k__prob, sizeof(__pyx_k__prob), 0, 0, 1, 1}, + {&__pyx_n_s__q, __pyx_k__q, sizeof(__pyx_k__q), 0, 0, 1, 1}, + {&__pyx_n_s__r, __pyx_k__r, sizeof(__pyx_k__r), 0, 0, 1, 1}, + {&__pyx_n_s__range, __pyx_k__range, sizeof(__pyx_k__range), 0, 0, 1, 1}, + {&__pyx_n_s__re, __pyx_k__re, sizeof(__pyx_k__re), 0, 0, 1, 1}, + {&__pyx_n_s__readline, __pyx_k__readline, sizeof(__pyx_k__readline), 0, 0, 1, 1}, + {&__pyx_n_s__readlines, __pyx_k__readlines, sizeof(__pyx_k__readlines), 0, 0, 1, 1}, + {&__pyx_n_s__replace, __pyx_k__replace, sizeof(__pyx_k__replace), 0, 0, 1, 1}, + {&__pyx_n_s__self, __pyx_k__self, sizeof(__pyx_k__self), 0, 0, 1, 1}, + {&__pyx_n_s__selftrans, __pyx_k__selftrans, sizeof(__pyx_k__selftrans), 0, 0, 1, 1}, + {&__pyx_n_s__split, __pyx_k__split, sizeof(__pyx_k__split), 0, 0, 1, 1}, + {&__pyx_n_s__sprob, __pyx_k__sprob, sizeof(__pyx_k__sprob), 0, 0, 1, 1}, + {&__pyx_n_s__start_p, __pyx_k__start_p, sizeof(__pyx_k__start_p), 0, 0, 1, 1}, + {&__pyx_n_s__startp, __pyx_k__startp, sizeof(__pyx_k__startp), 0, 0, 1, 1}, + {&__pyx_n_s__state, __pyx_k__state, sizeof(__pyx_k__state), 0, 0, 1, 1}, + {&__pyx_n_s__states, __pyx_k__states, sizeof(__pyx_k__states), 0, 0, 1, 1}, + {&__pyx_n_s__stderr, __pyx_k__stderr, sizeof(__pyx_k__stderr), 0, 0, 1, 1}, + {&__pyx_n_s__sub_ped, __pyx_k__sub_ped, sizeof(__pyx_k__sub_ped), 0, 0, 1, 1}, + {&__pyx_n_s__sys, __pyx_k__sys, sizeof(__pyx_k__sys), 0, 0, 1, 1}, + {&__pyx_n_s__t, __pyx_k__t, sizeof(__pyx_k__t), 0, 0, 1, 1}, + {&__pyx_n_s__tempin, __pyx_k__tempin, sizeof(__pyx_k__tempin), 0, 0, 1, 1}, + {&__pyx_n_s__tfile, __pyx_k__tfile, sizeof(__pyx_k__tfile), 0, 0, 1, 1}, + {&__pyx_n_s__tmat, __pyx_k__tmat, sizeof(__pyx_k__tmat), 0, 0, 1, 1}, + {&__pyx_n_s__trans_p, __pyx_k__trans_p, sizeof(__pyx_k__trans_p), 0, 0, 1, 1}, + {&__pyx_n_s__transmat, __pyx_k__transmat, sizeof(__pyx_k__transmat), 0, 0, 1, 1}, + {&__pyx_n_s__trash, __pyx_k__trash, sizeof(__pyx_k__trash), 0, 0, 1, 1}, + {&__pyx_n_s__viterbi, __pyx_k__viterbi, sizeof(__pyx_k__viterbi), 0, 0, 1, 1}, + {&__pyx_n_s__y, __pyx_k__y, sizeof(__pyx_k__y), 0, 0, 1, 1}, + {&__pyx_n_s__y0, __pyx_k__y0, sizeof(__pyx_k__y0), 0, 0, 1, 1}, + {&__pyx_n_s__zeros, __pyx_k__zeros, sizeof(__pyx_k__zeros), 0, 0, 1, 1}, + {0, 0, 0, 0, 0, 0, 0} +}; +static int __Pyx_InitCachedBuiltins(void) { + __pyx_builtin_open = __Pyx_GetName(__pyx_b, __pyx_n_s__open); if (!__pyx_builtin_open) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_exit = __Pyx_GetName(__pyx_b, __pyx_n_s__exit); if (!__pyx_builtin_exit) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_range = __Pyx_GetName(__pyx_b, __pyx_n_s__range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_max = __Pyx_GetName(__pyx_b, __pyx_n_s__max); if (!__pyx_builtin_max) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_RuntimeError = __Pyx_GetName(__pyx_b, __pyx_n_s__RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + return 0; + __pyx_L1_error:; + return -1; +} + +static int __Pyx_InitCachedConstants(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); + + /* "trioToolsNew/hmmUtils.pyx":31 + * tfile = open(path, "r") + * for line in tfile.readlines(): + * linelist = line.replace("nonself", str(nonselftrans)).replace("self", str(selftrans)).replace("\n", "").split("\t") # <<<<<<<<<<<<<< + * tmat[i][0] = math.log10(np.float(linelist[0])) + * tmat[i][1] = math.log10(np.float(linelist[1])) + */ + __pyx_k_tuple_3 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_3); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_1)); + PyTuple_SET_ITEM(__pyx_k_tuple_3, 0, ((PyObject *)__pyx_kp_s_1)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_1)); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_2)); + PyTuple_SET_ITEM(__pyx_k_tuple_3, 1, ((PyObject *)__pyx_kp_s_2)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_2)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_3)); + __pyx_k_tuple_5 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_5); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_4)); + PyTuple_SET_ITEM(__pyx_k_tuple_5, 0, ((PyObject *)__pyx_kp_s_4)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_4)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_5)); + + /* "trioToolsNew/hmmUtils.pyx":45 + * tfile = open(path, "r") + * for line in tfile.readlines(): + * linelist = line.replace("nonself", str(nonselftrans)).replace("self", str(selftrans)).replace("\n", "").split("\t") # <<<<<<<<<<<<<< + * tmat[i][0] = math.log10(np.float(linelist[0])) + * tmat[i][1] = math.log10(np.float(linelist[1])) + */ + __pyx_k_tuple_6 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_6); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_1)); + PyTuple_SET_ITEM(__pyx_k_tuple_6, 0, ((PyObject *)__pyx_kp_s_1)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_1)); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_2)); + PyTuple_SET_ITEM(__pyx_k_tuple_6, 1, ((PyObject *)__pyx_kp_s_2)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_2)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_6)); + __pyx_k_tuple_7 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_7); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_4)); + PyTuple_SET_ITEM(__pyx_k_tuple_7, 0, ((PyObject *)__pyx_kp_s_4)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_4)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_7)); + + /* "trioToolsNew/hmmUtils.pyx":57 + * else: + * print >> sys.stderr, "Error in hmmUtils.load_transition: Unknown sub-pedigree format: "+sub_ped + * exit(1) # <<<<<<<<<<<<<< + * + * #loads emission matrix for hmm + */ + __pyx_k_tuple_9 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_9); + __Pyx_INCREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_k_tuple_9, 0, __pyx_int_1); + __Pyx_GIVEREF(__pyx_int_1); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_9)); + + /* "trioToolsNew/hmmUtils.pyx":71 + * #alleles are in father, mother, child order + * #there are 12 allele assortments consistent with MIEs and one uniformly heterozygous position indicating possible compressions + * erprobG = np.float(err)/np.float(12) # <<<<<<<<<<<<<< + * goodprob = (1-np.float(err))/np.float(15) + * + */ + __pyx_k_tuple_10 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_10); + __Pyx_INCREF(__pyx_int_12); + PyTuple_SET_ITEM(__pyx_k_tuple_10, 0, __pyx_int_12); + __Pyx_GIVEREF(__pyx_int_12); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_10)); + + /* "trioToolsNew/hmmUtils.pyx":72 + * #there are 12 allele assortments consistent with MIEs and one uniformly heterozygous position indicating possible compressions + * erprobG = np.float(err)/np.float(12) + * goodprob = (1-np.float(err))/np.float(15) # <<<<<<<<<<<<<< + * + * erprobC = (1-np.float(comp))/np.float(26) + */ + __pyx_k_tuple_11 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_11); + __Pyx_INCREF(__pyx_int_15); + PyTuple_SET_ITEM(__pyx_k_tuple_11, 0, __pyx_int_15); + __Pyx_GIVEREF(__pyx_int_15); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_11)); + + /* "trioToolsNew/hmmUtils.pyx":74 + * goodprob = (1-np.float(err))/np.float(15) + * + * erprobC = (1-np.float(comp))/np.float(26) # <<<<<<<<<<<<<< + * + * erprobM = (1-np.float(mie))/np.float(15) + */ + __pyx_k_tuple_12 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_12); + __Pyx_INCREF(__pyx_int_26); + PyTuple_SET_ITEM(__pyx_k_tuple_12, 0, __pyx_int_26); + __Pyx_GIVEREF(__pyx_int_26); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_12)); + + /* "trioToolsNew/hmmUtils.pyx":76 + * erprobC = (1-np.float(comp))/np.float(26) + * + * erprobM = (1-np.float(mie))/np.float(15) # <<<<<<<<<<<<<< + * mieprob = np.float(mie)/np.float(12) + * + */ + __pyx_k_tuple_13 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_13); + __Pyx_INCREF(__pyx_int_15); + PyTuple_SET_ITEM(__pyx_k_tuple_13, 0, __pyx_int_15); + __Pyx_GIVEREF(__pyx_int_15); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_13)); + + /* "trioToolsNew/hmmUtils.pyx":77 + * + * erprobM = (1-np.float(mie))/np.float(15) + * mieprob = np.float(mie)/np.float(12) # <<<<<<<<<<<<<< + * + * i = 0 + */ + __pyx_k_tuple_14 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_14); + __Pyx_INCREF(__pyx_int_12); + PyTuple_SET_ITEM(__pyx_k_tuple_14, 0, __pyx_int_12); + __Pyx_GIVEREF(__pyx_int_12); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_14)); + + /* "trioToolsNew/hmmUtils.pyx":82 + * #0 is MIErich, 1 is compression, 2 is good data + * for line in efile.readlines(): + * linelist = line.replace("erprobM", str(erprobM)).replace("erprobG", str(erprobG)).replace("goodprob", str(goodprob)).replace("comprob", str(comp)).replace("erprobC", str(erprobC)).replace("mieprob", str(mieprob)).split("\t") # <<<<<<<<<<<<<< + * emat[0][i] = math.log10(np.float(linelist[2])) + * emat[1][i] = math.log10(np.float(linelist[3])) + */ + __pyx_k_tuple_15 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_15); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_4)); + PyTuple_SET_ITEM(__pyx_k_tuple_15, 0, ((PyObject *)__pyx_kp_s_4)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_4)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_15)); + + /* "trioToolsNew/hmmUtils.pyx":98 + * #alleles are in father, mother, child, child order + * #there are 52 allele assortments consistent with MIEs and one uniformly heterozygous position indicating possible compressions + * erprobHI = np.float(err)/np.float(65) # <<<<<<<<<<<<<< + * erprobID = np.float(err)/np.float(66) + * goodprobID = (1-np.float(err))/np.float(16) + */ + __pyx_k_tuple_16 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_16); + __Pyx_INCREF(__pyx_int_65); + PyTuple_SET_ITEM(__pyx_k_tuple_16, 0, __pyx_int_65); + __Pyx_GIVEREF(__pyx_int_65); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_16)); + + /* "trioToolsNew/hmmUtils.pyx":99 + * #there are 52 allele assortments consistent with MIEs and one uniformly heterozygous position indicating possible compressions + * erprobHI = np.float(err)/np.float(65) + * erprobID = np.float(err)/np.float(66) # <<<<<<<<<<<<<< + * goodprobID = (1-np.float(err))/np.float(16) + * goodprobHI = (1-np.float(err))/np.float(15) + */ + __pyx_k_tuple_17 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_17); + __Pyx_INCREF(__pyx_int_66); + PyTuple_SET_ITEM(__pyx_k_tuple_17, 0, __pyx_int_66); + __Pyx_GIVEREF(__pyx_int_66); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_17)); + + /* "trioToolsNew/hmmUtils.pyx":100 + * erprobHI = np.float(err)/np.float(65) + * erprobID = np.float(err)/np.float(66) + * goodprobID = (1-np.float(err))/np.float(16) # <<<<<<<<<<<<<< + * goodprobHI = (1-np.float(err))/np.float(15) + * + */ + __pyx_k_tuple_18 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_18); + __Pyx_INCREF(__pyx_int_16); + PyTuple_SET_ITEM(__pyx_k_tuple_18, 0, __pyx_int_16); + __Pyx_GIVEREF(__pyx_int_16); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_18)); + + /* "trioToolsNew/hmmUtils.pyx":101 + * erprobID = np.float(err)/np.float(66) + * goodprobID = (1-np.float(err))/np.float(16) + * goodprobHI = (1-np.float(err))/np.float(15) # <<<<<<<<<<<<<< + * + * erprobC = (1-np.float(comp))/np.float(80) + */ + __pyx_k_tuple_19 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_19); + __Pyx_INCREF(__pyx_int_15); + PyTuple_SET_ITEM(__pyx_k_tuple_19, 0, __pyx_int_15); + __Pyx_GIVEREF(__pyx_int_15); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_19)); + + /* "trioToolsNew/hmmUtils.pyx":103 + * goodprobHI = (1-np.float(err))/np.float(15) + * + * erprobC = (1-np.float(comp))/np.float(80) # <<<<<<<<<<<<<< + * + * erprobM = (1-np.float(mie))/np.float(29) + */ + __pyx_k_tuple_20 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_20); + __Pyx_INCREF(__pyx_int_80); + PyTuple_SET_ITEM(__pyx_k_tuple_20, 0, __pyx_int_80); + __Pyx_GIVEREF(__pyx_int_80); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_20)); + + /* "trioToolsNew/hmmUtils.pyx":105 + * erprobC = (1-np.float(comp))/np.float(80) + * + * erprobM = (1-np.float(mie))/np.float(29) # <<<<<<<<<<<<<< + * + * mieprob = np.float(mie)/np.float(52) + */ + __pyx_k_tuple_21 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_21); + __Pyx_INCREF(__pyx_int_29); + PyTuple_SET_ITEM(__pyx_k_tuple_21, 0, __pyx_int_29); + __Pyx_GIVEREF(__pyx_int_29); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_21)); + + /* "trioToolsNew/hmmUtils.pyx":107 + * erprobM = (1-np.float(mie))/np.float(29) + * + * mieprob = np.float(mie)/np.float(52) # <<<<<<<<<<<<<< + * + * i = 0 + */ + __pyx_k_tuple_22 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_22); + __Pyx_INCREF(__pyx_int_52); + PyTuple_SET_ITEM(__pyx_k_tuple_22, 0, __pyx_int_52); + __Pyx_GIVEREF(__pyx_int_52); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_22)); + + /* "trioToolsNew/hmmUtils.pyx":112 + * #0 is MIErich, 1 is compression, 2 is good data + * for line in efile.readlines(): + * linelist = line.replace("erprobM", str(erprobM)).replace("erprobHI", str(erprobHI)).replace("erprobID", str(erprobID)).replace("goodprobHI", str(goodprobHI)).replace("goodprobID", str(goodprobID)).replace("comprob", str(comp)).replace("erprobC", str(erprobC)).replace("mieprob", str(mieprob)).split("\t") # <<<<<<<<<<<<<< + * emat[0][i] = math.log10(np.float(linelist[2])) + * emat[1][i] = math.log10(np.float(linelist[3])) + */ + __pyx_k_tuple_23 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_23); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_4)); + PyTuple_SET_ITEM(__pyx_k_tuple_23, 0, ((PyObject *)__pyx_kp_s_4)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_4)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_23)); + + /* "trioToolsNew/hmmUtils.pyx":124 + * else: + * print >> sys.stderr, "Error in hmmUtils.load_emission: Unknown sub-pedigree format: "+sub_ped + * exit(1) # <<<<<<<<<<<<<< + * + * #creates array of observations + */ + __pyx_k_tuple_25 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_25)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_25); + __Pyx_INCREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_k_tuple_25, 0, __pyx_int_1); + __Pyx_GIVEREF(__pyx_int_1); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_25)); + + /* "trioToolsNew/hmmUtils.pyx":145 + * else: + * print >> sys.stderr, "Error in hmmUtils.input_map: Unknown sub-pedigree format: "+sub_ped + * exit(1) # <<<<<<<<<<<<<< + * + * trash = tempin.readline() + */ + __pyx_k_tuple_29 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_29); + __Pyx_INCREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_k_tuple_29, 0, __pyx_int_1); + __Pyx_GIVEREF(__pyx_int_1); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_29)); + + /* "trioToolsNew/hmmUtils.pyx":149 + * trash = tempin.readline() + * for line in tempin.readlines(): + * linelist = line.split("\t") # <<<<<<<<<<<<<< + * imap[linelist[1]] = linelist[0] + * return imap + */ + __pyx_k_tuple_30 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_30)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_30); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_4)); + PyTuple_SET_ITEM(__pyx_k_tuple_30, 0, ((PyObject *)__pyx_kp_s_4)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_4)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_30)); + + /* "trioToolsNew/hmmUtils.pyx":157 + * if sub_ped == "t": + * #distribute non-self transition probability to non-self states + * nprob = (1-np.float(sprob))/np.float(2) # <<<<<<<<<<<<<< + * + * #create matrices for HMM, all probabilities in log10 space to avoid underflow from np.floating point + */ + __pyx_k_tuple_31 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_31)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_31); + __Pyx_INCREF(__pyx_int_2); + PyTuple_SET_ITEM(__pyx_k_tuple_31, 0, __pyx_int_2); + __Pyx_GIVEREF(__pyx_int_2); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_31)); + + /* "trioToolsNew/hmmUtils.pyx":162 + * transmat = load_transition(mpath+"TransitionTrioGen.txt", sprob, nprob, "t") + * emitmat = load_emission(mpath+"EmissionTrioGen.txt", comp, mprob, errprob, "t") + * startp = np.array([math.log10(np.float(1)/np.float(3)), math.log10(np.float(1)/np.float(3)), math.log10(np.float(1)/np.float(3))]) # <<<<<<<<<<<<<< + * states = np.array([0, 1, 2]) + * inmap = input_map(mpath, "t") + */ + __pyx_k_tuple_33 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_33)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_33); + __Pyx_INCREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_k_tuple_33, 0, __pyx_int_1); + __Pyx_GIVEREF(__pyx_int_1); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_33)); + __pyx_k_tuple_34 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_34)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_34); + __Pyx_INCREF(__pyx_int_3); + PyTuple_SET_ITEM(__pyx_k_tuple_34, 0, __pyx_int_3); + __Pyx_GIVEREF(__pyx_int_3); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_34)); + __pyx_k_tuple_35 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_35)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_35); + __Pyx_INCREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_k_tuple_35, 0, __pyx_int_1); + __Pyx_GIVEREF(__pyx_int_1); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_35)); + __pyx_k_tuple_36 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_36)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_36); + __Pyx_INCREF(__pyx_int_3); + PyTuple_SET_ITEM(__pyx_k_tuple_36, 0, __pyx_int_3); + __Pyx_GIVEREF(__pyx_int_3); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_36)); + __pyx_k_tuple_37 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_37)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_37); + __Pyx_INCREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_k_tuple_37, 0, __pyx_int_1); + __Pyx_GIVEREF(__pyx_int_1); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_37)); + __pyx_k_tuple_38 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_38)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_38); + __Pyx_INCREF(__pyx_int_3); + PyTuple_SET_ITEM(__pyx_k_tuple_38, 0, __pyx_int_3); + __Pyx_GIVEREF(__pyx_int_3); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_38)); + + /* "trioToolsNew/hmmUtils.pyx":168 + * elif sub_ped == "q": + * #distribute non-self transition probability to non-self states + * nprob = (1-np.float(sprob))/np.float(5) # <<<<<<<<<<<<<< + * + * #create matrices for HMM, all probabilities in log10 space to avoid underflow from np.floating point + */ + __pyx_k_tuple_39 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_39)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_39); + __Pyx_INCREF(__pyx_int_5); + PyTuple_SET_ITEM(__pyx_k_tuple_39, 0, __pyx_int_5); + __Pyx_GIVEREF(__pyx_int_5); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_39)); + + /* "trioToolsNew/hmmUtils.pyx":173 + * transmat = load_transition(mpath+"TransitionQuartetGen.txt", sprob, nprob, "q") + * emitmat = load_emission(mpath+"EmissionQuartetGen.txt", comp, mprob, errprob, "q") + * startp = np.array([math.log10(np.float(1)/np.float(6)), math.log10(np.float(1)/np.float(6)), math.log10(np.float(1)/np.float(6)), math.log10(np.float(1)/np.float(6)), math.log10(np.float(1)/np.float(6)), math.log10(np.float(1)/np.float(6))]) # <<<<<<<<<<<<<< + * states = np.array([0, 1, 2, 3, 4, 5]) + * inmap = input_map(mpath, "q") + */ + __pyx_k_tuple_41 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_41)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_41); + __Pyx_INCREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_k_tuple_41, 0, __pyx_int_1); + __Pyx_GIVEREF(__pyx_int_1); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_41)); + __pyx_k_tuple_42 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_42)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_42); + __Pyx_INCREF(__pyx_int_6); + PyTuple_SET_ITEM(__pyx_k_tuple_42, 0, __pyx_int_6); + __Pyx_GIVEREF(__pyx_int_6); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_42)); + __pyx_k_tuple_43 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_43)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_43); + __Pyx_INCREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_k_tuple_43, 0, __pyx_int_1); + __Pyx_GIVEREF(__pyx_int_1); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_43)); + __pyx_k_tuple_44 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_44)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_44); + __Pyx_INCREF(__pyx_int_6); + PyTuple_SET_ITEM(__pyx_k_tuple_44, 0, __pyx_int_6); + __Pyx_GIVEREF(__pyx_int_6); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_44)); + __pyx_k_tuple_45 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_45)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_45); + __Pyx_INCREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_k_tuple_45, 0, __pyx_int_1); + __Pyx_GIVEREF(__pyx_int_1); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_45)); + __pyx_k_tuple_46 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_46)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_46); + __Pyx_INCREF(__pyx_int_6); + PyTuple_SET_ITEM(__pyx_k_tuple_46, 0, __pyx_int_6); + __Pyx_GIVEREF(__pyx_int_6); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_46)); + __pyx_k_tuple_47 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_47)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_47); + __Pyx_INCREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_k_tuple_47, 0, __pyx_int_1); + __Pyx_GIVEREF(__pyx_int_1); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_47)); + __pyx_k_tuple_48 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_48)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_48); + __Pyx_INCREF(__pyx_int_6); + PyTuple_SET_ITEM(__pyx_k_tuple_48, 0, __pyx_int_6); + __Pyx_GIVEREF(__pyx_int_6); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_48)); + __pyx_k_tuple_49 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_49)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_49); + __Pyx_INCREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_k_tuple_49, 0, __pyx_int_1); + __Pyx_GIVEREF(__pyx_int_1); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_49)); + __pyx_k_tuple_50 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_50)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_50); + __Pyx_INCREF(__pyx_int_6); + PyTuple_SET_ITEM(__pyx_k_tuple_50, 0, __pyx_int_6); + __Pyx_GIVEREF(__pyx_int_6); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_50)); + __pyx_k_tuple_51 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_51)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_51); + __Pyx_INCREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_k_tuple_51, 0, __pyx_int_1); + __Pyx_GIVEREF(__pyx_int_1); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_51)); + __pyx_k_tuple_52 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_52)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_52); + __Pyx_INCREF(__pyx_int_6); + PyTuple_SET_ITEM(__pyx_k_tuple_52, 0, __pyx_int_6); + __Pyx_GIVEREF(__pyx_int_6); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_52)); + + /* "trioToolsNew/hmmUtils.pyx":178 + * else: + * print >> sys.stderr, "Error in hmmUtils.make_hmm: Unknown sub-pedigree format: "+sub_ped + * exit(1) # <<<<<<<<<<<<<< + * return transmat, emitmat, startp, states, inmap + * + */ + __pyx_k_tuple_54 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_54)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_54); + __Pyx_INCREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_k_tuple_54, 0, __pyx_int_1); + __Pyx_GIVEREF(__pyx_int_1); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_54)); + + /* "numpy.pxd":215 + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): + * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + */ + __pyx_k_tuple_56 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_56)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_56); + __Pyx_INCREF(((PyObject *)__pyx_kp_u_55)); + PyTuple_SET_ITEM(__pyx_k_tuple_56, 0, ((PyObject *)__pyx_kp_u_55)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_55)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_56)); + + /* "numpy.pxd":219 + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): + * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< + * + * info.buf = PyArray_DATA(self) + */ + __pyx_k_tuple_58 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_58)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_58); + __Pyx_INCREF(((PyObject *)__pyx_kp_u_57)); + PyTuple_SET_ITEM(__pyx_k_tuple_58, 0, ((PyObject *)__pyx_kp_u_57)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_57)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_58)); + + /* "numpy.pxd":257 + * if ((descr.byteorder == c'>' and little_endian) or + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< + * if t == NPY_BYTE: f = "b" + * elif t == NPY_UBYTE: f = "B" + */ + __pyx_k_tuple_60 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_60)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_60); + __Pyx_INCREF(((PyObject *)__pyx_kp_u_59)); + PyTuple_SET_ITEM(__pyx_k_tuple_60, 0, ((PyObject *)__pyx_kp_u_59)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_59)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_60)); + + /* "numpy.pxd":799 + * + * if (end - f) - (new_offset - offset[0]) < 15: + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< + * + * if ((child.byteorder == c'>' and little_endian) or + */ + __pyx_k_tuple_63 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_63)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_63); + __Pyx_INCREF(((PyObject *)__pyx_kp_u_62)); + PyTuple_SET_ITEM(__pyx_k_tuple_63, 0, ((PyObject *)__pyx_kp_u_62)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_62)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_63)); + + /* "numpy.pxd":803 + * if ((child.byteorder == c'>' and little_endian) or + * (child.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< + * # One could encode it in the format string and have Cython + * # complain instead, BUT: < and > in format strings also imply + */ + __pyx_k_tuple_64 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_64)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_64); + __Pyx_INCREF(((PyObject *)__pyx_kp_u_59)); + PyTuple_SET_ITEM(__pyx_k_tuple_64, 0, ((PyObject *)__pyx_kp_u_59)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_59)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_64)); + + /* "numpy.pxd":823 + * t = child.type_num + * if end - f < 5: + * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< + * + * # Until ticket #99 is fixed, use integers to avoid warnings + */ + __pyx_k_tuple_66 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_66)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_66); + __Pyx_INCREF(((PyObject *)__pyx_kp_u_65)); + PyTuple_SET_ITEM(__pyx_k_tuple_66, 0, ((PyObject *)__pyx_kp_u_65)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_65)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_66)); + + /* "trioToolsNew/hmmUtils.pyx":23 + * + * #loads transition matrix + * def load_transition(path, selftrans, nonselftrans, sub_ped): # <<<<<<<<<<<<<< + * + * #trio case + */ + __pyx_k_tuple_67 = PyTuple_New(9); if (unlikely(!__pyx_k_tuple_67)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_67); + __Pyx_INCREF(((PyObject *)__pyx_n_s__path)); + PyTuple_SET_ITEM(__pyx_k_tuple_67, 0, ((PyObject *)__pyx_n_s__path)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__path)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__selftrans)); + PyTuple_SET_ITEM(__pyx_k_tuple_67, 1, ((PyObject *)__pyx_n_s__selftrans)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__selftrans)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__nonselftrans)); + PyTuple_SET_ITEM(__pyx_k_tuple_67, 2, ((PyObject *)__pyx_n_s__nonselftrans)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__nonselftrans)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__sub_ped)); + PyTuple_SET_ITEM(__pyx_k_tuple_67, 3, ((PyObject *)__pyx_n_s__sub_ped)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__sub_ped)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__tmat)); + PyTuple_SET_ITEM(__pyx_k_tuple_67, 4, ((PyObject *)__pyx_n_s__tmat)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__tmat)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__i)); + PyTuple_SET_ITEM(__pyx_k_tuple_67, 5, ((PyObject *)__pyx_n_s__i)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__i)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__tfile)); + PyTuple_SET_ITEM(__pyx_k_tuple_67, 6, ((PyObject *)__pyx_n_s__tfile)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__tfile)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__line)); + PyTuple_SET_ITEM(__pyx_k_tuple_67, 7, ((PyObject *)__pyx_n_s__line)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__line)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__linelist)); + PyTuple_SET_ITEM(__pyx_k_tuple_67, 8, ((PyObject *)__pyx_n_s__linelist)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__linelist)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_67)); + __pyx_k_codeobj_68 = (PyObject*)__Pyx_PyCode_New(4, 0, 9, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_67, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_69, __pyx_n_s__load_transition, 23, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_68)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "trioToolsNew/hmmUtils.pyx":60 + * + * #loads emission matrix for hmm + * def load_emission(path, comp, mie, err, sub_ped): # <<<<<<<<<<<<<< + * + * #trio case + */ + __pyx_k_tuple_71 = PyTuple_New(20); if (unlikely(!__pyx_k_tuple_71)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_71); + __Pyx_INCREF(((PyObject *)__pyx_n_s__path)); + PyTuple_SET_ITEM(__pyx_k_tuple_71, 0, ((PyObject *)__pyx_n_s__path)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__path)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__comp)); + PyTuple_SET_ITEM(__pyx_k_tuple_71, 1, ((PyObject *)__pyx_n_s__comp)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__comp)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__mie)); + PyTuple_SET_ITEM(__pyx_k_tuple_71, 2, ((PyObject *)__pyx_n_s__mie)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__mie)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__err)); + PyTuple_SET_ITEM(__pyx_k_tuple_71, 3, ((PyObject *)__pyx_n_s__err)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__err)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__sub_ped)); + PyTuple_SET_ITEM(__pyx_k_tuple_71, 4, ((PyObject *)__pyx_n_s__sub_ped)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__sub_ped)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__emat)); + PyTuple_SET_ITEM(__pyx_k_tuple_71, 5, ((PyObject *)__pyx_n_s__emat)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__emat)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__efile)); + PyTuple_SET_ITEM(__pyx_k_tuple_71, 6, ((PyObject *)__pyx_n_s__efile)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__efile)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__trash)); + PyTuple_SET_ITEM(__pyx_k_tuple_71, 7, ((PyObject *)__pyx_n_s__trash)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__trash)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__erprobG)); + PyTuple_SET_ITEM(__pyx_k_tuple_71, 8, ((PyObject *)__pyx_n_s__erprobG)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__erprobG)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__goodprob)); + PyTuple_SET_ITEM(__pyx_k_tuple_71, 9, ((PyObject *)__pyx_n_s__goodprob)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__goodprob)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__erprobC)); + PyTuple_SET_ITEM(__pyx_k_tuple_71, 10, ((PyObject *)__pyx_n_s__erprobC)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__erprobC)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__erprobM)); + PyTuple_SET_ITEM(__pyx_k_tuple_71, 11, ((PyObject *)__pyx_n_s__erprobM)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__erprobM)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__mieprob)); + PyTuple_SET_ITEM(__pyx_k_tuple_71, 12, ((PyObject *)__pyx_n_s__mieprob)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__mieprob)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__i)); + PyTuple_SET_ITEM(__pyx_k_tuple_71, 13, ((PyObject *)__pyx_n_s__i)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__i)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__line)); + PyTuple_SET_ITEM(__pyx_k_tuple_71, 14, ((PyObject *)__pyx_n_s__line)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__line)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__linelist)); + PyTuple_SET_ITEM(__pyx_k_tuple_71, 15, ((PyObject *)__pyx_n_s__linelist)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__linelist)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__erprobHI)); + PyTuple_SET_ITEM(__pyx_k_tuple_71, 16, ((PyObject *)__pyx_n_s__erprobHI)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__erprobHI)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__erprobID)); + PyTuple_SET_ITEM(__pyx_k_tuple_71, 17, ((PyObject *)__pyx_n_s__erprobID)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__erprobID)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__goodprobID)); + PyTuple_SET_ITEM(__pyx_k_tuple_71, 18, ((PyObject *)__pyx_n_s__goodprobID)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__goodprobID)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__goodprobHI)); + PyTuple_SET_ITEM(__pyx_k_tuple_71, 19, ((PyObject *)__pyx_n_s__goodprobHI)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__goodprobHI)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_71)); + __pyx_k_codeobj_72 = (PyObject*)__Pyx_PyCode_New(5, 0, 20, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_71, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_69, __pyx_n_s__load_emission, 60, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_72)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "trioToolsNew/hmmUtils.pyx":127 + * + * #creates array of observations + * def makeobs_set(numsubj): # <<<<<<<<<<<<<< + * obs = [] + * n_assort = 3**numsubj + */ + __pyx_k_tuple_73 = PyTuple_New(4); if (unlikely(!__pyx_k_tuple_73)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_73); + __Pyx_INCREF(((PyObject *)__pyx_n_s__numsubj)); + PyTuple_SET_ITEM(__pyx_k_tuple_73, 0, ((PyObject *)__pyx_n_s__numsubj)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__numsubj)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__obs)); + PyTuple_SET_ITEM(__pyx_k_tuple_73, 1, ((PyObject *)__pyx_n_s__obs)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__obs)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__n_assort)); + PyTuple_SET_ITEM(__pyx_k_tuple_73, 2, ((PyObject *)__pyx_n_s__n_assort)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n_assort)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__i)); + PyTuple_SET_ITEM(__pyx_k_tuple_73, 3, ((PyObject *)__pyx_n_s__i)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__i)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_73)); + __pyx_k_codeobj_74 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_73, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_69, __pyx_n_s__makeobs_set, 127, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_74)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "trioToolsNew/hmmUtils.pyx":135 + * + * #returns map of allele assortments to allele codes for hmm, allele order father, mother, child + * def input_map(path_efile, sub_ped): # <<<<<<<<<<<<<< + * imap = {} + * + */ + __pyx_k_tuple_75 = PyTuple_New(7); if (unlikely(!__pyx_k_tuple_75)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_75); + __Pyx_INCREF(((PyObject *)__pyx_n_s__path_efile)); + PyTuple_SET_ITEM(__pyx_k_tuple_75, 0, ((PyObject *)__pyx_n_s__path_efile)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__path_efile)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__sub_ped)); + PyTuple_SET_ITEM(__pyx_k_tuple_75, 1, ((PyObject *)__pyx_n_s__sub_ped)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__sub_ped)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__imap)); + PyTuple_SET_ITEM(__pyx_k_tuple_75, 2, ((PyObject *)__pyx_n_s__imap)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__imap)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__tempin)); + PyTuple_SET_ITEM(__pyx_k_tuple_75, 3, ((PyObject *)__pyx_n_s__tempin)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__tempin)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__trash)); + PyTuple_SET_ITEM(__pyx_k_tuple_75, 4, ((PyObject *)__pyx_n_s__trash)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__trash)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__line)); + PyTuple_SET_ITEM(__pyx_k_tuple_75, 5, ((PyObject *)__pyx_n_s__line)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__line)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__linelist)); + PyTuple_SET_ITEM(__pyx_k_tuple_75, 6, ((PyObject *)__pyx_n_s__linelist)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__linelist)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_75)); + __pyx_k_codeobj_76 = (PyObject*)__Pyx_PyCode_New(2, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_75, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_69, __pyx_n_s__input_map, 135, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_76)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "trioToolsNew/hmmUtils.pyx":154 + * + * #creates and returns as a tuple emission, transition, start, state, and observation matrices + * def make_hmm(mpath, sprob, comp, mprob, errprob, sub_ped): # <<<<<<<<<<<<<< + * if sub_ped == "t": + * #distribute non-self transition probability to non-self states + */ + __pyx_k_tuple_77 = PyTuple_New(12); if (unlikely(!__pyx_k_tuple_77)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_77); + __Pyx_INCREF(((PyObject *)__pyx_n_s__mpath)); + PyTuple_SET_ITEM(__pyx_k_tuple_77, 0, ((PyObject *)__pyx_n_s__mpath)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__mpath)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__sprob)); + PyTuple_SET_ITEM(__pyx_k_tuple_77, 1, ((PyObject *)__pyx_n_s__sprob)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__sprob)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__comp)); + PyTuple_SET_ITEM(__pyx_k_tuple_77, 2, ((PyObject *)__pyx_n_s__comp)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__comp)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__mprob)); + PyTuple_SET_ITEM(__pyx_k_tuple_77, 3, ((PyObject *)__pyx_n_s__mprob)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__mprob)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__errprob)); + PyTuple_SET_ITEM(__pyx_k_tuple_77, 4, ((PyObject *)__pyx_n_s__errprob)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__errprob)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__sub_ped)); + PyTuple_SET_ITEM(__pyx_k_tuple_77, 5, ((PyObject *)__pyx_n_s__sub_ped)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__sub_ped)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__nprob)); + PyTuple_SET_ITEM(__pyx_k_tuple_77, 6, ((PyObject *)__pyx_n_s__nprob)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__nprob)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__transmat)); + PyTuple_SET_ITEM(__pyx_k_tuple_77, 7, ((PyObject *)__pyx_n_s__transmat)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__transmat)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__emitmat)); + PyTuple_SET_ITEM(__pyx_k_tuple_77, 8, ((PyObject *)__pyx_n_s__emitmat)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__emitmat)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__startp)); + PyTuple_SET_ITEM(__pyx_k_tuple_77, 9, ((PyObject *)__pyx_n_s__startp)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__startp)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__states)); + PyTuple_SET_ITEM(__pyx_k_tuple_77, 10, ((PyObject *)__pyx_n_s__states)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__states)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__inmap)); + PyTuple_SET_ITEM(__pyx_k_tuple_77, 11, ((PyObject *)__pyx_n_s__inmap)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__inmap)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_77)); + __pyx_k_codeobj_78 = (PyObject*)__Pyx_PyCode_New(6, 0, 12, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_77, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_69, __pyx_n_s__make_hmm, 154, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_78)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "trioToolsNew/hmmUtils.pyx":182 + * + * #uses sums of log-transformed probabilities to avoid np.floating point underflow problems + * def viterbi(np.ndarray[DTYPEi_t] obs, np.ndarray[DTYPEi_t] states, np.ndarray[DTYPEf_t] start_p, np.ndarray[DTYPEf_t, ndim = 2] trans_p, np.ndarray[DTYPEf_t, ndim = 2] emit_p): # <<<<<<<<<<<<<< + * cdef int y, y0, t, state + * cdef double prob + */ + __pyx_k_tuple_79 = PyTuple_New(12); if (unlikely(!__pyx_k_tuple_79)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_79); + __Pyx_INCREF(((PyObject *)__pyx_n_s__obs)); + PyTuple_SET_ITEM(__pyx_k_tuple_79, 0, ((PyObject *)__pyx_n_s__obs)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__obs)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__states)); + PyTuple_SET_ITEM(__pyx_k_tuple_79, 1, ((PyObject *)__pyx_n_s__states)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__states)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__start_p)); + PyTuple_SET_ITEM(__pyx_k_tuple_79, 2, ((PyObject *)__pyx_n_s__start_p)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__start_p)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__trans_p)); + PyTuple_SET_ITEM(__pyx_k_tuple_79, 3, ((PyObject *)__pyx_n_s__trans_p)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__trans_p)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__emit_p)); + PyTuple_SET_ITEM(__pyx_k_tuple_79, 4, ((PyObject *)__pyx_n_s__emit_p)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__emit_p)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__y)); + PyTuple_SET_ITEM(__pyx_k_tuple_79, 5, ((PyObject *)__pyx_n_s__y)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__y)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__y0)); + PyTuple_SET_ITEM(__pyx_k_tuple_79, 6, ((PyObject *)__pyx_n_s__y0)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__y0)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__t)); + PyTuple_SET_ITEM(__pyx_k_tuple_79, 7, ((PyObject *)__pyx_n_s__t)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__t)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__state)); + PyTuple_SET_ITEM(__pyx_k_tuple_79, 8, ((PyObject *)__pyx_n_s__state)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__state)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__prob)); + PyTuple_SET_ITEM(__pyx_k_tuple_79, 9, ((PyObject *)__pyx_n_s__prob)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__prob)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__V)); + PyTuple_SET_ITEM(__pyx_k_tuple_79, 10, ((PyObject *)__pyx_n_s__V)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__V)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__path)); + PyTuple_SET_ITEM(__pyx_k_tuple_79, 11, ((PyObject *)__pyx_n_s__path)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__path)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_79)); + __pyx_k_codeobj_80 = (PyObject*)__Pyx_PyCode_New(5, 0, 12, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_79, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_69, __pyx_n_s__viterbi, 182, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_80)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_RefNannyFinishContext(); + return 0; + __pyx_L1_error:; + __Pyx_RefNannyFinishContext(); + return -1; +} + +static int __Pyx_InitGlobals(void) { + if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_int_4 = PyInt_FromLong(4); if (unlikely(!__pyx_int_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_int_5 = PyInt_FromLong(5); if (unlikely(!__pyx_int_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_int_6 = PyInt_FromLong(6); if (unlikely(!__pyx_int_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_int_12 = PyInt_FromLong(12); if (unlikely(!__pyx_int_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_int_15 = PyInt_FromLong(15); if (unlikely(!__pyx_int_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_int_16 = PyInt_FromLong(16); if (unlikely(!__pyx_int_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_int_26 = PyInt_FromLong(26); if (unlikely(!__pyx_int_26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_int_27 = PyInt_FromLong(27); if (unlikely(!__pyx_int_27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_int_29 = PyInt_FromLong(29); if (unlikely(!__pyx_int_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_int_52 = PyInt_FromLong(52); if (unlikely(!__pyx_int_52)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_int_65 = PyInt_FromLong(65); if (unlikely(!__pyx_int_65)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_int_66 = PyInt_FromLong(66); if (unlikely(!__pyx_int_66)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_int_80 = PyInt_FromLong(80); if (unlikely(!__pyx_int_80)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_int_81 = PyInt_FromLong(81); if (unlikely(!__pyx_int_81)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + return 0; + __pyx_L1_error:; + return -1; +} + +#if PY_MAJOR_VERSION < 3 +PyMODINIT_FUNC inithmmUtils(void); /*proto*/ +PyMODINIT_FUNC inithmmUtils(void) +#else +PyMODINIT_FUNC PyInit_hmmUtils(void); /*proto*/ +PyMODINIT_FUNC PyInit_hmmUtils(void) +#endif +{ + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannyDeclarations + #if CYTHON_REFNANNY + __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); + if (!__Pyx_RefNanny) { + PyErr_Clear(); + __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); + if (!__Pyx_RefNanny) + Py_FatalError("failed to import 'refnanny' module"); + } + #endif + __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_hmmUtils(void)", 0); + if ( __Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #ifdef __Pyx_CyFunction_USED + if (__Pyx_CyFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + #ifdef __Pyx_FusedFunction_USED + if (__pyx_FusedFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + #ifdef __Pyx_Generator_USED + if (__pyx_Generator_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + /*--- Library function declarations ---*/ + /*--- Threads initialization code ---*/ + #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS + #ifdef WITH_THREAD /* Python build with threading support? */ + PyEval_InitThreads(); + #endif + #endif + /*--- Module creation code ---*/ + #if PY_MAJOR_VERSION < 3 + __pyx_m = Py_InitModule4(__Pyx_NAMESTR("hmmUtils"), __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); + #else + __pyx_m = PyModule_Create(&__pyx_moduledef); + #endif + if (unlikely(!__pyx_m)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME)); if (unlikely(!__pyx_b)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #if CYTHON_COMPILING_IN_PYPY + Py_INCREF(__pyx_b); + #endif + if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + /*--- Initialize various global constants etc. ---*/ + if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__pyx_module_is_main_trioToolsNew__hmmUtils) { + if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s____main__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + } + /*--- Builtin init code ---*/ + if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + /*--- Constants init code ---*/ + if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + /*--- Global init code ---*/ + /*--- Variable export code ---*/ + /*--- Function export code ---*/ + /*--- Type init code ---*/ + /*--- Type import code ---*/ + __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type", + #if CYTHON_COMPILING_IN_PYPY + sizeof(PyTypeObject), + #else + sizeof(PyHeapTypeObject), + #endif + 0); if (unlikely(!__pyx_ptype_7cpython_4type_type)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr), 0); if (unlikely(!__pyx_ptype_5numpy_dtype)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5numpy_flatiter = __Pyx_ImportType("numpy", "flatiter", sizeof(PyArrayIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_flatiter)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5numpy_broadcast = __Pyx_ImportType("numpy", "broadcast", sizeof(PyArrayMultiIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_broadcast)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject), 0); if (unlikely(!__pyx_ptype_5numpy_ndarray)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5numpy_ufunc = __Pyx_ImportType("numpy", "ufunc", sizeof(PyUFuncObject), 0); if (unlikely(!__pyx_ptype_5numpy_ufunc)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 861; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + /*--- Variable import code ---*/ + /*--- Function import code ---*/ + /*--- Execution code ---*/ + + /* "trioToolsNew/hmmUtils.pyx":7 + * #usage: Cython internal toolset for HMM + * + * import sys # <<<<<<<<<<<<<< + * import os + * import re + */ + __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__sys), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (PyObject_SetAttr(__pyx_m, __pyx_n_s__sys, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "trioToolsNew/hmmUtils.pyx":8 + * + * import sys + * import os # <<<<<<<<<<<<<< + * import re + * import fileinput + */ + __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__os), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (PyObject_SetAttr(__pyx_m, __pyx_n_s__os, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "trioToolsNew/hmmUtils.pyx":9 + * import sys + * import os + * import re # <<<<<<<<<<<<<< + * import fileinput + * import getopt + */ + __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__re), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (PyObject_SetAttr(__pyx_m, __pyx_n_s__re, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "trioToolsNew/hmmUtils.pyx":10 + * import os + * import re + * import fileinput # <<<<<<<<<<<<<< + * import getopt + * import argparse + */ + __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__fileinput), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (PyObject_SetAttr(__pyx_m, __pyx_n_s__fileinput, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "trioToolsNew/hmmUtils.pyx":11 + * import re + * import fileinput + * import getopt # <<<<<<<<<<<<<< + * import argparse + * import numpy as np + */ + __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__getopt), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (PyObject_SetAttr(__pyx_m, __pyx_n_s__getopt, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "trioToolsNew/hmmUtils.pyx":12 + * import fileinput + * import getopt + * import argparse # <<<<<<<<<<<<<< + * import numpy as np + * cimport numpy as np + */ + __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__argparse), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (PyObject_SetAttr(__pyx_m, __pyx_n_s__argparse, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "trioToolsNew/hmmUtils.pyx":13 + * import getopt + * import argparse + * import numpy as np # <<<<<<<<<<<<<< + * cimport numpy as np + * import math + */ + __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__numpy), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (PyObject_SetAttr(__pyx_m, __pyx_n_s__np, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "trioToolsNew/hmmUtils.pyx":15 + * import numpy as np + * cimport numpy as np + * import math # <<<<<<<<<<<<<< + * + * DTYPEf = np.float + */ + __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__math), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (PyObject_SetAttr(__pyx_m, __pyx_n_s__math, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "trioToolsNew/hmmUtils.pyx":17 + * import math + * + * DTYPEf = np.float # <<<<<<<<<<<<<< + * DTYPEi = np.int + * ctypedef np.float_t DTYPEf_t + */ + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__float); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (PyObject_SetAttr(__pyx_m, __pyx_n_s__DTYPEf, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "trioToolsNew/hmmUtils.pyx":18 + * + * DTYPEf = np.float + * DTYPEi = np.int # <<<<<<<<<<<<<< + * ctypedef np.float_t DTYPEf_t + * ctypedef np.int_t DTYPEi_t + */ + __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__int); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + if (PyObject_SetAttr(__pyx_m, __pyx_n_s__DTYPEi, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "trioToolsNew/hmmUtils.pyx":23 + * + * #loads transition matrix + * def load_transition(path, selftrans, nonselftrans, sub_ped): # <<<<<<<<<<<<<< + * + * #trio case + */ + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_12trioToolsNew_8hmmUtils_1load_transition, NULL, __pyx_n_s_70); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (PyObject_SetAttr(__pyx_m, __pyx_n_s__load_transition, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "trioToolsNew/hmmUtils.pyx":60 + * + * #loads emission matrix for hmm + * def load_emission(path, comp, mie, err, sub_ped): # <<<<<<<<<<<<<< + * + * #trio case + */ + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_12trioToolsNew_8hmmUtils_3load_emission, NULL, __pyx_n_s_70); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (PyObject_SetAttr(__pyx_m, __pyx_n_s__load_emission, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "trioToolsNew/hmmUtils.pyx":127 + * + * #creates array of observations + * def makeobs_set(numsubj): # <<<<<<<<<<<<<< + * obs = [] + * n_assort = 3**numsubj + */ + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_12trioToolsNew_8hmmUtils_5makeobs_set, NULL, __pyx_n_s_70); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (PyObject_SetAttr(__pyx_m, __pyx_n_s__makeobs_set, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "trioToolsNew/hmmUtils.pyx":135 + * + * #returns map of allele assortments to allele codes for hmm, allele order father, mother, child + * def input_map(path_efile, sub_ped): # <<<<<<<<<<<<<< + * imap = {} + * + */ + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_12trioToolsNew_8hmmUtils_7input_map, NULL, __pyx_n_s_70); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (PyObject_SetAttr(__pyx_m, __pyx_n_s__input_map, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "trioToolsNew/hmmUtils.pyx":154 + * + * #creates and returns as a tuple emission, transition, start, state, and observation matrices + * def make_hmm(mpath, sprob, comp, mprob, errprob, sub_ped): # <<<<<<<<<<<<<< + * if sub_ped == "t": + * #distribute non-self transition probability to non-self states + */ + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_12trioToolsNew_8hmmUtils_9make_hmm, NULL, __pyx_n_s_70); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (PyObject_SetAttr(__pyx_m, __pyx_n_s__make_hmm, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "trioToolsNew/hmmUtils.pyx":182 + * + * #uses sums of log-transformed probabilities to avoid np.floating point underflow problems + * def viterbi(np.ndarray[DTYPEi_t] obs, np.ndarray[DTYPEi_t] states, np.ndarray[DTYPEf_t] start_p, np.ndarray[DTYPEf_t, ndim = 2] trans_p, np.ndarray[DTYPEf_t, ndim = 2] emit_p): # <<<<<<<<<<<<<< + * cdef int y, y0, t, state + * cdef double prob + */ + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_12trioToolsNew_8hmmUtils_11viterbi, NULL, __pyx_n_s_70); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (PyObject_SetAttr(__pyx_m, __pyx_n_s__viterbi, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "trioToolsNew/hmmUtils.pyx":1 + * #!/usr/bin/env python # <<<<<<<<<<<<<< + * #Rick Dewey 8.14.12 + * #Last modified 8.14.12 Rick Dewey for Cython + */ + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_1)); + if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + + /* "numpy.pxd":975 + * arr.base = baseptr + * + * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< + * if arr.base is NULL: + * return None + */ + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + if (__pyx_m) { + __Pyx_AddTraceback("init trioToolsNew.hmmUtils", __pyx_clineno, __pyx_lineno, __pyx_filename); + Py_DECREF(__pyx_m); __pyx_m = 0; + } else if (!PyErr_Occurred()) { + PyErr_SetString(PyExc_ImportError, "init trioToolsNew.hmmUtils"); + } + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + #if PY_MAJOR_VERSION < 3 + return; + #else + return __pyx_m; + #endif +} + +/* Runtime support code */ +#if CYTHON_REFNANNY +static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { + PyObject *m = NULL, *p = NULL; + void *r = NULL; + m = PyImport_ImportModule((char *)modname); + if (!m) goto end; + p = PyObject_GetAttrString(m, (char *)"RefNannyAPI"); + if (!p) goto end; + r = PyLong_AsVoidPtr(p); +end: + Py_XDECREF(p); + Py_XDECREF(m); + return (__Pyx_RefNannyAPIStruct *)r; +} +#endif /* CYTHON_REFNANNY */ + +static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) { + PyObject *result; + result = PyObject_GetAttr(dict, name); + if (!result) { + if (dict != __pyx_b) { + PyErr_Clear(); + result = PyObject_GetAttr(__pyx_b, name); + } + if (!result) { + PyErr_SetObject(PyExc_NameError, name); + } + } + return result; +} + +static void __Pyx_RaiseArgtupleInvalid( + const char* func_name, + int exact, + Py_ssize_t num_min, + Py_ssize_t num_max, + Py_ssize_t num_found) +{ + Py_ssize_t num_expected; + const char *more_or_less; + if (num_found < num_min) { + num_expected = num_min; + more_or_less = "at least"; + } else { + num_expected = num_max; + more_or_less = "at most"; + } + if (exact) { + more_or_less = "exactly"; + } + PyErr_Format(PyExc_TypeError, + "%s() takes %s %" CYTHON_FORMAT_SSIZE_T "d positional argument%s (%" CYTHON_FORMAT_SSIZE_T "d given)", + func_name, more_or_less, num_expected, + (num_expected == 1) ? "" : "s", num_found); +} + +static void __Pyx_RaiseDoubleKeywordsError( + const char* func_name, + PyObject* kw_name) +{ + PyErr_Format(PyExc_TypeError, + #if PY_MAJOR_VERSION >= 3 + "%s() got multiple values for keyword argument '%U'", func_name, kw_name); + #else + "%s() got multiple values for keyword argument '%s'", func_name, + PyString_AsString(kw_name)); + #endif +} + +static int __Pyx_ParseOptionalKeywords( + PyObject *kwds, + PyObject **argnames[], + PyObject *kwds2, + PyObject *values[], + Py_ssize_t num_pos_args, + const char* function_name) +{ + PyObject *key = 0, *value = 0; + Py_ssize_t pos = 0; + PyObject*** name; + PyObject*** first_kw_arg = argnames + num_pos_args; + while (PyDict_Next(kwds, &pos, &key, &value)) { + name = first_kw_arg; + while (*name && (**name != key)) name++; + if (*name) { + values[name-argnames] = value; + continue; + } + name = first_kw_arg; + #if PY_MAJOR_VERSION < 3 + if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) { + while (*name) { + if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) + && _PyString_Eq(**name, key)) { + values[name-argnames] = value; + break; + } + name++; + } + if (*name) continue; + else { + PyObject*** argname = argnames; + while (argname != first_kw_arg) { + if ((**argname == key) || ( + (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) + && _PyString_Eq(**argname, key))) { + goto arg_passed_twice; + } + argname++; + } + } + } else + #endif + if (likely(PyUnicode_Check(key))) { + while (*name) { + int cmp = (**name == key) ? 0 : + #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 + (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 : + #endif + PyUnicode_Compare(**name, key); + if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; + if (cmp == 0) { + values[name-argnames] = value; + break; + } + name++; + } + if (*name) continue; + else { + PyObject*** argname = argnames; + while (argname != first_kw_arg) { + int cmp = (**argname == key) ? 0 : + #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 + (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 : + #endif + PyUnicode_Compare(**argname, key); + if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; + if (cmp == 0) goto arg_passed_twice; + argname++; + } + } + } else + goto invalid_keyword_type; + if (kwds2) { + if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; + } else { + goto invalid_keyword; + } + } + return 0; +arg_passed_twice: + __Pyx_RaiseDoubleKeywordsError(function_name, key); + goto bad; +invalid_keyword_type: + PyErr_Format(PyExc_TypeError, + "%s() keywords must be strings", function_name); + goto bad; +invalid_keyword: + PyErr_Format(PyExc_TypeError, + #if PY_MAJOR_VERSION < 3 + "%s() got an unexpected keyword argument '%s'", + function_name, PyString_AsString(key)); + #else + "%s() got an unexpected keyword argument '%U'", + function_name, key); + #endif +bad: + return -1; +} + +static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) { + PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname); +} + +static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, + const char *name, int exact) +{ + if (!type) { + PyErr_Format(PyExc_SystemError, "Missing type object"); + return 0; + } + if (none_allowed && obj == Py_None) return 1; + else if (exact) { + if (Py_TYPE(obj) == type) return 1; + } + else { + if (PyObject_TypeCheck(obj, type)) return 1; + } + PyErr_Format(PyExc_TypeError, + "Argument '%s' has incorrect type (expected %s, got %s)", + name, type->tp_name, Py_TYPE(obj)->tp_name); + return 0; +} + +static CYTHON_INLINE int __Pyx_IsLittleEndian(void) { + unsigned int n = 1; + return *(unsigned char*)(&n) != 0; +} +static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx, + __Pyx_BufFmt_StackElem* stack, + __Pyx_TypeInfo* type) { + stack[0].field = &ctx->root; + stack[0].parent_offset = 0; + ctx->root.type = type; + ctx->root.name = "buffer dtype"; + ctx->root.offset = 0; + ctx->head = stack; + ctx->head->field = &ctx->root; + ctx->fmt_offset = 0; + ctx->head->parent_offset = 0; + ctx->new_packmode = '@'; + ctx->enc_packmode = '@'; + ctx->new_count = 1; + ctx->enc_count = 0; + ctx->enc_type = 0; + ctx->is_complex = 0; + ctx->is_valid_array = 0; + ctx->struct_alignment = 0; + while (type->typegroup == 'S') { + ++ctx->head; + ctx->head->field = type->fields; + ctx->head->parent_offset = 0; + type = type->fields->type; + } +} +static int __Pyx_BufFmt_ParseNumber(const char** ts) { + int count; + const char* t = *ts; + if (*t < '0' || *t > '9') { + return -1; + } else { + count = *t++ - '0'; + while (*t >= '0' && *t < '9') { + count *= 10; + count += *t++ - '0'; + } + } + *ts = t; + return count; +} +static int __Pyx_BufFmt_ExpectNumber(const char **ts) { + int number = __Pyx_BufFmt_ParseNumber(ts); + if (number == -1) /* First char was not a digit */ + PyErr_Format(PyExc_ValueError,\ + "Does not understand character buffer dtype format string ('%c')", **ts); + return number; +} +static void __Pyx_BufFmt_RaiseUnexpectedChar(char ch) { + PyErr_Format(PyExc_ValueError, + "Unexpected format string character: '%c'", ch); +} +static const char* __Pyx_BufFmt_DescribeTypeChar(char ch, int is_complex) { + switch (ch) { + case 'c': return "'char'"; + case 'b': return "'signed char'"; + case 'B': return "'unsigned char'"; + case 'h': return "'short'"; + case 'H': return "'unsigned short'"; + case 'i': return "'int'"; + case 'I': return "'unsigned int'"; + case 'l': return "'long'"; + case 'L': return "'unsigned long'"; + case 'q': return "'long long'"; + case 'Q': return "'unsigned long long'"; + case 'f': return (is_complex ? "'complex float'" : "'float'"); + case 'd': return (is_complex ? "'complex double'" : "'double'"); + case 'g': return (is_complex ? "'complex long double'" : "'long double'"); + case 'T': return "a struct"; + case 'O': return "Python object"; + case 'P': return "a pointer"; + case 's': case 'p': return "a string"; + case 0: return "end"; + default: return "unparseable format string"; + } +} +static size_t __Pyx_BufFmt_TypeCharToStandardSize(char ch, int is_complex) { + switch (ch) { + case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; + case 'h': case 'H': return 2; + case 'i': case 'I': case 'l': case 'L': return 4; + case 'q': case 'Q': return 8; + case 'f': return (is_complex ? 8 : 4); + case 'd': return (is_complex ? 16 : 8); + case 'g': { + PyErr_SetString(PyExc_ValueError, "Python does not define a standard format string size for long double ('g').."); + return 0; + } + case 'O': case 'P': return sizeof(void*); + default: + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } +} +static size_t __Pyx_BufFmt_TypeCharToNativeSize(char ch, int is_complex) { + switch (ch) { + case 'c': case 'b': case 'B': case 's': case 'p': return 1; + case 'h': case 'H': return sizeof(short); + case 'i': case 'I': return sizeof(int); + case 'l': case 'L': return sizeof(long); + #ifdef HAVE_LONG_LONG + case 'q': case 'Q': return sizeof(PY_LONG_LONG); + #endif + case 'f': return sizeof(float) * (is_complex ? 2 : 1); + case 'd': return sizeof(double) * (is_complex ? 2 : 1); + case 'g': return sizeof(long double) * (is_complex ? 2 : 1); + case 'O': case 'P': return sizeof(void*); + default: { + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } + } +} +typedef struct { char c; short x; } __Pyx_st_short; +typedef struct { char c; int x; } __Pyx_st_int; +typedef struct { char c; long x; } __Pyx_st_long; +typedef struct { char c; float x; } __Pyx_st_float; +typedef struct { char c; double x; } __Pyx_st_double; +typedef struct { char c; long double x; } __Pyx_st_longdouble; +typedef struct { char c; void *x; } __Pyx_st_void_p; +#ifdef HAVE_LONG_LONG +typedef struct { char c; PY_LONG_LONG x; } __Pyx_st_longlong; +#endif +static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, CYTHON_UNUSED int is_complex) { + switch (ch) { + case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; + case 'h': case 'H': return sizeof(__Pyx_st_short) - sizeof(short); + case 'i': case 'I': return sizeof(__Pyx_st_int) - sizeof(int); + case 'l': case 'L': return sizeof(__Pyx_st_long) - sizeof(long); +#ifdef HAVE_LONG_LONG + case 'q': case 'Q': return sizeof(__Pyx_st_longlong) - sizeof(PY_LONG_LONG); +#endif + case 'f': return sizeof(__Pyx_st_float) - sizeof(float); + case 'd': return sizeof(__Pyx_st_double) - sizeof(double); + case 'g': return sizeof(__Pyx_st_longdouble) - sizeof(long double); + case 'P': case 'O': return sizeof(__Pyx_st_void_p) - sizeof(void*); + default: + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } +} +/* These are for computing the padding at the end of the struct to align + on the first member of the struct. This will probably the same as above, + but we don't have any guarantees. + */ +typedef struct { short x; char c; } __Pyx_pad_short; +typedef struct { int x; char c; } __Pyx_pad_int; +typedef struct { long x; char c; } __Pyx_pad_long; +typedef struct { float x; char c; } __Pyx_pad_float; +typedef struct { double x; char c; } __Pyx_pad_double; +typedef struct { long double x; char c; } __Pyx_pad_longdouble; +typedef struct { void *x; char c; } __Pyx_pad_void_p; +#ifdef HAVE_LONG_LONG +typedef struct { PY_LONG_LONG x; char c; } __Pyx_pad_longlong; +#endif +static size_t __Pyx_BufFmt_TypeCharToPadding(char ch, CYTHON_UNUSED int is_complex) { + switch (ch) { + case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; + case 'h': case 'H': return sizeof(__Pyx_pad_short) - sizeof(short); + case 'i': case 'I': return sizeof(__Pyx_pad_int) - sizeof(int); + case 'l': case 'L': return sizeof(__Pyx_pad_long) - sizeof(long); +#ifdef HAVE_LONG_LONG + case 'q': case 'Q': return sizeof(__Pyx_pad_longlong) - sizeof(PY_LONG_LONG); +#endif + case 'f': return sizeof(__Pyx_pad_float) - sizeof(float); + case 'd': return sizeof(__Pyx_pad_double) - sizeof(double); + case 'g': return sizeof(__Pyx_pad_longdouble) - sizeof(long double); + case 'P': case 'O': return sizeof(__Pyx_pad_void_p) - sizeof(void*); + default: + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } +} +static char __Pyx_BufFmt_TypeCharToGroup(char ch, int is_complex) { + switch (ch) { + case 'c': + return 'H'; + case 'b': case 'h': case 'i': + case 'l': case 'q': case 's': case 'p': + return 'I'; + case 'B': case 'H': case 'I': case 'L': case 'Q': + return 'U'; + case 'f': case 'd': case 'g': + return (is_complex ? 'C' : 'R'); + case 'O': + return 'O'; + case 'P': + return 'P'; + default: { + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } + } +} +static void __Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context* ctx) { + if (ctx->head == NULL || ctx->head->field == &ctx->root) { + const char* expected; + const char* quote; + if (ctx->head == NULL) { + expected = "end"; + quote = ""; + } else { + expected = ctx->head->field->type->name; + quote = "'"; + } + PyErr_Format(PyExc_ValueError, + "Buffer dtype mismatch, expected %s%s%s but got %s", + quote, expected, quote, + __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex)); + } else { + __Pyx_StructField* field = ctx->head->field; + __Pyx_StructField* parent = (ctx->head - 1)->field; + PyErr_Format(PyExc_ValueError, + "Buffer dtype mismatch, expected '%s' but got %s in '%s.%s'", + field->type->name, __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex), + parent->type->name, field->name); + } +} +static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) { + char group; + size_t size, offset, arraysize = 1; + if (ctx->enc_type == 0) return 0; + if (ctx->head->field->type->arraysize[0]) { + int i, ndim = 0; + if (ctx->enc_type == 's' || ctx->enc_type == 'p') { + ctx->is_valid_array = ctx->head->field->type->ndim == 1; + ndim = 1; + if (ctx->enc_count != ctx->head->field->type->arraysize[0]) { + PyErr_Format(PyExc_ValueError, + "Expected a dimension of size %zu, got %zu", + ctx->head->field->type->arraysize[0], ctx->enc_count); + return -1; + } + } + if (!ctx->is_valid_array) { + PyErr_Format(PyExc_ValueError, "Expected %d dimensions, got %d", + ctx->head->field->type->ndim, ndim); + return -1; + } + for (i = 0; i < ctx->head->field->type->ndim; i++) { + arraysize *= ctx->head->field->type->arraysize[i]; + } + ctx->is_valid_array = 0; + ctx->enc_count = 1; + } + group = __Pyx_BufFmt_TypeCharToGroup(ctx->enc_type, ctx->is_complex); + do { + __Pyx_StructField* field = ctx->head->field; + __Pyx_TypeInfo* type = field->type; + if (ctx->enc_packmode == '@' || ctx->enc_packmode == '^') { + size = __Pyx_BufFmt_TypeCharToNativeSize(ctx->enc_type, ctx->is_complex); + } else { + size = __Pyx_BufFmt_TypeCharToStandardSize(ctx->enc_type, ctx->is_complex); + } + if (ctx->enc_packmode == '@') { + size_t align_at = __Pyx_BufFmt_TypeCharToAlignment(ctx->enc_type, ctx->is_complex); + size_t align_mod_offset; + if (align_at == 0) return -1; + align_mod_offset = ctx->fmt_offset % align_at; + if (align_mod_offset > 0) ctx->fmt_offset += align_at - align_mod_offset; + if (ctx->struct_alignment == 0) + ctx->struct_alignment = __Pyx_BufFmt_TypeCharToPadding(ctx->enc_type, + ctx->is_complex); + } + if (type->size != size || type->typegroup != group) { + if (type->typegroup == 'C' && type->fields != NULL) { + size_t parent_offset = ctx->head->parent_offset + field->offset; + ++ctx->head; + ctx->head->field = type->fields; + ctx->head->parent_offset = parent_offset; + continue; + } + if ((type->typegroup == 'H' || group == 'H') && type->size == size) { + } else { + __Pyx_BufFmt_RaiseExpected(ctx); + return -1; + } + } + offset = ctx->head->parent_offset + field->offset; + if (ctx->fmt_offset != offset) { + PyErr_Format(PyExc_ValueError, + "Buffer dtype mismatch; next field is at offset %" CYTHON_FORMAT_SSIZE_T "d but %" CYTHON_FORMAT_SSIZE_T "d expected", + (Py_ssize_t)ctx->fmt_offset, (Py_ssize_t)offset); + return -1; + } + ctx->fmt_offset += size; + if (arraysize) + ctx->fmt_offset += (arraysize - 1) * size; + --ctx->enc_count; /* Consume from buffer string */ + while (1) { + if (field == &ctx->root) { + ctx->head = NULL; + if (ctx->enc_count != 0) { + __Pyx_BufFmt_RaiseExpected(ctx); + return -1; + } + break; /* breaks both loops as ctx->enc_count == 0 */ + } + ctx->head->field = ++field; + if (field->type == NULL) { + --ctx->head; + field = ctx->head->field; + continue; + } else if (field->type->typegroup == 'S') { + size_t parent_offset = ctx->head->parent_offset + field->offset; + if (field->type->fields->type == NULL) continue; /* empty struct */ + field = field->type->fields; + ++ctx->head; + ctx->head->field = field; + ctx->head->parent_offset = parent_offset; + break; + } else { + break; + } + } + } while (ctx->enc_count); + ctx->enc_type = 0; + ctx->is_complex = 0; + return 0; +} +static CYTHON_INLINE PyObject * +__pyx_buffmt_parse_array(__Pyx_BufFmt_Context* ctx, const char** tsp) +{ + const char *ts = *tsp; + int i = 0, number; + int ndim = ctx->head->field->type->ndim; +; + ++ts; + if (ctx->new_count != 1) { + PyErr_SetString(PyExc_ValueError, + "Cannot handle repeated arrays in format string"); + return NULL; + } + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + while (*ts && *ts != ')') { + if (isspace(*ts)) + continue; + number = __Pyx_BufFmt_ExpectNumber(&ts); + if (number == -1) return NULL; + if (i < ndim && (size_t) number != ctx->head->field->type->arraysize[i]) + return PyErr_Format(PyExc_ValueError, + "Expected a dimension of size %zu, got %d", + ctx->head->field->type->arraysize[i], number); + if (*ts != ',' && *ts != ')') + return PyErr_Format(PyExc_ValueError, + "Expected a comma in format string, got '%c'", *ts); + if (*ts == ',') ts++; + i++; + } + if (i != ndim) + return PyErr_Format(PyExc_ValueError, "Expected %d dimension(s), got %d", + ctx->head->field->type->ndim, i); + if (!*ts) { + PyErr_SetString(PyExc_ValueError, + "Unexpected end of format string, expected ')'"); + return NULL; + } + ctx->is_valid_array = 1; + ctx->new_count = 1; + *tsp = ++ts; + return Py_None; +} +static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts) { + int got_Z = 0; + while (1) { + switch(*ts) { + case 0: + if (ctx->enc_type != 0 && ctx->head == NULL) { + __Pyx_BufFmt_RaiseExpected(ctx); + return NULL; + } + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + if (ctx->head != NULL) { + __Pyx_BufFmt_RaiseExpected(ctx); + return NULL; + } + return ts; + case ' ': + case 10: + case 13: + ++ts; + break; + case '<': + if (!__Pyx_IsLittleEndian()) { + PyErr_SetString(PyExc_ValueError, "Little-endian buffer not supported on big-endian compiler"); + return NULL; + } + ctx->new_packmode = '='; + ++ts; + break; + case '>': + case '!': + if (__Pyx_IsLittleEndian()) { + PyErr_SetString(PyExc_ValueError, "Big-endian buffer not supported on little-endian compiler"); + return NULL; + } + ctx->new_packmode = '='; + ++ts; + break; + case '=': + case '@': + case '^': + ctx->new_packmode = *ts++; + break; + case 'T': /* substruct */ + { + const char* ts_after_sub; + size_t i, struct_count = ctx->new_count; + size_t struct_alignment = ctx->struct_alignment; + ctx->new_count = 1; + ++ts; + if (*ts != '{') { + PyErr_SetString(PyExc_ValueError, "Buffer acquisition: Expected '{' after 'T'"); + return NULL; + } + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + ctx->enc_type = 0; /* Erase processed last struct element */ + ctx->enc_count = 0; + ctx->struct_alignment = 0; + ++ts; + ts_after_sub = ts; + for (i = 0; i != struct_count; ++i) { + ts_after_sub = __Pyx_BufFmt_CheckString(ctx, ts); + if (!ts_after_sub) return NULL; + } + ts = ts_after_sub; + if (struct_alignment) ctx->struct_alignment = struct_alignment; + } + break; + case '}': /* end of substruct; either repeat or move on */ + { + size_t alignment = ctx->struct_alignment; + ++ts; + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + ctx->enc_type = 0; /* Erase processed last struct element */ + if (alignment && ctx->fmt_offset % alignment) { + ctx->fmt_offset += alignment - (ctx->fmt_offset % alignment); + } + } + return ts; + case 'x': + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + ctx->fmt_offset += ctx->new_count; + ctx->new_count = 1; + ctx->enc_count = 0; + ctx->enc_type = 0; + ctx->enc_packmode = ctx->new_packmode; + ++ts; + break; + case 'Z': + got_Z = 1; + ++ts; + if (*ts != 'f' && *ts != 'd' && *ts != 'g') { + __Pyx_BufFmt_RaiseUnexpectedChar('Z'); + return NULL; + } /* fall through */ + case 'c': case 'b': case 'B': case 'h': case 'H': case 'i': case 'I': + case 'l': case 'L': case 'q': case 'Q': + case 'f': case 'd': case 'g': + case 'O': case 's': case 'p': + if (ctx->enc_type == *ts && got_Z == ctx->is_complex && + ctx->enc_packmode == ctx->new_packmode) { + ctx->enc_count += ctx->new_count; + } else { + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + ctx->enc_count = ctx->new_count; + ctx->enc_packmode = ctx->new_packmode; + ctx->enc_type = *ts; + ctx->is_complex = got_Z; + } + ++ts; + ctx->new_count = 1; + got_Z = 0; + break; + case ':': + ++ts; + while(*ts != ':') ++ts; + ++ts; + break; + case '(': + if (!__pyx_buffmt_parse_array(ctx, &ts)) return NULL; + break; + default: + { + int number = __Pyx_BufFmt_ExpectNumber(&ts); + if (number == -1) return NULL; + ctx->new_count = (size_t)number; + } + } + } +} +static CYTHON_INLINE void __Pyx_ZeroBuffer(Py_buffer* buf) { + buf->buf = NULL; + buf->obj = NULL; + buf->strides = __Pyx_zeros; + buf->shape = __Pyx_zeros; + buf->suboffsets = __Pyx_minusones; +} +static CYTHON_INLINE int __Pyx_GetBufferAndValidate( + Py_buffer* buf, PyObject* obj, __Pyx_TypeInfo* dtype, int flags, + int nd, int cast, __Pyx_BufFmt_StackElem* stack) +{ + if (obj == Py_None || obj == NULL) { + __Pyx_ZeroBuffer(buf); + return 0; + } + buf->buf = NULL; + if (__Pyx_GetBuffer(obj, buf, flags) == -1) goto fail; + if (buf->ndim != nd) { + PyErr_Format(PyExc_ValueError, + "Buffer has wrong number of dimensions (expected %d, got %d)", + nd, buf->ndim); + goto fail; + } + if (!cast) { + __Pyx_BufFmt_Context ctx; + __Pyx_BufFmt_Init(&ctx, stack, dtype); + if (!__Pyx_BufFmt_CheckString(&ctx, buf->format)) goto fail; + } + if ((unsigned)buf->itemsize != dtype->size) { + PyErr_Format(PyExc_ValueError, + "Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "d byte%s) does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "d byte%s)", + buf->itemsize, (buf->itemsize > 1) ? "s" : "", + dtype->name, (Py_ssize_t)dtype->size, (dtype->size > 1) ? "s" : ""); + goto fail; + } + if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones; + return 0; +fail:; + __Pyx_ZeroBuffer(buf); + return -1; +} +static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) { + if (info->buf == NULL) return; + if (info->suboffsets == __Pyx_minusones) info->suboffsets = NULL; + __Pyx_ReleaseBuffer(info); +} + +static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { + if (unlikely(!type)) { + PyErr_Format(PyExc_SystemError, "Missing type object"); + return 0; + } + if (likely(PyObject_TypeCheck(obj, type))) + return 1; + PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s", + Py_TYPE(obj)->tp_name, type->tp_name); + return 0; +} + +static void __Pyx_RaiseBufferIndexError(int axis) { + PyErr_Format(PyExc_IndexError, + "Out of bounds on buffer access (axis %d)", axis); +} + +static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { + PyErr_Format(PyExc_ValueError, + "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected); +} + +static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { + PyErr_Format(PyExc_ValueError, + "need more than %" CYTHON_FORMAT_SSIZE_T "d value%s to unpack", + index, (index == 1) ? "" : "s"); +} + +static CYTHON_INLINE int __Pyx_IterFinish(void) { +#if CYTHON_COMPILING_IN_CPYTHON + PyThreadState *tstate = PyThreadState_GET(); + PyObject* exc_type = tstate->curexc_type; + if (unlikely(exc_type)) { + if (likely(exc_type == PyExc_StopIteration) || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)) { + PyObject *exc_value, *exc_tb; + exc_value = tstate->curexc_value; + exc_tb = tstate->curexc_traceback; + tstate->curexc_type = 0; + tstate->curexc_value = 0; + tstate->curexc_traceback = 0; + Py_DECREF(exc_type); + Py_XDECREF(exc_value); + Py_XDECREF(exc_tb); + return 0; + } else { + return -1; + } + } + return 0; +#else + if (unlikely(PyErr_Occurred())) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) { + PyErr_Clear(); + return 0; + } else { + return -1; + } + } + return 0; +#endif +} + +static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) { + if (unlikely(retval)) { + Py_DECREF(retval); + __Pyx_RaiseTooManyValuesError(expected); + return -1; + } else { + return __Pyx_IterFinish(); + } + return 0; +} + +static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) { +#if CYTHON_COMPILING_IN_CPYTHON + PyObject *tmp_type, *tmp_value, *tmp_tb; + PyThreadState *tstate = PyThreadState_GET(); + tmp_type = tstate->curexc_type; + tmp_value = tstate->curexc_value; + tmp_tb = tstate->curexc_traceback; + tstate->curexc_type = type; + tstate->curexc_value = value; + tstate->curexc_traceback = tb; + Py_XDECREF(tmp_type); + Py_XDECREF(tmp_value); + Py_XDECREF(tmp_tb); +#else + PyErr_Restore(type, value, tb); +#endif +} +static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) { +#if CYTHON_COMPILING_IN_CPYTHON + PyThreadState *tstate = PyThreadState_GET(); + *type = tstate->curexc_type; + *value = tstate->curexc_value; + *tb = tstate->curexc_traceback; + tstate->curexc_type = 0; + tstate->curexc_value = 0; + tstate->curexc_traceback = 0; +#else + PyErr_Fetch(type, value, tb); +#endif +} + +#if PY_MAJOR_VERSION < 3 +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, + CYTHON_UNUSED PyObject *cause) { + Py_XINCREF(type); + if (!value || value == Py_None) + value = NULL; + else + Py_INCREF(value); + if (!tb || tb == Py_None) + tb = NULL; + else { + Py_INCREF(tb); + if (!PyTraceBack_Check(tb)) { + PyErr_SetString(PyExc_TypeError, + "raise: arg 3 must be a traceback or None"); + goto raise_error; + } + } + #if PY_VERSION_HEX < 0x02050000 + if (PyClass_Check(type)) { + #else + if (PyType_Check(type)) { + #endif +#if CYTHON_COMPILING_IN_PYPY + if (!value) { + Py_INCREF(Py_None); + value = Py_None; + } +#endif + PyErr_NormalizeException(&type, &value, &tb); + } else { + if (value) { + PyErr_SetString(PyExc_TypeError, + "instance exception may not have a separate value"); + goto raise_error; + } + value = type; + #if PY_VERSION_HEX < 0x02050000 + if (PyInstance_Check(type)) { + type = (PyObject*) ((PyInstanceObject*)type)->in_class; + Py_INCREF(type); + } + else { + type = 0; + PyErr_SetString(PyExc_TypeError, + "raise: exception must be an old-style class or instance"); + goto raise_error; + } + #else + type = (PyObject*) Py_TYPE(type); + Py_INCREF(type); + if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { + PyErr_SetString(PyExc_TypeError, + "raise: exception class must be a subclass of BaseException"); + goto raise_error; + } + #endif + } + __Pyx_ErrRestore(type, value, tb); + return; +raise_error: + Py_XDECREF(value); + Py_XDECREF(type); + Py_XDECREF(tb); + return; +} +#else /* Python 3+ */ +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { + PyObject* owned_instance = NULL; + if (tb == Py_None) { + tb = 0; + } else if (tb && !PyTraceBack_Check(tb)) { + PyErr_SetString(PyExc_TypeError, + "raise: arg 3 must be a traceback or None"); + goto bad; + } + if (value == Py_None) + value = 0; + if (PyExceptionInstance_Check(type)) { + if (value) { + PyErr_SetString(PyExc_TypeError, + "instance exception may not have a separate value"); + goto bad; + } + value = type; + type = (PyObject*) Py_TYPE(value); + } else if (PyExceptionClass_Check(type)) { + PyObject *args; + if (!value) + args = PyTuple_New(0); + else if (PyTuple_Check(value)) { + Py_INCREF(value); + args = value; + } + else + args = PyTuple_Pack(1, value); + if (!args) + goto bad; + owned_instance = PyEval_CallObject(type, args); + Py_DECREF(args); + if (!owned_instance) + goto bad; + value = owned_instance; + if (!PyExceptionInstance_Check(value)) { + PyErr_Format(PyExc_TypeError, + "calling %R should have returned an instance of " + "BaseException, not %R", + type, Py_TYPE(value)); + goto bad; + } + } else { + PyErr_SetString(PyExc_TypeError, + "raise: exception class must be a subclass of BaseException"); + goto bad; + } + if (cause && cause != Py_None) { + PyObject *fixed_cause; + if (PyExceptionClass_Check(cause)) { + fixed_cause = PyObject_CallObject(cause, NULL); + if (fixed_cause == NULL) + goto bad; + } + else if (PyExceptionInstance_Check(cause)) { + fixed_cause = cause; + Py_INCREF(fixed_cause); + } + else { + PyErr_SetString(PyExc_TypeError, + "exception causes must derive from " + "BaseException"); + goto bad; + } + PyException_SetCause(value, fixed_cause); + } + PyErr_SetObject(type, value); + if (tb) { + PyThreadState *tstate = PyThreadState_GET(); + PyObject* tmp_tb = tstate->curexc_traceback; + if (tb != tmp_tb) { + Py_INCREF(tb); + tstate->curexc_traceback = tb; + Py_XDECREF(tmp_tb); + } + } +bad: + Py_XDECREF(owned_instance); + return; +} +#endif + +static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); +} + +#if PY_MAJOR_VERSION < 3 +static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) { + CYTHON_UNUSED PyObject *getbuffer_cobj; + #if PY_VERSION_HEX >= 0x02060000 + if (PyObject_CheckBuffer(obj)) return PyObject_GetBuffer(obj, view, flags); + #endif + if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) return __pyx_pw_5numpy_7ndarray_1__getbuffer__(obj, view, flags); + #if PY_VERSION_HEX < 0x02060000 + if (obj->ob_type->tp_dict && + (getbuffer_cobj = PyMapping_GetItemString(obj->ob_type->tp_dict, + "__pyx_getbuffer"))) { + getbufferproc func; + #if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION == 0) + func = (getbufferproc) PyCapsule_GetPointer(getbuffer_cobj, "getbuffer(obj, view, flags)"); + #else + func = (getbufferproc) PyCObject_AsVoidPtr(getbuffer_cobj); + #endif + Py_DECREF(getbuffer_cobj); + if (!func) + goto fail; + return func(obj, view, flags); + } else { + PyErr_Clear(); + } + #endif + PyErr_Format(PyExc_TypeError, "'%100s' does not have the buffer interface", Py_TYPE(obj)->tp_name); +#if PY_VERSION_HEX < 0x02060000 +fail: +#endif + return -1; +} +static void __Pyx_ReleaseBuffer(Py_buffer *view) { + PyObject *obj = view->obj; + CYTHON_UNUSED PyObject *releasebuffer_cobj; + if (!obj) return; + #if PY_VERSION_HEX >= 0x02060000 + if (PyObject_CheckBuffer(obj)) { + PyBuffer_Release(view); + return; + } + #endif + if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) { __pyx_pw_5numpy_7ndarray_3__releasebuffer__(obj, view); return; } + #if PY_VERSION_HEX < 0x02060000 + if (obj->ob_type->tp_dict && + (releasebuffer_cobj = PyMapping_GetItemString(obj->ob_type->tp_dict, + "__pyx_releasebuffer"))) { + releasebufferproc func; + #if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION == 0) + func = (releasebufferproc) PyCapsule_GetPointer(releasebuffer_cobj, "releasebuffer(obj, view)"); + #else + func = (releasebufferproc) PyCObject_AsVoidPtr(releasebuffer_cobj); + #endif + Py_DECREF(releasebuffer_cobj); + if (!func) + goto fail; + func(obj, view); + return; + } else { + PyErr_Clear(); + } + #endif + goto nofail; +#if PY_VERSION_HEX < 0x02060000 +fail: +#endif + PyErr_WriteUnraisable(obj); +nofail: + Py_DECREF(obj); + view->obj = NULL; +} +#endif /* PY_MAJOR_VERSION < 3 */ + + + static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, long level) { + PyObject *py_import = 0; + PyObject *empty_list = 0; + PyObject *module = 0; + PyObject *global_dict = 0; + PyObject *empty_dict = 0; + PyObject *list; + py_import = __Pyx_GetAttrString(__pyx_b, "__import__"); + if (!py_import) + goto bad; + if (from_list) + list = from_list; + else { + empty_list = PyList_New(0); + if (!empty_list) + goto bad; + list = empty_list; + } + global_dict = PyModule_GetDict(__pyx_m); + if (!global_dict) + goto bad; + empty_dict = PyDict_New(); + if (!empty_dict) + goto bad; + #if PY_VERSION_HEX >= 0x02050000 + { + #if PY_MAJOR_VERSION >= 3 + if (level == -1) { + if (strchr(__Pyx_MODULE_NAME, '.')) { + /* try package relative import first */ + PyObject *py_level = PyInt_FromLong(1); + if (!py_level) + goto bad; + module = PyObject_CallFunctionObjArgs(py_import, + name, global_dict, empty_dict, list, py_level, NULL); + Py_DECREF(py_level); + if (!module) { + if (!PyErr_ExceptionMatches(PyExc_ImportError)) + goto bad; + PyErr_Clear(); + } + } + level = 0; /* try absolute import on failure */ + } + #endif + if (!module) { + PyObject *py_level = PyInt_FromLong(level); + if (!py_level) + goto bad; + module = PyObject_CallFunctionObjArgs(py_import, + name, global_dict, empty_dict, list, py_level, NULL); + Py_DECREF(py_level); + } + } + #else + if (level>0) { + PyErr_SetString(PyExc_RuntimeError, "Relative import is not supported for Python <=2.4."); + goto bad; + } + module = PyObject_CallFunctionObjArgs(py_import, + name, global_dict, empty_dict, list, NULL); + #endif +bad: + Py_XDECREF(empty_list); + Py_XDECREF(py_import); + Py_XDECREF(empty_dict); + return module; +} + +#if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION < 3 +static PyObject *__Pyx_GetStdout(void) { + PyObject *f = PySys_GetObject((char *)"stdout"); + if (!f) { + PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout"); + } + return f; +} +static int __Pyx_Print(PyObject* f, PyObject *arg_tuple, int newline) { + int i; + if (!f) { + if (!(f = __Pyx_GetStdout())) + return -1; + } + Py_INCREF(f); + for (i=0; i < PyTuple_GET_SIZE(arg_tuple); i++) { + PyObject* v; + if (PyFile_SoftSpace(f, 1)) { + if (PyFile_WriteString(" ", f) < 0) + goto error; + } + v = PyTuple_GET_ITEM(arg_tuple, i); + if (PyFile_WriteObject(v, f, Py_PRINT_RAW) < 0) + goto error; + if (PyString_Check(v)) { + char *s = PyString_AsString(v); + Py_ssize_t len = PyString_Size(v); + if (len > 0 && + isspace(Py_CHARMASK(s[len-1])) && + s[len-1] != ' ') + PyFile_SoftSpace(f, 0); + } + } + if (newline) { + if (PyFile_WriteString("\n", f) < 0) + goto error; + PyFile_SoftSpace(f, 0); + } + Py_DECREF(f); + return 0; +error: + Py_DECREF(f); + return -1; +} +#else /* Python 3 has a print function */ +static int __Pyx_Print(PyObject* stream, PyObject *arg_tuple, int newline) { + PyObject* kwargs = 0; + PyObject* result = 0; + PyObject* end_string; + if (unlikely(!__pyx_print)) { + __pyx_print = __Pyx_GetAttrString(__pyx_b, "print"); + if (!__pyx_print) + return -1; + } + if (stream) { + kwargs = PyDict_New(); + if (unlikely(!kwargs)) + return -1; + if (unlikely(PyDict_SetItemString(kwargs, "file", stream) < 0)) + goto bad; + if (!newline) { + end_string = PyUnicode_FromStringAndSize(" ", 1); + if (unlikely(!end_string)) + goto bad; + if (PyDict_SetItemString(kwargs, "end", end_string) < 0) { + Py_DECREF(end_string); + goto bad; + } + Py_DECREF(end_string); + } + } else if (!newline) { + if (unlikely(!__pyx_print_kwargs)) { + __pyx_print_kwargs = PyDict_New(); + if (unlikely(!__pyx_print_kwargs)) + return -1; + end_string = PyUnicode_FromStringAndSize(" ", 1); + if (unlikely(!end_string)) + return -1; + if (PyDict_SetItemString(__pyx_print_kwargs, "end", end_string) < 0) { + Py_DECREF(end_string); + return -1; + } + Py_DECREF(end_string); + } + kwargs = __pyx_print_kwargs; + } + result = PyObject_Call(__pyx_print, arg_tuple, kwargs); + if (unlikely(kwargs) && (kwargs != __pyx_print_kwargs)) + Py_DECREF(kwargs); + if (!result) + return -1; + Py_DECREF(result); + return 0; +bad: + if (kwargs != __pyx_print_kwargs) + Py_XDECREF(kwargs); + return -1; +} +#endif + +#if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION < 3 +static int __Pyx_PrintOne(PyObject* f, PyObject *o) { + if (!f) { + if (!(f = __Pyx_GetStdout())) + return -1; + } + Py_INCREF(f); + if (PyFile_SoftSpace(f, 0)) { + if (PyFile_WriteString(" ", f) < 0) + goto error; + } + if (PyFile_WriteObject(o, f, Py_PRINT_RAW) < 0) + goto error; + if (PyFile_WriteString("\n", f) < 0) + goto error; + Py_DECREF(f); + return 0; +error: + Py_DECREF(f); + return -1; + /* the line below is just to avoid C compiler + * warnings about unused functions */ + return __Pyx_Print(f, NULL, 0); +} +#else /* Python 3 has a print function */ +static int __Pyx_PrintOne(PyObject* stream, PyObject *o) { + int res; + PyObject* arg_tuple = PyTuple_Pack(1, o); + if (unlikely(!arg_tuple)) + return -1; + res = __Pyx_Print(stream, arg_tuple, 1); + Py_DECREF(arg_tuple); + return res; +} +#endif + +static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_npy_long(npy_long val) { + const npy_long neg_one = (npy_long)-1, const_zero = (npy_long)0; + const int is_unsigned = const_zero < neg_one; + if ((sizeof(npy_long) == sizeof(char)) || + (sizeof(npy_long) == sizeof(short))) { + return PyInt_FromLong((long)val); + } else if ((sizeof(npy_long) == sizeof(int)) || + (sizeof(npy_long) == sizeof(long))) { + if (is_unsigned) + return PyLong_FromUnsignedLong((unsigned long)val); + else + return PyInt_FromLong((long)val); + } else if (sizeof(npy_long) == sizeof(PY_LONG_LONG)) { + if (is_unsigned) + return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)val); + else + return PyLong_FromLongLong((PY_LONG_LONG)val); + } else { + int one = 1; int little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + return _PyLong_FromByteArray(bytes, sizeof(npy_long), + little, !is_unsigned); + } +} + +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { + return ::std::complex< float >(x, y); + } + #else + static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { + return x + y*(__pyx_t_float_complex)_Complex_I; + } + #endif +#else + static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { + __pyx_t_float_complex z; + z.real = x; + z.imag = y; + return z; + } +#endif + +#if CYTHON_CCOMPLEX +#else + static CYTHON_INLINE int __Pyx_c_eqf(__pyx_t_float_complex a, __pyx_t_float_complex b) { + return (a.real == b.real) && (a.imag == b.imag); + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sumf(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + z.real = a.real + b.real; + z.imag = a.imag + b.imag; + return z; + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_difff(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + z.real = a.real - b.real; + z.imag = a.imag - b.imag; + return z; + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prodf(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + z.real = a.real * b.real - a.imag * b.imag; + z.imag = a.real * b.imag + a.imag * b.real; + return z; + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quotf(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + float denom = b.real * b.real + b.imag * b.imag; + z.real = (a.real * b.real + a.imag * b.imag) / denom; + z.imag = (a.imag * b.real - a.real * b.imag) / denom; + return z; + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_negf(__pyx_t_float_complex a) { + __pyx_t_float_complex z; + z.real = -a.real; + z.imag = -a.imag; + return z; + } + static CYTHON_INLINE int __Pyx_c_is_zerof(__pyx_t_float_complex a) { + return (a.real == 0) && (a.imag == 0); + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conjf(__pyx_t_float_complex a) { + __pyx_t_float_complex z; + z.real = a.real; + z.imag = -a.imag; + return z; + } + #if 1 + static CYTHON_INLINE float __Pyx_c_absf(__pyx_t_float_complex z) { + #if !defined(HAVE_HYPOT) || defined(_MSC_VER) + return sqrtf(z.real*z.real + z.imag*z.imag); + #else + return hypotf(z.real, z.imag); + #endif + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_powf(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + float r, lnr, theta, z_r, z_theta; + if (b.imag == 0 && b.real == (int)b.real) { + if (b.real < 0) { + float denom = a.real * a.real + a.imag * a.imag; + a.real = a.real / denom; + a.imag = -a.imag / denom; + b.real = -b.real; + } + switch ((int)b.real) { + case 0: + z.real = 1; + z.imag = 0; + return z; + case 1: + return a; + case 2: + z = __Pyx_c_prodf(a, a); + return __Pyx_c_prodf(a, a); + case 3: + z = __Pyx_c_prodf(a, a); + return __Pyx_c_prodf(z, a); + case 4: + z = __Pyx_c_prodf(a, a); + return __Pyx_c_prodf(z, z); + } + } + if (a.imag == 0) { + if (a.real == 0) { + return a; + } + r = a.real; + theta = 0; + } else { + r = __Pyx_c_absf(a); + theta = atan2f(a.imag, a.real); + } + lnr = logf(r); + z_r = expf(lnr * b.real - theta * b.imag); + z_theta = theta * b.real + lnr * b.imag; + z.real = z_r * cosf(z_theta); + z.imag = z_r * sinf(z_theta); + return z; + } + #endif +#endif + +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { + return ::std::complex< double >(x, y); + } + #else + static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { + return x + y*(__pyx_t_double_complex)_Complex_I; + } + #endif +#else + static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { + __pyx_t_double_complex z; + z.real = x; + z.imag = y; + return z; + } +#endif + +#if CYTHON_CCOMPLEX +#else + static CYTHON_INLINE int __Pyx_c_eq(__pyx_t_double_complex a, __pyx_t_double_complex b) { + return (a.real == b.real) && (a.imag == b.imag); + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + z.real = a.real + b.real; + z.imag = a.imag + b.imag; + return z; + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + z.real = a.real - b.real; + z.imag = a.imag - b.imag; + return z; + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + z.real = a.real * b.real - a.imag * b.imag; + z.imag = a.real * b.imag + a.imag * b.real; + return z; + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + double denom = b.real * b.real + b.imag * b.imag; + z.real = (a.real * b.real + a.imag * b.imag) / denom; + z.imag = (a.imag * b.real - a.real * b.imag) / denom; + return z; + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg(__pyx_t_double_complex a) { + __pyx_t_double_complex z; + z.real = -a.real; + z.imag = -a.imag; + return z; + } + static CYTHON_INLINE int __Pyx_c_is_zero(__pyx_t_double_complex a) { + return (a.real == 0) && (a.imag == 0); + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj(__pyx_t_double_complex a) { + __pyx_t_double_complex z; + z.real = a.real; + z.imag = -a.imag; + return z; + } + #if 1 + static CYTHON_INLINE double __Pyx_c_abs(__pyx_t_double_complex z) { + #if !defined(HAVE_HYPOT) || defined(_MSC_VER) + return sqrt(z.real*z.real + z.imag*z.imag); + #else + return hypot(z.real, z.imag); + #endif + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + double r, lnr, theta, z_r, z_theta; + if (b.imag == 0 && b.real == (int)b.real) { + if (b.real < 0) { + double denom = a.real * a.real + a.imag * a.imag; + a.real = a.real / denom; + a.imag = -a.imag / denom; + b.real = -b.real; + } + switch ((int)b.real) { + case 0: + z.real = 1; + z.imag = 0; + return z; + case 1: + return a; + case 2: + z = __Pyx_c_prod(a, a); + return __Pyx_c_prod(a, a); + case 3: + z = __Pyx_c_prod(a, a); + return __Pyx_c_prod(z, a); + case 4: + z = __Pyx_c_prod(a, a); + return __Pyx_c_prod(z, z); + } + } + if (a.imag == 0) { + if (a.real == 0) { + return a; + } + r = a.real; + theta = 0; + } else { + r = __Pyx_c_abs(a); + theta = atan2(a.imag, a.real); + } + lnr = log(r); + z_r = exp(lnr * b.real - theta * b.imag); + z_theta = theta * b.real + lnr * b.imag; + z.real = z_r * cos(z_theta); + z.imag = z_r * sin(z_theta); + return z; + } + #endif +#endif + +static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject* x) { + const unsigned char neg_one = (unsigned char)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(unsigned char) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(unsigned char)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to unsigned char" : + "value too large to convert to unsigned char"); + } + return (unsigned char)-1; + } + return (unsigned char)val; + } + return (unsigned char)__Pyx_PyInt_AsUnsignedLong(x); +} + +static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject* x) { + const unsigned short neg_one = (unsigned short)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(unsigned short) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(unsigned short)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to unsigned short" : + "value too large to convert to unsigned short"); + } + return (unsigned short)-1; + } + return (unsigned short)val; + } + return (unsigned short)__Pyx_PyInt_AsUnsignedLong(x); +} + +static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject* x) { + const unsigned int neg_one = (unsigned int)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(unsigned int) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(unsigned int)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to unsigned int" : + "value too large to convert to unsigned int"); + } + return (unsigned int)-1; + } + return (unsigned int)val; + } + return (unsigned int)__Pyx_PyInt_AsUnsignedLong(x); +} + +static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject* x) { + const char neg_one = (char)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(char) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(char)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to char" : + "value too large to convert to char"); + } + return (char)-1; + } + return (char)val; + } + return (char)__Pyx_PyInt_AsLong(x); +} + +static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject* x) { + const short neg_one = (short)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(short) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(short)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to short" : + "value too large to convert to short"); + } + return (short)-1; + } + return (short)val; + } + return (short)__Pyx_PyInt_AsLong(x); +} + +static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject* x) { + const int neg_one = (int)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(int) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(int)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to int" : + "value too large to convert to int"); + } + return (int)-1; + } + return (int)val; + } + return (int)__Pyx_PyInt_AsLong(x); +} + +static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject* x) { + const signed char neg_one = (signed char)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(signed char) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(signed char)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to signed char" : + "value too large to convert to signed char"); + } + return (signed char)-1; + } + return (signed char)val; + } + return (signed char)__Pyx_PyInt_AsSignedLong(x); +} + +static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject* x) { + const signed short neg_one = (signed short)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(signed short) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(signed short)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to signed short" : + "value too large to convert to signed short"); + } + return (signed short)-1; + } + return (signed short)val; + } + return (signed short)__Pyx_PyInt_AsSignedLong(x); +} + +static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject* x) { + const signed int neg_one = (signed int)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(signed int) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(signed int)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to signed int" : + "value too large to convert to signed int"); + } + return (signed int)-1; + } + return (signed int)val; + } + return (signed int)__Pyx_PyInt_AsSignedLong(x); +} + +static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject* x) { + const int neg_one = (int)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(int) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(int)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to int" : + "value too large to convert to int"); + } + return (int)-1; + } + return (int)val; + } + return (int)__Pyx_PyInt_AsLong(x); +} + +static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) { + const unsigned long neg_one = (unsigned long)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; +#if PY_VERSION_HEX < 0x03000000 + if (likely(PyInt_Check(x))) { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to unsigned long"); + return (unsigned long)-1; + } + return (unsigned long)val; + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { + if (unlikely(Py_SIZE(x) < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to unsigned long"); + return (unsigned long)-1; + } + return (unsigned long)PyLong_AsUnsignedLong(x); + } else { + return (unsigned long)PyLong_AsLong(x); + } + } else { + unsigned long val; + PyObject *tmp = __Pyx_PyNumber_Int(x); + if (!tmp) return (unsigned long)-1; + val = __Pyx_PyInt_AsUnsignedLong(tmp); + Py_DECREF(tmp); + return val; + } +} + +static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject* x) { + const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; +#if PY_VERSION_HEX < 0x03000000 + if (likely(PyInt_Check(x))) { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to unsigned PY_LONG_LONG"); + return (unsigned PY_LONG_LONG)-1; + } + return (unsigned PY_LONG_LONG)val; + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { + if (unlikely(Py_SIZE(x) < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to unsigned PY_LONG_LONG"); + return (unsigned PY_LONG_LONG)-1; + } + return (unsigned PY_LONG_LONG)PyLong_AsUnsignedLongLong(x); + } else { + return (unsigned PY_LONG_LONG)PyLong_AsLongLong(x); + } + } else { + unsigned PY_LONG_LONG val; + PyObject *tmp = __Pyx_PyNumber_Int(x); + if (!tmp) return (unsigned PY_LONG_LONG)-1; + val = __Pyx_PyInt_AsUnsignedLongLong(tmp); + Py_DECREF(tmp); + return val; + } +} + +static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject* x) { + const long neg_one = (long)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; +#if PY_VERSION_HEX < 0x03000000 + if (likely(PyInt_Check(x))) { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to long"); + return (long)-1; + } + return (long)val; + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { + if (unlikely(Py_SIZE(x) < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to long"); + return (long)-1; + } + return (long)PyLong_AsUnsignedLong(x); + } else { + return (long)PyLong_AsLong(x); + } + } else { + long val; + PyObject *tmp = __Pyx_PyNumber_Int(x); + if (!tmp) return (long)-1; + val = __Pyx_PyInt_AsLong(tmp); + Py_DECREF(tmp); + return val; + } +} + +static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject* x) { + const PY_LONG_LONG neg_one = (PY_LONG_LONG)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; +#if PY_VERSION_HEX < 0x03000000 + if (likely(PyInt_Check(x))) { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to PY_LONG_LONG"); + return (PY_LONG_LONG)-1; + } + return (PY_LONG_LONG)val; + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { + if (unlikely(Py_SIZE(x) < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to PY_LONG_LONG"); + return (PY_LONG_LONG)-1; + } + return (PY_LONG_LONG)PyLong_AsUnsignedLongLong(x); + } else { + return (PY_LONG_LONG)PyLong_AsLongLong(x); + } + } else { + PY_LONG_LONG val; + PyObject *tmp = __Pyx_PyNumber_Int(x); + if (!tmp) return (PY_LONG_LONG)-1; + val = __Pyx_PyInt_AsLongLong(tmp); + Py_DECREF(tmp); + return val; + } +} + +static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) { + const signed long neg_one = (signed long)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; +#if PY_VERSION_HEX < 0x03000000 + if (likely(PyInt_Check(x))) { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to signed long"); + return (signed long)-1; + } + return (signed long)val; + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { + if (unlikely(Py_SIZE(x) < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to signed long"); + return (signed long)-1; + } + return (signed long)PyLong_AsUnsignedLong(x); + } else { + return (signed long)PyLong_AsLong(x); + } + } else { + signed long val; + PyObject *tmp = __Pyx_PyNumber_Int(x); + if (!tmp) return (signed long)-1; + val = __Pyx_PyInt_AsSignedLong(tmp); + Py_DECREF(tmp); + return val; + } +} + +static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* x) { + const signed PY_LONG_LONG neg_one = (signed PY_LONG_LONG)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; +#if PY_VERSION_HEX < 0x03000000 + if (likely(PyInt_Check(x))) { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to signed PY_LONG_LONG"); + return (signed PY_LONG_LONG)-1; + } + return (signed PY_LONG_LONG)val; + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { + if (unlikely(Py_SIZE(x) < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to signed PY_LONG_LONG"); + return (signed PY_LONG_LONG)-1; + } + return (signed PY_LONG_LONG)PyLong_AsUnsignedLongLong(x); + } else { + return (signed PY_LONG_LONG)PyLong_AsLongLong(x); + } + } else { + signed PY_LONG_LONG val; + PyObject *tmp = __Pyx_PyNumber_Int(x); + if (!tmp) return (signed PY_LONG_LONG)-1; + val = __Pyx_PyInt_AsSignedLongLong(tmp); + Py_DECREF(tmp); + return val; + } +} + +static int __Pyx_check_binary_version(void) { + char ctversion[4], rtversion[4]; + PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); + PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion()); + if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) { + char message[200]; + PyOS_snprintf(message, sizeof(message), + "compiletime version %s of module '%.100s' " + "does not match runtime version %s", + ctversion, __Pyx_MODULE_NAME, rtversion); + #if PY_VERSION_HEX < 0x02050000 + return PyErr_Warn(NULL, message); + #else + return PyErr_WarnEx(NULL, message, 1); + #endif + } + return 0; +} + +#ifndef __PYX_HAVE_RT_ImportModule +#define __PYX_HAVE_RT_ImportModule +static PyObject *__Pyx_ImportModule(const char *name) { + PyObject *py_name = 0; + PyObject *py_module = 0; + py_name = __Pyx_PyIdentifier_FromString(name); + if (!py_name) + goto bad; + py_module = PyImport_Import(py_name); + Py_DECREF(py_name); + return py_module; +bad: + Py_XDECREF(py_name); + return 0; +} +#endif + +#ifndef __PYX_HAVE_RT_ImportType +#define __PYX_HAVE_RT_ImportType +static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, + size_t size, int strict) +{ + PyObject *py_module = 0; + PyObject *result = 0; + PyObject *py_name = 0; + char warning[200]; + py_module = __Pyx_ImportModule(module_name); + if (!py_module) + goto bad; + py_name = __Pyx_PyIdentifier_FromString(class_name); + if (!py_name) + goto bad; + result = PyObject_GetAttr(py_module, py_name); + Py_DECREF(py_name); + py_name = 0; + Py_DECREF(py_module); + py_module = 0; + if (!result) + goto bad; + if (!PyType_Check(result)) { + PyErr_Format(PyExc_TypeError, + "%s.%s is not a type object", + module_name, class_name); + goto bad; + } + if (!strict && (size_t)((PyTypeObject *)result)->tp_basicsize > size) { + PyOS_snprintf(warning, sizeof(warning), + "%s.%s size changed, may indicate binary incompatibility", + module_name, class_name); + #if PY_VERSION_HEX < 0x02050000 + if (PyErr_Warn(NULL, warning) < 0) goto bad; + #else + if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad; + #endif + } + else if ((size_t)((PyTypeObject *)result)->tp_basicsize != size) { + PyErr_Format(PyExc_ValueError, + "%s.%s has the wrong size, try recompiling", + module_name, class_name); + goto bad; + } + return (PyTypeObject *)result; +bad: + Py_XDECREF(py_module); + Py_XDECREF(result); + return NULL; +} +#endif + +static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { + int start = 0, mid = 0, end = count - 1; + if (end >= 0 && code_line > entries[end].code_line) { + return count; + } + while (start < end) { + mid = (start + end) / 2; + if (code_line < entries[mid].code_line) { + end = mid; + } else if (code_line > entries[mid].code_line) { + start = mid + 1; + } else { + return mid; + } + } + if (code_line <= entries[mid].code_line) { + return mid; + } else { + return mid + 1; + } +} +static PyCodeObject *__pyx_find_code_object(int code_line) { + PyCodeObject* code_object; + int pos; + if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) { + return NULL; + } + pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); + if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) { + return NULL; + } + code_object = __pyx_code_cache.entries[pos].code_object; + Py_INCREF(code_object); + return code_object; +} +static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { + int pos, i; + __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; + if (unlikely(!code_line)) { + return; + } + if (unlikely(!entries)) { + entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); + if (likely(entries)) { + __pyx_code_cache.entries = entries; + __pyx_code_cache.max_count = 64; + __pyx_code_cache.count = 1; + entries[0].code_line = code_line; + entries[0].code_object = code_object; + Py_INCREF(code_object); + } + return; + } + pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); + if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) { + PyCodeObject* tmp = entries[pos].code_object; + entries[pos].code_object = code_object; + Py_DECREF(tmp); + return; + } + if (__pyx_code_cache.count == __pyx_code_cache.max_count) { + int new_max = __pyx_code_cache.max_count + 64; + entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( + __pyx_code_cache.entries, new_max*sizeof(__Pyx_CodeObjectCacheEntry)); + if (unlikely(!entries)) { + return; + } + __pyx_code_cache.entries = entries; + __pyx_code_cache.max_count = new_max; + } + for (i=__pyx_code_cache.count; i>pos; i--) { + entries[i] = entries[i-1]; + } + entries[pos].code_line = code_line; + entries[pos].code_object = code_object; + __pyx_code_cache.count++; + Py_INCREF(code_object); +} + +#include "compile.h" +#include "frameobject.h" +#include "traceback.h" +static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( + const char *funcname, int c_line, + int py_line, const char *filename) { + PyCodeObject *py_code = 0; + PyObject *py_srcfile = 0; + PyObject *py_funcname = 0; + #if PY_MAJOR_VERSION < 3 + py_srcfile = PyString_FromString(filename); + #else + py_srcfile = PyUnicode_FromString(filename); + #endif + if (!py_srcfile) goto bad; + if (c_line) { + #if PY_MAJOR_VERSION < 3 + py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); + #else + py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); + #endif + } + else { + #if PY_MAJOR_VERSION < 3 + py_funcname = PyString_FromString(funcname); + #else + py_funcname = PyUnicode_FromString(funcname); + #endif + } + if (!py_funcname) goto bad; + py_code = __Pyx_PyCode_New( + 0, /*int argcount,*/ + 0, /*int kwonlyargcount,*/ + 0, /*int nlocals,*/ + 0, /*int stacksize,*/ + 0, /*int flags,*/ + __pyx_empty_bytes, /*PyObject *code,*/ + __pyx_empty_tuple, /*PyObject *consts,*/ + __pyx_empty_tuple, /*PyObject *names,*/ + __pyx_empty_tuple, /*PyObject *varnames,*/ + __pyx_empty_tuple, /*PyObject *freevars,*/ + __pyx_empty_tuple, /*PyObject *cellvars,*/ + py_srcfile, /*PyObject *filename,*/ + py_funcname, /*PyObject *name,*/ + py_line, /*int firstlineno,*/ + __pyx_empty_bytes /*PyObject *lnotab*/ + ); + Py_DECREF(py_srcfile); + Py_DECREF(py_funcname); + return py_code; +bad: + Py_XDECREF(py_srcfile); + Py_XDECREF(py_funcname); + return NULL; +} +static void __Pyx_AddTraceback(const char *funcname, int c_line, + int py_line, const char *filename) { + PyCodeObject *py_code = 0; + PyObject *py_globals = 0; + PyFrameObject *py_frame = 0; + py_code = __pyx_find_code_object(c_line ? c_line : py_line); + if (!py_code) { + py_code = __Pyx_CreateCodeObjectForTraceback( + funcname, c_line, py_line, filename); + if (!py_code) goto bad; + __pyx_insert_code_object(c_line ? c_line : py_line, py_code); + } + py_globals = PyModule_GetDict(__pyx_m); + if (!py_globals) goto bad; + py_frame = PyFrame_New( + PyThreadState_GET(), /*PyThreadState *tstate,*/ + py_code, /*PyCodeObject *code,*/ + py_globals, /*PyObject *globals,*/ + 0 /*PyObject *locals*/ + ); + if (!py_frame) goto bad; + py_frame->f_lineno = py_line; + PyTraceBack_Here(py_frame); +bad: + Py_XDECREF(py_code); + Py_XDECREF(py_frame); +} + +static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { + while (t->p) { + #if PY_MAJOR_VERSION < 3 + if (t->is_unicode) { + *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); + } else if (t->intern) { + *t->p = PyString_InternFromString(t->s); + } else { + *t->p = PyString_FromStringAndSize(t->s, t->n - 1); + } + #else /* Python 3+ has unicode identifiers */ + if (t->is_unicode | t->is_str) { + if (t->intern) { + *t->p = PyUnicode_InternFromString(t->s); + } else if (t->encoding) { + *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL); + } else { + *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1); + } + } else { + *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1); + } + #endif + if (!*t->p) + return -1; + ++t; + } + return 0; +} + + +/* Type Conversion Functions */ + +static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { + int is_true = x == Py_True; + if (is_true | (x == Py_False) | (x == Py_None)) return is_true; + else return PyObject_IsTrue(x); +} + +static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) { + PyNumberMethods *m; + const char *name = NULL; + PyObject *res = NULL; +#if PY_VERSION_HEX < 0x03000000 + if (PyInt_Check(x) || PyLong_Check(x)) +#else + if (PyLong_Check(x)) +#endif + return Py_INCREF(x), x; + m = Py_TYPE(x)->tp_as_number; +#if PY_VERSION_HEX < 0x03000000 + if (m && m->nb_int) { + name = "int"; + res = PyNumber_Int(x); + } + else if (m && m->nb_long) { + name = "long"; + res = PyNumber_Long(x); + } +#else + if (m && m->nb_int) { + name = "int"; + res = PyNumber_Long(x); + } +#endif + if (res) { +#if PY_VERSION_HEX < 0x03000000 + if (!PyInt_Check(res) && !PyLong_Check(res)) { +#else + if (!PyLong_Check(res)) { +#endif + PyErr_Format(PyExc_TypeError, + "__%s__ returned non-%s (type %.200s)", + name, name, Py_TYPE(res)->tp_name); + Py_DECREF(res); + return NULL; + } + } + else if (!PyErr_Occurred()) { + PyErr_SetString(PyExc_TypeError, + "an integer is required"); + } + return res; +} + +static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { + Py_ssize_t ival; + PyObject* x = PyNumber_Index(b); + if (!x) return -1; + ival = PyInt_AsSsize_t(x); + Py_DECREF(x); + return ival; +} + +static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { +#if PY_VERSION_HEX < 0x02050000 + if (ival <= LONG_MAX) + return PyInt_FromLong((long)ival); + else { + unsigned char *bytes = (unsigned char *) &ival; + int one = 1; int little = (int)*(unsigned char*)&one; + return _PyLong_FromByteArray(bytes, sizeof(size_t), little, 0); + } +#else + return PyInt_FromSize_t(ival); +#endif +} + +static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject* x) { + unsigned PY_LONG_LONG val = __Pyx_PyInt_AsUnsignedLongLong(x); + if (unlikely(val == (unsigned PY_LONG_LONG)-1 && PyErr_Occurred())) { + return (size_t)-1; + } else if (unlikely(val != (unsigned PY_LONG_LONG)(size_t)val)) { + PyErr_SetString(PyExc_OverflowError, + "value too large to convert to size_t"); + return (size_t)-1; + } + return (size_t)val; +} + + +#endif /* Py_PYTHON_H */ diff --git a/code/trio/hmmUtils.pyx b/code/trio/hmmUtils.pyx new file mode 100644 index 0000000..0d13946 --- /dev/null +++ b/code/trio/hmmUtils.pyx @@ -0,0 +1,203 @@ +#!/usr/bin/env python +#Rick Dewey 8.14.12 +#Last modified 8.14.12 Rick Dewey for Cython +#Python utils for HMM inheritance analysis of pedigrees +#usage: Cython internal toolset for HMM + +import sys +import os +import re +import fileinput +import getopt +import argparse +import numpy as np +cimport numpy as np +import math + +DTYPEf = np.float +DTYPEi = np.int +ctypedef np.float_t DTYPEf_t +ctypedef np.int_t DTYPEi_t + +#loads transition matrix +def load_transition(path, selftrans, nonselftrans, sub_ped): + + #trio case + if sub_ped == "t": + tmat = np.zeros([3, 3], np.float) + i = 0 + tfile = open(path, "r") + for line in tfile.readlines(): + linelist = line.replace("nonself", str(nonselftrans)).replace("self", str(selftrans)).replace("\n", "").split("\t") + tmat[i][0] = math.log10(np.float(linelist[0])) + tmat[i][1] = math.log10(np.float(linelist[1])) + tmat[i][2] = math.log10(np.float(linelist[2])) + i+=1 + return tmat + + #quartet case + elif sub_ped == "q": + tmat = np.zeros([6, 6], np.float) + i = 0 + + tfile = open(path, "r") + for line in tfile.readlines(): + linelist = line.replace("nonself", str(nonselftrans)).replace("self", str(selftrans)).replace("\n", "").split("\t") + tmat[i][0] = math.log10(np.float(linelist[0])) + tmat[i][1] = math.log10(np.float(linelist[1])) + tmat[i][2] = math.log10(np.float(linelist[2])) + tmat[i][3] = math.log10(np.float(linelist[3])) + tmat[i][4] = math.log10(np.float(linelist[4])) + tmat[i][5] = math.log10(np.float(linelist[5])) + i+=1 + return tmat + + else: + print >> sys.stderr, "Error in hmmUtils.load_transition: Unknown sub-pedigree format: "+sub_ped + exit(1) + +#loads emission matrix for hmm +def load_emission(path, comp, mie, err, sub_ped): + + #trio case + if sub_ped == "t": + emat = np.zeros([3, 27], np.float) + + efile = open(path, "r") + trash = efile.readline() + + #alleles are in father, mother, child order + #there are 12 allele assortments consistent with MIEs and one uniformly heterozygous position indicating possible compressions + erprobG = np.float(err)/np.float(12) + goodprob = (1-np.float(err))/np.float(15) + + erprobC = (1-np.float(comp))/np.float(26) + + erprobM = (1-np.float(mie))/np.float(15) + mieprob = np.float(mie)/np.float(12) + + i = 0 + #0 is MIErich, 1 is compression, 2 is good data + for line in efile.readlines(): + linelist = line.replace("erprobM", str(erprobM)).replace("erprobG", str(erprobG)).replace("goodprob", str(goodprob)).replace("comprob", str(comp)).replace("erprobC", str(erprobC)).replace("mieprob", str(mieprob)).split("\t") + emat[0][i] = math.log10(np.float(linelist[2])) + emat[1][i] = math.log10(np.float(linelist[3])) + emat[2][i] = math.log10(np.float(linelist[4])) + i+=1 + return emat + + #quartet case + elif sub_ped == "q": + efile = open(path, "r") + trash = efile.readline() + + emat = np.zeros([6, 81], np.float) + + #alleles are in father, mother, child, child order + #there are 52 allele assortments consistent with MIEs and one uniformly heterozygous position indicating possible compressions + erprobHI = np.float(err)/np.float(65) + erprobID = np.float(err)/np.float(66) + goodprobID = (1-np.float(err))/np.float(16) + goodprobHI = (1-np.float(err))/np.float(15) + + erprobC = (1-np.float(comp))/np.float(80) + + erprobM = (1-np.float(mie))/np.float(29) + + mieprob = np.float(mie)/np.float(52) + + i = 0 + #0 is MIErich, 1 is compression, 2 is good data + for line in efile.readlines(): + linelist = line.replace("erprobM", str(erprobM)).replace("erprobHI", str(erprobHI)).replace("erprobID", str(erprobID)).replace("goodprobHI", str(goodprobHI)).replace("goodprobID", str(goodprobID)).replace("comprob", str(comp)).replace("erprobC", str(erprobC)).replace("mieprob", str(mieprob)).split("\t") + emat[0][i] = math.log10(np.float(linelist[2])) + emat[1][i] = math.log10(np.float(linelist[3])) + emat[2][i] = math.log10(np.float(linelist[4])) + emat[3][i] = math.log10(np.float(linelist[5])) + emat[4][i] = math.log10(np.float(linelist[6])) + emat[5][i] = math.log10(np.float(linelist[7])) + i+=1 + return emat + + else: + print >> sys.stderr, "Error in hmmUtils.load_emission: Unknown sub-pedigree format: "+sub_ped + exit(1) + +#creates array of observations +def makeobs_set(numsubj): + obs = [] + n_assort = 3**numsubj + for i in range(0, n_assort): + obs.append(i) + return obs + +#returns map of allele assortments to allele codes for hmm, allele order father, mother, child +def input_map(path_efile, sub_ped): + imap = {} + + #trio case + if sub_ped == "t": + tempin = open(path_efile+"EmissionTrioGen.txt", "r") + elif sub_ped == "q": + tempin = open(path_efile+"EmissionQuartetGen.txt", "r") + else: + print >> sys.stderr, "Error in hmmUtils.input_map: Unknown sub-pedigree format: "+sub_ped + exit(1) + + trash = tempin.readline() + for line in tempin.readlines(): + linelist = line.split("\t") + imap[linelist[1]] = linelist[0] + return imap + +#creates and returns as a tuple emission, transition, start, state, and observation matrices +def make_hmm(mpath, sprob, comp, mprob, errprob, sub_ped): + if sub_ped == "t": + #distribute non-self transition probability to non-self states + nprob = (1-np.float(sprob))/np.float(2) + + #create matrices for HMM, all probabilities in log10 space to avoid underflow from np.floating point + transmat = load_transition(mpath+"TransitionTrioGen.txt", sprob, nprob, "t") + emitmat = load_emission(mpath+"EmissionTrioGen.txt", comp, mprob, errprob, "t") + startp = np.array([math.log10(np.float(1)/np.float(3)), math.log10(np.float(1)/np.float(3)), math.log10(np.float(1)/np.float(3))]) + states = np.array([0, 1, 2]) + inmap = input_map(mpath, "t") + + elif sub_ped == "q": + #distribute non-self transition probability to non-self states + nprob = (1-np.float(sprob))/np.float(5) + + #create matrices for HMM, all probabilities in log10 space to avoid underflow from np.floating point + transmat = load_transition(mpath+"TransitionQuartetGen.txt", sprob, nprob, "q") + emitmat = load_emission(mpath+"EmissionQuartetGen.txt", comp, mprob, errprob, "q") + startp = np.array([math.log10(np.float(1)/np.float(6)), math.log10(np.float(1)/np.float(6)), math.log10(np.float(1)/np.float(6)), math.log10(np.float(1)/np.float(6)), math.log10(np.float(1)/np.float(6)), math.log10(np.float(1)/np.float(6))]) + states = np.array([0, 1, 2, 3, 4, 5]) + inmap = input_map(mpath, "q") + else: + print >> sys.stderr, "Error in hmmUtils.make_hmm: Unknown sub-pedigree format: "+sub_ped + exit(1) + return transmat, emitmat, startp, states, inmap + +#uses sums of log-transformed probabilities to avoid np.floating point underflow problems +def viterbi(np.ndarray[DTYPEi_t] obs, np.ndarray[DTYPEi_t] states, np.ndarray[DTYPEf_t] start_p, np.ndarray[DTYPEf_t, ndim = 2] trans_p, np.ndarray[DTYPEf_t, ndim = 2] emit_p): + cdef int y, y0, t, state + cdef double prob + cdef np.ndarray[DTYPEf_t, ndim = 2] V = np.zeros([len(obs), len(states)], np.float) + cdef np.ndarray[DTYPEi_t, ndim = 2] path = np.zeros([len(states), len(obs)], np.int) + + # Initialize base cases (t == 0) + for y in states: + V[0,y] = start_p[y] + emit_p[y,int(obs[0])] + path[y,0] = y + + # Run Viterbi for t > 0 + for t in range(1,len(obs)): + + for y in states: + (prob, state) = max([(V[t-1,y0] + trans_p[y0,y] + emit_p[y,obs[t]], y0) for y0 in states]) + V[t,y] = prob + path[y,0:t] = path[state,0:t] + path[y,t] = y + + (prob, state) = max([(V[len(obs) - 1,y], y) for y in states]) + return (prob, path[state]) diff --git a/code/trio/pedigreeUtils.py b/code/trio/pedigreeUtils.py new file mode 100644 index 0000000..a0c9b15 --- /dev/null +++ b/code/trio/pedigreeUtils.py @@ -0,0 +1,399 @@ +#Rick Dewey 6.28.12 +#Last modified 8.26.13 James Priest +#module for general pedigree utilities +#usage: utils module for general pedigree utilities +#!/usr/bin/env python + +import os +import re +import sys +import math +import vcfUtils +#import hmmUtils +import time +import numpy as np + + +#traverses .ped files and returns founders, a dictionary with parents and number of offspring (trios), all trios, quartets, and parents with one child only (unique_trios), dictionary with affected status +def traverse(pfile): + fam_arr = [] + parent_arr = [] + parent_dict = {} + last_trio = {} + affected = {} + + trios = [] + unique_trios = [] + quartets = [] + founders = [] + + try: + pedfile = open(pfile, "r") + except IOError: + print >> sys.stderr, "Error in pedigreeUtils.traverse: Invalid pedigree file" + exit(1) + + header = pedfile.readline() + + for line in pedfile: + linelist = line.replace("\n", "").split("\t") + family_id = linelist[0] + child = linelist[1] + father = linelist[2] + mother = linelist[3] + gender = linelist[4] + affected[child] = linelist[5] + + if (father == "--") and (mother == "--"): + founders.append(child) + else: + + #trios sharing same parent are identified as quartets + if ((father+":"+mother) in parent_arr): + parent_dict[father+":"+mother]+=1 + trios.append(father+":"+mother+":"+child) + quartets.append(father+":"+mother+":"+last_trio[father+":"+mother]+":"+child) + last_trio[father+":"+mother] = child + + #remove trios that form quartets from unique_trios + for element in unique_trios: + if father+":"+mother in element: + unique_trios.remove(element) + else: + parent_arr.append(father+":"+mother) + parent_dict[father+":"+mother] = 1 + trios.append(father+":"+mother+":"+child) + last_trio[father+":"+mother] = child + unique_trios.append(father+":"+mother+":"+child) + + return founders, parent_dict, trios, quartets, unique_trios, affected + +#creates inheritance states for quartets: 0 = haploidentical paternal, 1 = haploidentical maternal, 2 = identical, 3 = nonidentical; and two error states: 4 = compression, 5 = mie rich +def phase_quartet(fatherID, motherID, offspring1ID, offspring2ID, vcf_in_stem, depth, altDepth, gtQual, mapQual, mapQual0, pl, mat_path, error, compression, mie, selfprob, platform): + nonselfprob = str((1-float(selfprob))/float(5)) + + #create matrices for HMM, all probabilities in log10 space to avoid underflow from floating point + transmat, emitmat, startp, states, inmap = hmmUtils.make_hmm(mat_path, selfprob, compression, mie, error, "q") + + #temp file for inheritance state + phase_out = open(".".join([vcf_in_stem, fatherID, motherID, offspring1ID, offspring2ID, "phase_out.txt"]), "w") + + #chrom_arr = ["21", "22"] + chrom_arr = ["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","X"] + + start_time=time.clock() + for chromh in chrom_arr: + print "\nWorking on chromosome "+str(chromh)+"\n" + fin = open(vcf_in_stem+"_chr"+chromh+".txt", "r") + + header = fin.readline() + + #grab proper columns from header for variants + headlist = header.replace("\n", "").split("\t") + try: + offspring1 = headlist.index(offspring1ID) + offspring2 = headlist.index(offspring2ID) + father = headlist.index(fatherID) + mother = headlist.index(motherID) + except ValueError: + return "Error in pedigreeUtils.phase_quartet: Invalid input for quartet "+":".join([fatherID, motherID, offspring1ID, offspring2ID])+" - Specified subject ID does not match vcf file header, consider malformed header or pedigree file" + + #arrays for observations and positions + obs_seq = [] + position_clean = [] + position_all = [] + res_dict = {} + + #counters for error modes (DN = de novo allele, HZGC = apparent gene conversions/hemizygosity + counterDN1 = 0 + counterHZGC1 = 0 + counterDN2 = 0 + counterHZGC2 = 0 + counter = 0 + + #counters for number of informative allele assortments for determing paternity/maternity + inform_parents = 0 + non_paternal1 = 0 + non_maternal1 = 0 + non_paternal2 = 0 + non_maternal2 = 0 + + for line in fin.readlines(): + if ("#" in line) == 0: + linelist = line.replace("\n", "").split("\t") + chrom = linelist[headlist.index("CHROM")] + posit = linelist[headlist.index("POS")] + info = linelist[headlist.index("INFO")] + position_all.append(posit) + + #temp variable to flag if line should be used, and also check for unsupported data format (currently supports CG and Illumina GATK-style) + goline = 0 + if ((platform == "ILLUMINA") or (platform == "ILL")): + try: + mq, mq0 = vcfUtils.parse_info(info) + if mq >= mapQual and mq0 <= mapQual0 and ("PASS" in line): + goline = 1 + except UnboundLocalError: + return "Error in pedigreeUtils.phase_quartet for quartet "+":".join([fatherID, motherID, offspring1ID, offspring2ID])+" - Invalid input format: Data does not appear to be in GATK style from Illumina platform" + elif (platform == "COMPLETE") or (platform == "CG"): + goline = 1 + elif (platform == "RTG") or (platform == "rtg"): + goline = 1 + elif (platform != "COMPLETE") and (platform != "CG") and (platform != "ILLUMINA") and (platform != "ILL"): + return "Error in pedigreeUtils.phase_quartet for quartet "+":".join([fatherID, motherID, offspring1ID, offspring2ID])+": Invalid input - unknown or unsupported data format: "+platform + + if goline == 1: + geno_father = vcfUtils.allele_coder(linelist[father], depth, altDepth, gtQual, pl, platform) + geno_mother = vcfUtils.allele_coder(linelist[mother], depth, altDepth, gtQual, pl, platform) + geno_offspring1 = vcfUtils.allele_coder(linelist[offspring1], depth, altDepth, gtQual, pl, platform) + geno_offspring2 = vcfUtils.allele_coder(linelist[offspring2], depth, altDepth, gtQual, pl, platform) + + alleles2 = geno_father+","+geno_mother+","+geno_offspring1+","+geno_offspring2 + if ((("3" in alleles2) == 0) and (("4" in alleles2) == 0)): + counter+=1 + + #checks for paternity, maternity + if geno_father == "0" and geno_mother == "2": + inform_parents += 1 + if geno_offspring1 == "2": + non_paternal1 += 1 + if geno_offspring1 == "0": + non_maternal1 += 1 + if geno_offspring2 == "2": + non_paternal2 += 1 + if geno_offspring2 == "0": + non_maternal2 += 1 + + elif geno_father == "2" and geno_mother == "0": + inform_parents += 1 + if geno_offspring1 == "0": + non_paternal1 += 1 + if geno_offspring1 == "2": + non_maternal1 += 1 + if geno_offspring2 == "0": + non_paternal2 += 1 + if geno_offspring2 == "2": + non_maternal2 += 1 + + #simple de novo case + if alleles2 == "0,0,1,1": + counterDN1+=1 + counterDN2+=1 + elif alleles2 == "0,0,1,0": + counterDN1+=1 + elif alleles2 == "0,0,0,1": + counterDN2+=1 + + #hemizygosity or gene conversion case + elif (geno_father == "0" and geno_mother == "0" and geno_offspring1 == "2") or (geno_father == "1" and geno_mother == "0" and geno_offspring1 == "2") or (geno_father == "0" and geno_mother == "1" and geno_offspring1 == "2") or (geno_father == "1" and geno_mother == "2" and geno_offspring1 == "0") or (geno_father == "2" and geno_mother == "1" and geno_offspring1 == "0"): + counterHZGC1+=1 + elif (geno_father == "0" and geno_mother == "0" and geno_offspring2 == "2") or (geno_father == "1" and geno_mother == "0" and geno_offspring2 == "2") or (geno_father == "0" and geno_mother == "1" and geno_offspring2 == "2") or (geno_father == "1" and geno_mother == "2" and geno_offspring2 == "0") or (geno_father == "2" and geno_mother == "1" and geno_offspring2 == "0"): + counterHZGC2+=1 + + #creates an array of clean observations for HMM + if inmap.has_key(alleles2): + obs_seq.append(int(inmap[alleles2])) + position_clean.append(posit) + + fin.close() + + cent_np1 = float(non_paternal1)/float(inform_parents) + cent_nm1 = float(non_maternal1)/float(inform_parents) + cent_DN1 = float(counterDN1+counterHZGC1)/float(counter) + + cent_np2 = float(non_paternal2)/float(inform_parents) + cent_nm2 = float(non_maternal2)/float(inform_parents) + cent_DN2 = float(counterDN2+counterHZGC2)/float(counter) + + print "\nAllele QC summary for quartet: "+str(":".join([fatherID, motherID, offspring1ID, offspring2ID])+"\n") + print "\nNon-transmitted paternal alleles for child 1 (%): "+str(cent_np1*float(100)) + print "Non-transmitted maternal alleles for child 1 (%): "+str(cent_nm1*float(100)) + print "Novel alleles for child 1 (%): "+str(cent_DN1*float(100)) + print "\nNon-transmitted paternal alleles for child 2 (%): "+str(cent_np2*float(100)) + print "Non-transmitted maternal alleles for child 2 (%): "+str(cent_nm2*float(100)) + print "Novel alleles for child 2 (%): "+str(cent_DN2*float(100)) + + #warning for high rates of non-transmission, does not kill process + if (cent_np1) > 0.05 and (chromh != 'X'): + print "\nWARNING! High rate of non-transmission of paternal alleles in child "+offspring1ID+": consider sample mix-up or non-paternity...\n" + if (cent_np2) > 0.05 and (chromh != 'X'): + print "\nWARNING! High rate of non-transmission of paternal alleles in child "+offspring2ID+": consider sample mix-up or non-paternity...\n" + if (cent_nm1) > 0.05 and (chromh != 'X'): + print "\nWARNING! High rate of non-transmission of maternal alleles in child "+offspring1ID+": consider sample mix-up or non-maternity...\n" + if (cent_nm2) > 0.05 and (chromh != 'X'): + print "\nWARNING! High rate of non-transmission of maternal alleles in child "+offspring2ID+": consider sample mix-up or non-maternity...\n" + if (cent_DN1) > 0.05 and (chromh != 'X'): + print "\nWARNING! High rate of novel alleles in child "+offspring1ID+": consider sample mix-up or non-maternity or non-paternity...\n" + if (cent_DN2) > 0.05 and (chromh != 'X'): + print "\nWARNING! High rate of novel alleles in child "+offspring2ID+": consider sample mix-up or non-maternity or non-paternity...\n" + + #run Viterbi algorithm on HMM defined above + vit = hmmUtils.viterbi(np.array(obs_seq), states, startp, transmat, emitmat) + vit_path = vit[1] + + #bind viterbi path to position dict for annotation + for i in range(0, len(vit_path)): + res_dict[position_clean[i]] = vit_path[i] + + #temp variables to allow bridging alleles not used in HMM + firstpath = lastpath = vit_path[0] + + #create output dict with state for every position, including those not used in HMM + for i in position_all: + if res_dict.has_key(i): + phase_out.write("chr"+chromh+":"+str(i)+"\t"+str(res_dict[i])+"\n") + lastpath = res_dict[i] + else: + phase_out.write("chr"+chromh+":"+str(i)+"\t"+str(lastpath)+"\n") + end_time = time.clock() + phase_out.close() + return "Normal exit status for quartet "+":".join([fatherID, motherID, offspring1ID, offspring2ID])+". Processing time: "+str((float(end_time)-float(start_time))/float(60))+" minutes" + +#wrapper for QA hmm for trios: 0 = mierich, 1 = compression, 2 = good data +def phase_trio(fatherID, motherID, offspringID, vcf_in_stem, depth, altDepth, gtQual, mapQual, mapQual0, pl, mat_path, error, compression, mie, selfprob, platform): + + nonselfprob = str((float(1)-float(selfprob))/float(2)) + + #create matrices for HMM, all probabilities in log10 space to avoid underflow + transmat, emitmat, startp, states, inmap = hmmUtils.make_hmm(mat_path, selfprob, compression, mie, error, "t") + + #chrom_arr = ["21", "22"] + chrom_arr = ["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","X"] + + #temp file for inheritance state + phase_out = open(".".join([vcf_in_stem, fatherID, motherID, offspringID, "phase_out.txt"]), "w") + start_time=time.clock() + + for chromh in chrom_arr: + fin = open(vcf_in_stem+"_chr"+chromh+".txt", "r") + print "\nWorking on chromosome "+str(chromh)+"\n" + header = fin.readline() + + #grab proper columns from header for variants, need error message for improper input + headlist = header.replace("\n", "").split("\t") + try: + offspring = headlist.index(offspringID) + father = headlist.index(fatherID) + mother = headlist.index(motherID) + except ValueError: + return "Error in pedigreeUtils.phase_trio for trio "+":".join([fatherID, motherID, offspringID])+": Invalid input - Specified subject ID does not match vcf file header, consider malformed header or pedigree file" + + obs_seq = [] + position_clean = [] + position_all = [] + res_dict = {} + + counterDN = 0 + counterHZGC = 0 + counter = 0 + + #counter for number of informative allele assortments for determing paternity/maternity + inform_parents = 0 + non_paternal = 0 + non_maternal = 0 + + for line in fin.readlines(): + if ("#" in line) == 0: + counter+=1 + linelist = line.replace("\n", "").split("\t") + chrom = linelist[headlist.index("CHROM")] + posit = linelist[headlist.index("POS")] + info = linelist[headlist.index("INFO")] + position_all.append(posit) + + #temp variable to flag if line should be used, and also check for unsupported data format (currently supports CG and Illumina GATK-style) + goline = 0 + if ((platform == "ILLUMINA") or (platform == "ILL")): + try: + mq, mq0 = vcfUtils.parse_info(info) + if mq >= mapQual and mq0 <= mapQual0 and ("PASS" in line): + goline = 1 + except UnboundLocalError: + return "Error in pedigreeUtils.phase_trio for trio "+":".join([fatherID, motherID, offspringID])+": Data does not appear to be in GATK style from Illumina platform" + elif (platform == "COMPLETE") or (platform == "CG"): + goline = 1 + elif (platform == "RTG") or (platform == "rtg"): + goline = 1 + elif (platform != "COMPLETE") and (platform != "CG") and (platform != "ILLUMINA") and (platform != "ILL"): + return "Error in pedigreeUtils.phase_trio for trio "+":".join([fatherID, motherID, offspringID])+": Invalid input - unknown or unsupported data format: "+platform + + if goline == 1: + + geno_father = vcfUtils.allele_coder(linelist[father], depth, altDepth, gtQual, pl, platform) + geno_mother = vcfUtils.allele_coder(linelist[mother], depth, altDepth, gtQual, pl, platform) + geno_offspring = vcfUtils.allele_coder(linelist[offspring], depth, altDepth, gtQual, pl, platform) + + alleles2 = geno_father+","+geno_mother+","+geno_offspring + if ((("3" in alleles2) == 0) and (("4" in alleles2) == 0)): + counter+=1 + + #checks for paternity, maternity + if geno_father == "0" and geno_mother == "2": + inform_parents += 1 + if geno_offspring == "2": + non_paternal += 1 + if geno_offspring == "0": + non_maternal += 1 + + elif geno_father == "2" and geno_mother == "0": + inform_parents += 1 + if geno_offspring == "0": + non_paternal += 1 + if geno_offspring == "2": + non_maternal += 1 + + #simple de novo case + if alleles2 == "0,0,1": + counterDN+=1 + + #hemizygosity or gene conversion case + elif alleles2 == "0,0,2" or alleles2 == "1,0,2" or alleles2 == "0,1,2" or alleles2 == "1,2,0" or alleles2 == "2,1,0": + counterHZGC+=1 + + #creates an array of clean observations for HMM + if inmap.has_key(alleles2): + obs_seq.append(int(inmap[alleles2])) + position_clean.append(posit) + + fin.close() + + cent_np = float(non_paternal)/float(inform_parents) + cent_nm = float(non_maternal)/float(inform_parents) + cent_DN = float(counterDN+counterHZGC)/float(counter) + + print "\nAllele QC summary for trio: "+str(":".join([fatherID, motherID, offspringID])+"\n") + print "\nNon-transmitted paternal alleles (%): "+str(cent_np*float(100)) + print "Non-transmitted maternal alleles (%): "+str(cent_nm*float(100)) + print "Novel alleles (%): "+str(cent_DN*float(100)) + + #warning for high rates of non-transmission on autosomes, does not kill process + if (cent_np > 0.05) and (chromh != 'X'): + print "\nWARNING! High rate of non-transmission of paternal alleles: consider sample mix-up or non-paternity...\n" + if (cent_nm > 0.05) and (chromh != 'X'): + print "\nWARNING! High rate of non-transmission of maternal alleles: consider sample mix-up or non-maternity...\n" + if (cent_DN > 0.05) and (chromh != 'X'): + print "\nWARNING! High rate of novel alleles in child: consider sample mix-up or non-maternity or non-paternity...\n" + + fin.close() + + #run Viterbi algorithm on HMM defined above + vit = hmmUtils.viterbi(np.array(obs_seq), states, startp, transmat, emitmat) + vit_path = vit[1] + + #bind viterbi path to position dict for annotation + for i in range(0, len(vit_path)): + res_dict[position_clean[i]] = vit_path[i] + + #temp variables to allow bridging alleles not used in HMM + firstpath = lastpath = vit_path[0] + + #create output dict with state for every position, including those not used in HMM + for i in position_all: + if res_dict.has_key(i): + phase_out.write("chr"+chromh+":"+str(i)+"\t"+str(res_dict[i])+"\n") + lastpath = res_dict[i] + else: + phase_out.write("chr"+chromh+":"+str(i)+"\t"+str(lastpath)+"\n") + end_time = time.clock() + phase_out.close() + return "Normal exit status for trio "+":".join([fatherID, motherID, offspringID])+". Processing time: "+str((float(end_time)-float(start_time))/float(60))+" minutes" diff --git a/code/trio/setup.py b/code/trio/setup.py new file mode 100644 index 0000000..41666e4 --- /dev/null +++ b/code/trio/setup.py @@ -0,0 +1,11 @@ +#Rick Dewey 8.14.12 +#Last modified 8.14.12 Rick Dewey +#setup utility for cython extension module hmmUtils +#!/usr/bin/env python + +from distutils.core import setup +from distutils.extension import Extension +from Cython.Distutils import build_ext +from Cython.Build import cythonize + +setup(cmdclass = {'build_ext':build_ext}, name = "hmmUtils", ext_modules = [Extension("hmmUtils", ["hmmUtils.pyx"])]) diff --git a/code/trio/trioPipeline.py b/code/trio/trioPipeline.py new file mode 100644 index 0000000..29c2248 --- /dev/null +++ b/code/trio/trioPipeline.py @@ -0,0 +1,458 @@ +#Rick Dewey 6.29.12 +#Modified by James Priest 8.26.13 +#Python code for Trio case where offspring is affected +#usage: trioPipeline.py +#!/usr/bin/env python + +import os +import re +import fileinput +import sys +import getopt +import argparse +import math +import vcfUtils +import hmmUtils +import numpy as np +import math + + +#get args from command line +parser = argparse.ArgumentParser(description = 'Finds variants consistent with sporadic disease or autosomal recessive transmission in trios') +parser.add_argument('input', help = 'input vcf file') +parser.add_argument('output', help = 'file stem for formatted output') +parser.add_argument('annovar', help = 'annovar environment') +parser.add_argument('matrix_path', help = 'path to emission and transition matrices') +parser.add_argument('offspringID', help = 'ID for offspring') +parser.add_argument('fatherID', help = 'ID for father') +parser.add_argument('motherID', help = 'ID for mother') +parser.add_argument('-v','--annotate_variants', help = 'perform annovar annotation, default = TRUE', default = 'TRUE') +parser.add_argument('-r','--reference', help = 'reference coordinates for annovar, default hg19', default = "hg19") +parser.add_argument('-p','--dbsnp', help = 'version of dbsnp, default 135', default = "135") +parser.add_argument('-g','--gene_model', help = 'gene model, default UCSC knowngene', default = "knowngene") +parser.add_argument('-d','--depth', help = 'coverage depth threshold for inclusion, default 0', default = 0) +parser.add_argument('-a','--alt_depth', help = 'threshold for reads containing alt allele, default 0', default = 0) +parser.add_argument('-f','--allele_frequency', help = 'allele frequency cut-off for inclusion, default 0.01', default = 0.01) +parser.add_argument('-b','--background_population', nargs = "+", help = 'background population for allele frequency estimates', default = '1000g2012apr_ALL ESP6500_ALL') +parser.add_argument('-q','--gt_quality', help = 'genotype quality cut-off for inclusion, default 0', default = 0) +parser.add_argument('-m','--mapping_quality', help = 'mapping quality cut-off for inclusion, default 0', default = 0) +parser.add_argument('-z','--mq0', help = 'mapping quality 0 cut-off for inclusion, default 0', default = 0) +parser.add_argument('-l','--AVR_cutoff', help = 'user defined AVR cutoff for inclusion default 0', default = 0.0) +parser.add_argument('-e','--error_prob', help = 'per-base error estimate, default 0.005', default = 0.005) +parser.add_argument('-c','--compression_prob', help = 'emission probability for uniform heterozygosity for compressions, default 0.66', default = 0.66) +parser.add_argument('-i','--mie_prob', help = 'emission probability for MIE in MIE rich regions, default 0.33', default = 0.33) +parser.add_argument('-s','--self_transition_prob', help = 'self-self transition probability, default 0.999999', default = 0.999999) +parser.add_argument('-x','--exome', help = 'data is exome data, default FALSE', default = 'FALSE') +#parser.add_argument('-t','--platform', help = 'sequencing platform ILLUMINA, CG, or RTG', default = 'ILLUMINA') +args = parser.parse_args() + +vcf_in = args.input +final_out = args.output +depth = int(args.depth) +altDepth = int(args.alt_depth) +freq = float(args.allele_frequency) +gtQual = float(args.gt_quality) +mapQual = float(args.mapping_quality) +mapQual0 = float(args.mq0) +pl = float(args.AVR_cutoff) +mat_path = args.matrix_path +error = args.error_prob +compression = args.compression_prob +mie = args.mie_prob +selfprob = args.self_transition_prob +annovar = args.annovar +ref = args.reference +dbSNP = args.dbsnp +geneModel = args.gene_model +exome = args.exome +annotate = args.annotate_variants +backpop = args.background_population +platform = "RTG" + + +#create matrices for HMM, all probabilities in log10 space to avoid underflow +transmat, emitmat, startp, states, inmap = hmmUtils.make_hmm(mat_path, selfprob, compression, mie, error, "t") + +#will run annovar annotations if not done already, needs error message for non-vcf file input +if annotate == "TRUE": + #format vcf file for annovar (all chromosomes) + print "\nStep 1: Formatting vcf file for annovar\n" + print "Converting vcf to annovar format...\n" + os.system("perl "+annovar+"convert2annovar.pl "+vcf_in+" --includeinfo -format vcf4 > "+vcf_in.replace(".vcf", "_annovar.txt")) + + #annotate using modified annovar, annotates all variants at once to avoid slow-downs associated with loading annotation files into memory repeatedly + print "\nStep 2: Annotating variants using annovar\n" + os.system("perl "+annovar+"summarize_annovarRDv2.pl "+vcf_in.replace(".vcf", "_annovar.txt ")+annovar+"humandb/ --buildver "+ref+" --verdbsnp "+dbSNP+" --genetype "+geneModel+" --remove") + + #reformat header for hmm and sporadic trio allele finding + print "\nStep 3: Adding vcf header to annotated vcf file\n" + temp = open(vcf_in.replace(".vcf", "_annovar.txt.genome_summary.txt"), "r") + head1 = temp.readline() + headvcf = vcfUtils.get_head(vcf_in) + newhead = head1.replace("Otherinfo\n", headvcf) + + annovar_out = open(vcf_in.replace(".vcf", "_genome_summary_formattedALL.txt"), "w") + annovar_out.write(newhead) + for line in temp: + annovar_out.write(line) + annovar_out.close() + temp.close() + os.system("rm "+vcf_in.replace(".vcf", "_annovar.txt.genome_summary.txt")) + +#otherwise skips annovar annotation +else: + print "\nVariants are already annotated. Skipping steps 1-3." + +#only run QA hmm on genome data +if exome == "FALSE": + print "\nPreparing data for QA HMM...\n" + + #split annotated vcf file for HMM + if annotate == "TRUE": + vcfUtils.splitFiles(vcf_in.replace(".vcf", "_genome_summary_formattedALL.txt"), vcf_in.replace(".vcf", "_genome_summary_formatted")) + else: + vcfUtils.splitFiles(vcf_in, vcf_in.replace(".txt", "_genome_summary_formatted")) + + #QA hmm + print "\nStep 4: Running QA HMM" + + chrom_arr = ["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","X"] + + for chromh in chrom_arr: + print "\nWorking on chromosome: "+str(chromh) + if annotate == "TRUE": + fin = open(vcf_in.replace(".vcf", "_genome_summary_formatted")+"_chr"+chromh+".txt", "r") + else: + fin = open(vcf_in.replace(".txt", "_genome_summary_formatted")+"_chr"+chromh+".txt", "r") + + header = fin.readline() + #grab proper columns from header for variants, need error message for improper input + headlist = header.replace("\n", "").split("\t") + offspring = headlist.index(args.offspringID) + father = headlist.index(args.fatherID) + mother = headlist.index(args.motherID) + + obs_seq = [] + position = [] + res_dict = {} + + counterDN = 0 + counterHZGC = 0 + counter = 0 + + #counter for number of informative allele assortments for determing paternity/maternity + inform_parents = 0 + non_paternal = 0 + non_maternal = 0 + + print "Checking sample consistency and creating observation array..." + + for line in fin.readlines(): + counter+=1 + linelist = line.split("\t") + chrom = linelist[headlist.index("CHROM")] + posit = linelist[headlist.index("POS")] + info = linelist[headlist.index("INFO")] + #format = linelist[headlist.index("FORMAT")] + mq, mq0 = vcfUtils.parse_info(info) + + if ("#" in line) == 0 and mq >= mapQual and mq0 <= mapQual0 and ("PASS" in line): + #stat_locations = vcfUtils.stat_grabber(linelist + geno_father = vcfUtils.allele_coder(linelist[father], depth, altDepth, gtQual, pl, platform) + geno_mother = vcfUtils.allele_coder(linelist[mother], depth, altDepth, gtQual, pl, platform) + geno_offspring = vcfUtils.allele_coder(linelist[offspring], depth, altDepth, gtQual, pl, platform) + + alleles2 = geno_father+","+geno_mother+","+geno_offspring + if ((("3" in alleles2) == 0) and (("4" in alleles2) == 0)): + counter+=1 + + #checks for paternity, maternity + if geno_father == "0" and geno_mother == "2": + inform_parents += 1 + if geno_offspring == "2": + non_paternal += 1 + if geno_offspring == "0": + non_maternal += 1 + + elif geno_father == "2" and geno_mother == "0": + inform_parents += 1 + if geno_offspring == "0": + non_paternal += 1 + if geno_offspring == "2": + non_maternal += 1 + + #simple de novo case + if alleles2 == "0,0,1": + counterDN+=1 + + #hemizygosity or gene conversion case + elif alleles2 == "0,0,2" or alleles2 == "1,0,2" or alleles2 == "0,1,2" or alleles2 == "1,2,0" or alleles2 == "2,1,0": + counterHZGC+=1 + + #creates an array of clean observations for HMM + if inmap.has_key(alleles2): + obs_seq.append(int(inmap[alleles2])) + position.append(posit) + + fin.close() + + cent_np = float(non_paternal)/float(inform_parents) + cent_nm = float(non_maternal)/float(inform_parents) + cent_DN = float(counterDN+counterHZGC)/float(counter) + + print "...Done" + + print "\nNon-transmitted paternal alleles (%): "+str(cent_np*float(100)) + print "Non-transmitted maternal alleles (%): "+str(cent_nm*float(100)) + print "Novel alleles (%): "+str(cent_DN*float(100)) + + #warning for high rates of non-transmission + if cent_np > 0.05: + print "\nWARNING! High rate of non-transmission of paternal alleles: consider sample mix-up or non-paternity...\n" + if cent_nm > 0.05: + print "\nWARNING! High rate of non-transmission of maternal alleles: consider sample mix-up or non-maternity...\n" + if cent_DN > 0.05: + print "\nWARNING! High rate of novel alleles in child: consider sample mix-up or non-maternity or non-paternity...\n" + + print "\nRunning HMM..." + + #run Viterbi algorithm on HMM defined above + vit = hmmUtils.viterbi(np.array(obs_seq), states, startp, transmat, emitmat) + vit_path = vit[1] + + #bind viterbi path to position dict for annotation + for i in range(0, len(vit_path)): + res_dict[position[i]] = vit_path[i] + + print "...Done" + + if annotate == "TRUE": + print "\nWriting to output file "+vcf_in.replace(".vcf", "_chr"+chromh+"_annotated_hmmfiltered.txt") + fin = open(vcf_in.replace(".vcf", "_genome_summary_formatted")+"_chr"+chromh+".txt", "r") + fout = open(vcf_in.replace(".vcf", "_chr"+chromh+"_annotated_hmmfiltered.txt"), "w") + else: + print "\nWriting to output file "+vcf_in.replace(".txt", "_chr"+chromh+"_annotated_hmmfiltered.txt") + fin = open(vcf_in.replace(".txt", "_genome_summary_formatted")+"_chr"+chromh+".txt", "r") + fout = open(vcf_in.replace(".txt", "_chr"+chromh+"_annotated_hmmfiltered.txt"), "w") + + header = fin.readline() + fout.write(header) + + #temp variables to allow bridging alleles not used in HMM + firstpath = vit_path[0] + lastpath = firstpath + + for line in fin.readlines(): + + if ("#" in line) == 0: + linelist = line.split("\t") + chrom = linelist[headlist.index("CHROM")] + posit = linelist[headlist.index("POS")] + info = linelist[headlist.index("INFO")] + format = linelist[headlist.index("FORMAT")] + filter_field = linelist[headlist.index("FILTER")] + + #write filter flag for MIE/compression if it is present, none if otherwise + if res_dict.has_key(posit): + if res_dict[posit] == 0: + fout.write(line.replace(filter_field, "MIEregion")) + elif res_dict[posit] == 1: + fout.write(line.replace(filter_field, "CompressionRegion")) + elif res_dict[posit] == 2: + fout.write(line) + else: + print res_dict[posit] + lastpath = res_dict[posit] + + #uses filter from last position if not used in HMM + else: + if lastpath == 0: + if ("PASS" in line) == 0: + fout.write(line.replace(filter_field, filter_field+";MIEregion")) + else: + fout.write(line.replace(filter_field, "MIEregion")) + elif lastpath == 1: + if ("PASS" in line) == 0: + fout.write(line.replace(filter_field, filter_field+";CompressionRegion")) + else: + fout.write(line.replace(filter_field, "CompressionRegion")) + elif lastpath == 2: + fout.write(line) + + else: + fout.write(line) + fin.close() + + if annotate == "TRUE": + os.system("rm "+vcf_in.replace(".vcf", "_genome_summary_formatted")+"_chr"+chromh+".txt") + else: + os.system("rm "+vcf_in.replace(".txt", "_genome_summary_formatted")+"_chr"+chromh+".txt") + + fout.close() + + print "\nMerging files...\n" + + #merge annotated file for downstream tools + if annotate == "TRUE": + vcfUtils.mergeFiles(vcf_in.replace(".vcf", ""), vcf_in.replace(".vcf", "_annotated_hmmfilteredALL.txt")) + else: + vcfUtils.mergeFiles(vcf_in.replace(".txt", ""), vcf_in.replace(".txt", "_annotated_hmmfilteredALL.txt")) + +else: + print "\nExome data: Skipping step 4 (hmm QA)" + +#specific to sporadic trio allele finding +print "\nStep 5: finding alleles consistent with sporadic disease\n" + +if exome == "FALSE" and annotate == "TRUE": + fin = open(vcf_in.replace(".vcf", "_annotated_hmmfilteredALL.txt"), "r") +elif exome == "FALSE" and annotate == "FALSE": + fin = open(vcf_in.replace(".txt", "_annotated_hmmfilteredALL.txt"), "r") +elif exome == "TRUE" and annotate == "TRUE": + fin = open(vcf_in.replace(".vcf", "_genome_summary_formattedALL.txt"), "r") +elif exome == "TRUE" and annotate == "FALSE": + fin = open(vcf_in, "r") + +deNovo = open(final_out+"_deNovo.txt", "w") +rareHomozygous = open(final_out+"_homozygousRare.txt", "w") +compoundHet = open(final_out+"_compoundHet.txt", "w") +deNovoComplex = open(final_out+"_hemizygousGC.txt", "w") + +counterDN = 0 +counterRH = 0 +counterCH = 0 +counterHZGC = 0 +counter = 0 + +#array and dicts for compound het finder +gene_found = [] +gene_dict_pat = {} +gene_dict_mat = {} +wrote_dict = {} + +header = fin.readline() +deNovo.write(header) +rareHomozygous.write(header) +compoundHet.write(header) +deNovoComplex.write(header) +headlist = header.replace("\n", "").split("\t") +backpopindex = vcfUtils.get_listindex(headlist, backpop) +offspring = headlist.index(args.offspringID) +father = headlist.index(args.fatherID) +mother = headlist.index(args.motherID) + +MIEcounter = 0 +n_confident = 0 +oimputedcounter = 0 +mimputedcounter = 0 +fimputedcounter = 0 + +#read in and parse vcf formatted file +for line in fin.readlines(): + counter+=1 + linelist = line.split("\t") + chrom = linelist[headlist.index("CHROM")] + posit = linelist[headlist.index("POS")] + info = linelist[headlist.index("INFO")] + formatstats_avr_dp_rq = linelist[headlist.index("FORMAT")] + #print "\npipeline info "+str(info) + #print "\npipeline mq, mq0 "+str(mq)+" "+str(mq0) + mq, mq0 = vcfUtils.parse_info(info) + #print "\nstats field "+str(formatstats_avr_dp_rq) + avr_num, dp_num, rq_num, gq_num = vcfUtils.parse_format(formatstats_avr_dp_rq) + +#RQ The phred scaled posterior probability that the sample is not identical to the reference. +#GQ The standard VCF format genotype quality field. This is the phred scaled posterior score of the call. It is not necessarily the same as the QUAL column score. + + if ("#" in line) == 0: + #print "\nline "+str(line) + geno_father = vcfUtils.allele_coder(linelist[father], depth, altDepth, gtQual, pl, avr_num, dp_num, rq_num, gq_num, "RTG") + geno_mother = vcfUtils.allele_coder(linelist[mother], depth, altDepth, gtQual, pl, avr_num, dp_num, rq_num, gq_num, "RTG") + geno_offspring = vcfUtils.allele_coder(linelist[offspring], depth, altDepth, gtQual, pl, avr_num, dp_num, rq_num, gq_num, "RTG") + alleles2 = geno_father+","+geno_mother+","+geno_offspring + gene = linelist[headlist.index("Gene")] + #This bit looks for imputed genotypes in the offspring only + gto_list = linelist[offspring].split(":") + if (int(gto_list[dp_num]) == 0): + oimputedcounter+=1 + gto_list = linelist[mother].split(":") + if (int(gto_list[dp_num]) == 0): + mimputedcounter+=1 + gto_list = linelist[father].split(":") + if (int(gto_list[dp_num]) == 0): + fimputedcounter+=1 + if ((("3" in alleles2) == 0) and (("4" in alleles2) == 0)): + tempcode = int(inmap[alleles2]) + n_confident+=1 + if tempcode in [1, 2, 5, 6, 8, 11, 15, 18, 20, 21, 24, 25]: + MIEcounter+=1 + + if ("#" in line) == 0 and vcfUtils.is_rare(line, freq, backpopindex) and mq >= mapQual and mq0 <= mapQual0: + + if ((("3" in alleles2) == 0) and (("4" in alleles2) == 0)): + + #simple de novo case + if alleles2 == "0,0,1": + deNovo.write(line) + counterDN+=1 + + #rare homozygous case + elif alleles2 == "1,1,2": + rareHomozygous.write(line) + counterRH+=1 + + #hemizygosity or gene conversion case + elif alleles2 == "0,0,2" or alleles2 == "1,0,2" or alleles2 == "0,1,2" or alleles2 == "1,2,0" or alleles2 == "2,1,0": + deNovoComplex.write(line) + counterHZGC+=1 + + #compound het case + if gene_found.count(gene) >= 1: + if gene_dict_mat.has_key(gene) and (alleles2 == "1,0,1"): + oldlist = gene_dict_mat[gene].split("\t") + chrom2 = oldlist[headlist.index("CHROM")] + posit2 = oldlist[headlist.index("POS")] + if wrote_dict.has_key(chrom2+":"+posit2) == 0: + compoundHet.write(gene_dict_mat[gene]) + wrote_dict[chrom2+":"+posit2] = 1 + counterCH+=1 + compoundHet.write(line) + wrote_dict[chrom+":"+posit] = 1 + gene_dict_pat[gene] = line + counterCH+=1 + elif gene_dict_pat.has_key(gene) and (alleles2 == "0,1,1"): + oldlist = gene_dict_pat[gene].split("\t") + chrom2 = oldlist[headlist.index("CHROM")] + posit2 = oldlist[headlist.index("POS")] + if wrote_dict.has_key(chrom2+":"+posit2) == 0: + compoundHet.write(gene_dict_pat[gene]) + wrote_dict[chrom2+":"+posit2] = 1 + counterCH+=1 + compoundHet.write(line) + wrote_dict[chrom+":"+posit] = 1 + gene_dict_mat[gene] = line + counterCH+=1 + elif (alleles2 == "0,1,1"): + gene_dict_mat[gene] = line + gene_found.append(gene) + elif (alleles2 == "1,0,1"): + gene_dict_pat[gene] = line + gene_found.append(gene) + + if counter%500000 == 0: + print "Processed "+str(counter)+" records" + +print "\nRare de novo candidates: "+str(counterDN) +print "Rare homozygous candidates: "+str(counterRH) +print "Rare compound heterozygous candidates: "+str(counterCH) +print "Rare hemizygous or gene conversion candidates: "+str(counterHZGC) +print "MIE count: "+str(MIEcounter) +print "Confidently genotyped variants: "+str(n_confident) +print "Imputed variants in offspring: "+str(oimputedcounter) +print "Imputed variants in mother: "+str(mimputedcounter) +print "Imputed variants in father: "+str(fimputedcounter) + +fin.close() +deNovo.close() +rareHomozygous.close() +compoundHet.close() diff --git a/code/trio/vcfUtils.py b/code/trio/vcfUtils.py new file mode 100644 index 0000000..4584dbd --- /dev/null +++ b/code/trio/vcfUtils.py @@ -0,0 +1,391 @@ +#Rick Dewey 5.22.12 +#Last modified 8.22.13 James Priest +#module for general vcf utilities +#usage: utils module for vcf parsing +#!/usr/bin/env python + +import os +import re +import sys + +#gets proper head from vcf file, ignoring all other stuff +def get_head(infile): + f1 = open(infile, "r") + while True: + line = f1.readline() + if "CHROM" in line: + head = line.replace("#", "") + break + if not line: + print >> sys.stderr, "Error in vcfUtils.get_head - End of file reached prior to finding vcf header: vcf header is likely malformed" + exit(1) + f1.close() + return head + +#gets indexes from head of annotation file for downstream filtering/annotation +def get_listindex(head_list, viplist): + indexlist = [] + tempindex = 0 + for item in head_list: + if item in viplist: + indexlist.append(tempindex) + tempindex+=1 + return indexlist + +#parses vcf format genotypes into allele codes, works for bialleleic positions, need to update for multiallelic positions, works for GATK standard vcf format only so far +def allele_coder(GT, d, alt, q, p, avr_n, dp_n, rq_n, gq_n, data_type): + #deals with illumina format vcf files + if (data_type == "ILLUMINA") or (data_type == "ILL"): + likelihoodvec = gt_list[4].split(",") + print "\nlike vec "+str(likelihoodvec) + if ("./." in GT) == 0: + gt_list = GT.split(":") + gq = float(gt_list[3]) + temp = gt_list[1].split(",") + if not ".:." in GT: + #if int(temp[1]) != ".": + al = int(temp[1]) + totalDepth = int(temp[0])+int(temp[1]) + # handles imputed genotypes from GATK phase by transmission tool which may impute genotypes without read information + if ".:." in GT: + al = 0 + totalDepth = 0 + + if (gt_list[0] == "0/1" or gt_list[0] == "0|1" and totalDepth >= d and gq >= q and al >= alt and int(likelihoodvec[1]) <= p): + alleles = "1" + elif (gt_list[0] == "1|0" and totalDepth >= d and gq >= q and int(temp[0]) >= alt and int(likelihoodvec[0]) <= p): + alleles = "1" + elif (gt_list[0] == "1/1" or gt_list[0] == "1|1" and totalDepth >= d and gq >= q and al >= alt and int(likelihoodvec[2]) <= p): + alleles = "2" + elif (gt_list[0] == "0/0" or gt_list[0] == "0|0" and totalDepth >= d and gq >= q and int(likelihoodvec[0]) <= p): + alleles = "0" + + #3 for alleles not meeting filtering criteria + else: + alleles = "3" + + #4 for alleles not called + else: + alleles = "4" + return alleles + + #deals with complete genomics format vcf files + if (data_type == "COMPLETE") or (data_type == "CG"): + if ("./." in GT) == 0: + gt_list = GT.split(":") + if gt_list[0] == "0/1" or gt_list[0] == "0|1" or gt_list[0] == "1|0": + alleles = "1" + elif gt_list[0] == "1/1" or gt_list[0] == "1|1": + alleles = "2" + elif gt_list[0] == "0/0" or gt_list[0] == "0|0": + alleles = "0" + else: + alleles = "3" + + #4 for alleles not called + else: + alleles = "4" + return alleles + + #deals with RTG vcf files + #AVR definition: adaptive variant rescoring value. It is a value between 0 and 1 that represents the probability that the variant for the sample is correct. + #In the RTG version of the allele coder, likelihoodvec stores the AVR value, the --post_hoc_filter_cutoff represents the lower limit for inclusion + #Cutoffs occur if the likelihoodvec is < p or pl + if (data_type == "RTG") or (data_type == "rtg"): + #print "\nGT "+str(GT) + if ("./." in GT) == 0: + gt_list = GT.split(":") + likelihoodvec = float(gt_list[avr_n]) + gq = float(gt_list[gq_n]) + totalDepth = int(gt_list[dp_n]) + #print "\n p "+str(p)," AVR "+str(likelihoodvec) + if (gt_list[0] == "1/1" or gt_list[0] == "1|1"): + al = totalDepth * 0.5 + if totalDepth != 0: + #In RTG formatted vcf files, the alternate allele depth not reported in the stats field + al = int(99) + #totalDepth = int(temp[0])+int(temp[1]) + #print "\ntotaldepth "+str(totalDepth), "\nal "+str(al), "\nlikelihoodvec "+str(likelihoodvec), "\ngq "+str(gq) + # handles imputed genotypes from RTG which may impute genotypes without read information + if totalDepth == 0: + al = 0 + #print "\ntotaldepth "+str(totalDepth), "\nal "+str(al), "\nlikelihoodvec "+str(likelihoodvec), "\ngq "+str(gq) + + if (gt_list[0] == "0/1" or gt_list[0] == "0|1" and totalDepth >= d and gq >= q and al >= alt and likelihoodvec >= p): + alleles = "1" + #print "\ntotaldepth "+str(totalDepth), "\nal "+str(al), "\nlikelihoodvec "+str(likelihoodvec), "\ngq "+str(gq) + elif (gt_list[0] == "1|0" and totalDepth >= d and gq >= q and al >= alt and likelihoodvec >= p): + alleles = "1" + #print "\ntotaldepth "+str(totalDepth), "\nal "+str(al), "\nlikelihoodvec "+ likelihoodvec), "\ngq "+str(gq) + elif (gt_list[0] == "1/1" or gt_list[0] == "1|1" and totalDepth >= d and gq >= q and al >= alt and likelihoodvec >= p): + alleles = "2" + #print "\ntotaldepth "+str(totalDepth), "\nal "+str(al), "\nlikelihoodvec "+str(likelihoodvec), "\ngq "+str(gq) + elif (gt_list[0] == "0/0" or gt_list[0] == "0|0" and totalDepth >= d and gq >= q and likelihoodvec >= p): + #print "\ntotaldepth "+str(totalDepth), "\nal "+str(al), "\nlikelihoodvec "+str(likelihoodvec), "\ngq "+str(gq) + alleles = "0" + #print "\ntotaldepth "+str(totalDepth), "\nal "+str(al), "\nlikelihoodvec "+str(likelihoodvec), "\ngq "+str(gq) + #3 for alleles not meeting filtering criteria + else: + alleles = "3" + + #4 for alleles not called + else: + alleles = "4" + return alleles + + else: + print >> sys.stderr, "Invalid input - unknown or unsupported data format: "+data_type + exit(1) + + +#boolean, returns 1 for a variant with frequency below threshold (for all background populations consider) or novel or unknown allele frequency, 0 otherwise +def is_rare(templine, freq_thresh, bp_indexlist): + templinelist = templine.split("\t") + rare_flag = 1 + for i in bp_indexlist: + if templinelist[i] != "": + if float(templinelist[i]) > float(freq_thresh): + rare_flag = 0 + return rare_flag + +#boolean, returns 1 for a variant with user-defined functional properties as annotated by annovar +def is_functional(templine, function_list): + functional = 0 + if ("stoploss" in templine) and ("stoploss" in function_list): + functional=1 + elif ("stopgain" in templine) and ("stopgain" in function_list): + functional=1 + elif ("splicing" in templine) and ("splicing" in function_list): + functional=1 + elif ("frameshift" in templine) and (("nonframeshift" in templine) == 0) and ("frameshift" in function_list): + functional=1 + elif ("nonframeshift" in templine) and ("nonframeshift" in function_list): + functional=1 + elif ("nonsynonymous" in templine) and ("nonsynonymous" in function_list): + functional=1 + elif ("synonymous" in templine) and (("nonsynonymous" in templine) == 0) and ("synonymous" in function_list): + functional=1 + elif ("exonic" in templine) and ("exonic" in function_list): + functional=1 + elif ("intronic" in templine) and ("intronic" in function_list): + functional=1 + elif ("UTR5" in templine) and ("UTR5" in function_list): + functional=1 + elif ("UTR3" in templine) and ("UTR3" in function_list): + functional=1 + elif ("ncRNA" in templine) and ("ncRNA" in function_list): + functional=1 + elif ("upstream" in templine) and ("upstream" in function_list): + functional=1 + elif ("intergenic" in templine) and ("intergenic" in function_list): + functional=1 + elif ("downstream" in templine) and ("downstream" in function_list): + functional=1 + return functional + +#boolean, returns 1 for variant that is conserved according to user-defined criteria +def is_conserved(templine, cons_list, cons_criteria): + templinelist = templine.split("\t") + phyloP = templinelist[headlist.index("LJB_PhyloP_Pred")] + gerp = templinelist[headlist.index("LJB_GERP++")] + if gerp != "": + gerp = float(gerp) + if gerp >= 2.0 or phyloP == "C": + return 1 + else: + return 0 + elif phyloP == "C": + return 1 + else: + return 0 + +#boolean, returns 1 for variant that is pathogenic according to user-defined criteria +def is_pathogenic(templine, path_list, path_criteria): + templinelist = templine.split("\t") + pathogenic = 0 + sift = templinelist[headlist.index("LJB_SIFT_Pred")] + pp2 = templinelist[headlist.index("LJB_PolyPhen2_Pred")] + lrt = templinelist[headlist.index("LJB_LRT_Pred")] + mt = templinelist[headlist.index("LJB_MutationTaster_Pred")] + if sift == "D": + pathogenic+=1 + if (pp2 == "P") or (pp2 == "D"): + pathogenic+=1 + if lrt == "D": + pathogenic+=1 + if (mt == "A") or (mt == "D"): + pathogenic+=1 + if pathogenic >= int(nalg): + return 1 + else: + return 0 + +#parses info field of vcf file and returns tuple float for mq and mq0 +def parse_info(infofield): + infolist = infofield.split(";") + #print "\nutils before infofield "+str(infofield) + mapq = "" + mapq0 = "" + #print "\nutils before mapq, mapq0 "+str(mapq)+" "+str(mapq0) + for element in infolist: + if "MQ=" in element: + mapq=float(element.replace("MQ=", "")) + elif "MQ0=" in element: + mapq0=float(element.replace("MQ0=", "")) + #print "\nutils after infofield "+str(infofield) + #print "\nutils mapq, mapq0 "+str(mapq)+" "+str(mapq0) + return mapq, mapq0 + +#parses format field of vcf file to find location of AVR, DP, RQ +def parse_format(formatstats): + temp2 = formatstats.split(':') + counter = 0 + avr_num = 0 + dp_num = 0 + rq_num = 0 + gq_num = 0 + for infos in temp2: + if (str(infos) == "AVR"): + avr_num = int(counter) + if (str(infos) == "DP"): + dp_num = int(counter) + if (str(infos) == "RQ"): + rq_num = int(counter) + if (str(infos) == "GQ"): + gq_num = int(counter) + counter+=1 + return avr_num, dp_num, rq_num, gq_num + + + +#merges vcf files split by chromosome, writing head from chromosome 1 to X only for now +def mergeFiles(fin_stem, f_out): + chrom_arr = ["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","X"] + + fout = open(f_out, "w") + + for chrom in chrom_arr: + fin = open(fin_stem+"_chr"+chrom+"_annotated_hmmfiltered.txt", "r") + head = fin.readline() + if chrom == "1": + fout.write(head) + + for line in fin.readlines(): + fout.write(line) + fin.close() + os.system("rm "+fin_stem+"_chr"+chrom+"_annotated_hmmfiltered.txt") + fout.close() + +#splits vcf file by chromosome, to X only for now +def splitFiles(f_in, fout_stem): + chrom_arr = ["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","X"] + + try: + fin = open(f_in, "r") + except IOError: + print >> sys.stderr, "Error in vcfUtils.splitFiles: Cannot open input vcf file "+f_in + exit(1) + + head = get_head(f_in) + try: + f1 = open(fout_stem+"_chr1.txt", "w") + f1.write(head) + f2 = open(fout_stem+"_chr2.txt", "w") + f2.write(head) + f3 = open(fout_stem+"_chr3.txt", "w") + f3.write(head) + f4 = open(fout_stem+"_chr4.txt", "w") + f4.write(head) + f5 = open(fout_stem+"_chr5.txt", "w") + f5.write(head) + f6 = open(fout_stem+"_chr6.txt", "w") + f6.write(head) + f7 = open(fout_stem+"_chr7.txt", "w") + f7.write(head) + f8 = open(fout_stem+"_chr8.txt", "w") + f8.write(head) + f9 = open(fout_stem+"_chr9.txt", "w") + f9.write(head) + f10 = open(fout_stem+"_chr10.txt", "w") + f10.write(head) + f11 = open(fout_stem+"_chr11.txt", "w") + f11.write(head) + f12 = open(fout_stem+"_chr12.txt", "w") + f12.write(head) + f13 = open(fout_stem+"_chr13.txt", "w") + f13.write(head) + f14 = open(fout_stem+"_chr14.txt", "w") + f14.write(head) + f15 = open(fout_stem+"_chr15.txt", "w") + f15.write(head) + f16 = open(fout_stem+"_chr16.txt", "w") + f16.write(head) + f17 = open(fout_stem+"_chr17.txt", "w") + f17.write(head) + f18 = open(fout_stem+"_chr18.txt", "w") + f18.write(head) + f19 = open(fout_stem+"_chr19.txt", "w") + f19.write(head) + f20 = open(fout_stem+"_chr20.txt", "w") + f20.write(head) + f21 = open(fout_stem+"_chr21.txt", "w") + f21.write(head) + f22 = open(fout_stem+"_chr22.txt", "w") + f22.write(head) + fX = open(fout_stem+"_chrX.txt", "w") + fX.write(head) + except IOError: + print >> sys.stderr, "Error in vcfUtils.splitFiles: Improper output file specification "+f_in + exit(1) + + while 1: + temp = fin.readline() + if not temp: + break + else: + if ("chr1\t" in temp) and (('#' in temp) == 0): + f1.write(temp) + if ("chr2\t" in temp) and (('#' in temp) == 0): + f2.write(temp) + if ("chr3\t" in temp) and (('#' in temp) == 0): + f3.write(temp) + if ("chr4\t" in temp) and (('#' in temp) == 0): + f4.write(temp) + if ("chr5\t" in temp) and (('#' in temp) == 0): + f5.write(temp) + if ("chr6\t" in temp) and (('#' in temp) == 0): + f6.write(temp) + if ("chr7\t" in temp) and (('#' in temp) == 0): + f7.write(temp) + if ("chr8\t" in temp) and (('#' in temp) == 0): + f8.write(temp) + if ("chr9\t" in temp) and (('#' in temp) == 0): + f9.write(temp) + if ("chr10\t" in temp) and (('#' in temp) == 0): + f10.write(temp) + if ("chr11\t" in temp) and (('#' in temp) == 0): + f11.write(temp) + if ("chr12\t" in temp) and (('#' in temp) == 0): + f12.write(temp) + if ("chr13\t" in temp) and (('#' in temp) == 0): + f13.write(temp) + if ("chr14\t" in temp) and (('#' in temp) == 0): + f14.write(temp) + if ("chr15\t" in temp) and (('#' in temp) == 0): + f15.write(temp) + if ("chr16\t" in temp) and (('#' in temp) == 0): + f16.write(temp) + if ("chr17\t" in temp) and (('#' in temp) == 0): + f17.write(temp) + if ("chr18\t" in temp) and (('#' in temp) == 0): + f18.write(temp) + if ("chr19\t" in temp) and (('#' in temp) == 0): + f19.write(temp) + if ("chr20\t" in temp) and (('#' in temp) == 0): + f20.write(temp) + if ("chr21\t" in temp) and (('#' in temp) == 0): + f21.write(temp) + if ("chr22\t" in temp) and (('#' in temp) == 0): + f22.write(temp) + if ("chrX\t" in temp) and (('#' in temp) == 0): + fX.write(temp) diff --git a/code/vcfHeaders.py b/code/vcfHeaders.py new file mode 100644 index 0000000..e6aefa4 --- /dev/null +++ b/code/vcfHeaders.py @@ -0,0 +1,80 @@ +# list of VCF headers from the annotated output file that are used in vcfUtils + +# consts +kCLINVAR_CLNREVSTAT_NO_ASSERTION = 'no_assertion_criteria_provided' +kCLINVAR_CLNREVSTAT_YES_ASSERTION = 'criteria_provided' +kCLINVAR_CLNREVSTAT_ONE_SUBMITTER = 'single_submitter' +kCLINVAR_CLNREVSTAT_CONFLICTING_INTERPS = 'conflicting_interpretations' +# TODO maybe pull the below codes from their definition in the clinvar VCF on import +kCLINVAR_CLINSIG_NOT_PROVIDED_CODE = 1 +kCLINVAR_CLINSIG_BENIGN_CODE = 2 +kCLINVAR_CLINSIG_LIKELY_BENIGN_CODE = 3 +kCLINVAR_CLINSIG_LIKELY_PATHOGENIC_CODE = 4 +kCLINVAR_CLINSIG_PATHOGENIC_CODE = 5 +kCLINVAR_CLINSIG_DRUG_RESPONSE_CODE = 6 +kCLINVAR_CLINSIG_HISTOCOMPATIBILITY_CODE = 7 +kCLINVAR_CLINSIG_OTHER_CODE = 255 + +# clinvar headers +kClinvarClinSigHeader = 'CLNSIG' +kClinvarClinRevStatusHeader = 'CLNREVSTAT' +kClinvarStarHeader = 'CLNSTARS' # added by us + +# SQL data types for standard VCF columns +# KEYS MUST BE ALL LOWERCASE since we're doing a case insensitive lookup by converting the search term to lowercase +kVCFColTypes = { + 'chrom': 'varchar(10)', + 'start': 'int', + 'pos': 'int', # same as start + 'id': 'varchar(127)', + 'ref': 'varchar(512)', + 'alt': 'varchar(512)', + 'qual': 'varchar(127)', + 'filter': 'varchar(127)' + # there shoudn't be a definition for the INFO col bc we're only importing specific tags + } +# kVCFColTypeChrom = 'varchar(10)' +# kVCFColTypeStart = 'int' +# kVCFColTypeID = 'varchar(127)' +# kVCFColTypeRef = 'varchar(512)' +# kVCFColTypeAlt = 'varchar(512)' +# kVCFColTypeQual = 'varchar(127)' +# kVCFColTypeFilter = 'varchar(127)' + + +# for rare variant identification +kHapMap2And3_CEU = 'hg19_hapmap2and3_CEU_info' +k1000g_all = 'hg19_popfreq_all_20150413_1000g_all' +k1000g_eur = 'hg19_popfreq_all_20150413_1000g_eur' +kCg69 = 'hg19_cg69_info' +kEsp6500si_ALL = 'hg19_popfreq_all_20150413_esp6500siv2_all' +kEsp6500si_EA = 'hg19_popfreq_all_20150413_esp6500siv2_ea' + +k_hapmap2and3_CHB = 'hg19_hapmap2and3_CHB_info' +k_1000g_ASN = '1000g2012apr_ASN' # warning missing +k_hapmap2and3_YRI = 'hg19_hapmap2and3_YRI_info' +k_esp6500si_AA = 'hg19_popfreq_all_20150413_esp6500siv2_aa' +k1000g_afr = 'hg19_popfreq_all_20150413_1000g_afr' + +# for tiering +kClinvar = 'clinvar_info' +kEncode_dnaseCluster = 'hg19_wgEncodeRegDnaseClustered_r' +kPhyloP_pred = "dbnsfp_PhyloP_Pred" # warning currently not in annotated output file +# kGerp = 'dbnsfp_GERP++' # warning not in annotation +# kGerp = 'GERP++_RS' # check +kPhastConsElts46Way = 'hg19_phastConsElements46way_r_MSA_MCE_score' +# kWg_gerp = 'wg_GERP++_gt2' # warning not in annotation +kWg_gerp = 'hg19_ljb26_all_GERP++_RS' +# kGerp = '' # currently not mapped -- use kWg_gerp instead +kGerp = kWg_gerp # for now + + +# kSiftPred = 'dbnsfp_SIFT_Pred' +kSiftPred = 'hg19_ljb26_all_SIFT_pred' +# kPolyphen2Pred = 'dbnsfp_PolyPhen2_Pred' +kPolyphen2Pred = 'hg19_ljb26_all_Polyphen2_HVAR_pred' # or polyphen2_HDIV_pred +kPolyphen2Pred_2 = 'hg19_ljb26_all_Polyphen2_HDIV_pred' +# kLrtPred = 'dbnsfp_LRT_Pred' +kLrtPred = 'hg19_ljb26_all_LRT_pred' +# kMutationTasterPred = 'dbnsfp_MutationTaster_Pred' +kMutationTasterPred = 'hg19_ljb26_all_MutationTaster_pred' diff --git a/code/vcfUtils.py b/code/vcfUtils.py new file mode 100644 index 0000000..ef2c456 --- /dev/null +++ b/code/vcfUtils.py @@ -0,0 +1,618 @@ +#Rick Dewey 5.22.12 +#Last modified 1.26.14 Rick Dewey +#module for general vcf utilities +#usage: utils module for vcf parsing +#!/usr/bin/env python + +import os +import re +import sys +import vcfHeaders + +#gets proper head from vcf file, ignoring all other stuff +def get_head(infile): + f1 = open(infile, "r") + while True: + line = f1.readline() + if "#CHROM" in line: + head = line.replace("#", "") + break + if not line: + print >> sys.stderr, "Error in vcfUtils.get_head - End of file reached prior to finding vcf header: vcf header is likely malformed" + exit(1) + f1.close() + return head + +#gets indexes from head of annotation file for downstream filtering/annotation +def get_listindex(head_list, viplist): + indexlist = [] + tempindex = 0 + for item in head_list: + if item in viplist: + indexlist.append(tempindex) + tempindex+=1 + return indexlist + +#parses vcf format genotypes into allele codes, works for bialleleic positions, need to update for multiallelic positions +def allele_coder(GT, d, alt, q, p, data_type): + + #deals with illumina format vcf files as processed by gatk + if (data_type == "ILLUMINA") or (data_type == "ILL"): + if ("./." in GT) == 0: + gt_list = GT.split(":") + gq = float(gt_list[3]) + temp = gt_list[1].split(",") + al = int(temp[1]) + totalDepth = int(temp[0])+int(temp[1]) + likelihoodvec = gt_list[4].split(",") + + if (gt_list[0] == "0/1" and totalDepth >= d and gq >= q and al >= alt and int(likelihoodvec[1]) <= p): + alleles = "1" + elif (gt_list[0] == "1/1" and totalDepth >= d and gq >= q and al >= alt and int(likelihoodvec[2]) <= p): + alleles = "2" + elif (gt_list[0] == "0/0" and totalDepth >= d and gq >= q and int(likelihoodvec[0]) <= p): + alleles = "0" + + #3 for alleles not meeting filtering criteria + else: + alleles = "3" + + #4 for alleles not called + else: + alleles = "4" + return alleles + + #deals with complete genomics format vcf files + if (data_type == "COMPLETE") or (data_type == "CG"): + if ("./." in GT) == 0: + gt_list = GT.split(":") + if gt_list[0] == "0/1": + alleles = "1" + elif gt_list[0] == "1/1": + alleles = "2" + elif gt_list[0] == "0/0": + alleles = "0" + elif gt_list[0] == "0/.": + alleles = "0" + elif gt_list[0] == "1/.": + alleles = "2" + else: + alleles = "3" + + #4 for alleles not called + else: + alleles = "4" + return alleles + else: + print >> sys.stderr, "Invalid input - unknown or unsupported data format: "+data_type + exit(1) + + #deals with real time genomics format vcf files + +#boolean, returns 1 for a variant with frequency below threshold (for all background populations consider) or novel or unknown allele frequency, 0 otherwise +def is_rare(templine, freq_thresh, bp_indexlist): + templinelist = templine.split("\t") + rare_flag = 1 # rare + for i in bp_indexlist: + if templinelist[i] != "": + # should throw an exception if templinelist[i] isn't a float + if float(templinelist[i]) > float(freq_thresh): + rare_flag = 0 # not rare + return rare_flag + +#boolean, returns 1 for a variant with user-defined functional properties as annotated by annovar +def is_functional(templine, function_list): + functional = 0 + if ("stoploss" in templine) and ("stoploss" in function_list): + functional=1 + elif ("stopgain" in templine) and ("stopgain" in function_list): + functional=1 + elif ("splicing" in templine) and ("splicing" in function_list): + functional=1 + elif ("frameshift" in templine) and (("nonframeshift" in templine) == 0) and ("frameshift" in function_list): + functional=1 + elif ("nonframeshift" in templine) and ("nonframeshift" in function_list): + functional=1 + elif ("nonsynonymous" in templine) and ("nonsynonymous" in function_list): + functional=1 + elif ("exonic" in templine) and ("exonic" in function_list): + functional=1 + elif ("intronic" in templine) and ("intronic" in function_list): + functional=1 + elif ("UTR5" in templine) and ("UTR5" in function_list): + functional=1 + elif ("UTR3" in templine) and ("UTR3" in function_list): + functional=1 + elif ("ncRNA" in templine) and ("ncRNA" in function_list): + functional=1 + elif ("upstream" in templine) and ("upstream" in function_list): + functional=1 + elif ("intergenic" in templine) and ("intergenic" in function_list): + functional=1 + elif ("downstream" in templine) and ("downstream" in function_list): + functional=1 + return functional + +#boolean, returns 1 for variant that is conserved according to user-defined criteria +def is_conserved(templine, headlist, thresh): + total = 0 + templinelist = templine.split("\t") + phyloP = '' + if(vcfHeaders.kPhyloP_pred in headlist): + phyloP = templinelist[headlist.index(vcfHeaders.kPhyloP_pred)] + else: + print 'warning: ' + vcfHeaders.kPhyloP_pred + ' not found in annotated header' + + gerp = '' + if(vcfHeaders.kGerp in headlist): + gerp = templinelist[headlist.index(vcfHeaders.kGerp)] + else: + print 'warning: ' + vcfHeaders.kGerp + ' not found in annotated header' + + phast_cons = '' + if(vcfHeaders.kPhastConsElts46Way in headlist): + phast_cons = templinelist[headlist.index(vcfHeaders.kPhastConsElts46Way)] + else: + print 'warning: ' + vcfHeaders.kPhastConsElts46Way + ' not found in annotated header' + + wg_gerp = '' + if(vcfHeaders.kWg_gerp in headlist): + wg_gerp = templinelist[headlist.index(vcfHeaders.kWg_gerp)] + else: + print 'warning: ' + vcfHeaders.kWg_gerp + ' not found in annotated header' + + if gerp != "" and phyloP != "": + gerp = float(gerp) + if gerp >= 2.0: + total+=1 + if phyloP == "C": + total+=1 + if phast_cons!= "": + if int(phast_cons) >= 250: + total+=1 + if wg_gerp != "": + if float(wg_gerp) >= 2.0: + total+=1 + if total >= thresh: + return 1 + else: + return 0 + + +def getClinvarInfoCol(templine, headlist): + templinelist = templine.split("\t") + clinvarInfo = templinelist[headlist.index(vcfHeaders.kClinvar)] if vcfHeaders.kClinvar in headlist else '' + if(vcfHeaders.kClinvar not in headlist): + print 'warning: ' + vcfHeaders.kClinvar + ' not found in annotated header' + return clinvarInfo + +# TODO be consistent -- when doing clinvar star annotation, need clinvar clinrevstatus without "clinvar_" prefix, but when doing tiering with final annotated VCF, need clinvar clinsig with "clinvar_" prefix +def getClinvarClinsigHeader(yaml_cmds): + return yaml_cmds['clinvar']['Annotation']+'_'+vcfHeaders.kClinvarClinSigHeader +# return vcfHeaders.kClinvarClinSigHeader +def getClinvarClinRevStatusHeader(yaml_cmds): +# return yaml_cmds['clinvar']['Annotation']+'_'+vcfHeaders.kClinvarClinRevStatusHeader + return vcfHeaders.kClinvarClinRevStatusHeader + +# return clinsig value(s) as a string (may have multiple reported values in clinvar) +def getClinvarClinsigStr(templine, headlist, yaml_cmds): + clinvarClinsigHeader = getClinvarClinsigHeader(yaml_cmds) + if(clinvarClinsigHeader in headlist): + idx = headlist.index(clinvarClinsigHeader) + tempLineElts = templine.rstrip("\n").split("\t") + return tempLineElts[idx] + else: + raise IndexError('could not get index of clinvar clinical significance column (' + clinvarClinsigHeader + ') in annotated file') + print 'error could not get index of clinvar clinical review status column in annotated file' + return '' +# clinvarInfo = getClinvarInfoCol(templine, headlist) +# if('CLNSIG' in clinvarInfo): +# None # TODO finish +# # else +# return '' +def clinvarClinsigStr2Array(clinsig_str): + return clinsig_str.split('|') +def getClinvarClinsigArray(templine, headlist): + return clinvarClinsigStr2Array(getClinvarClinsigStr(templine, headlist)) + +def isClinvarPathogenicOrLikelyPathogenic(line, headlist, yaml_cmds): + clinsigStr = getClinvarClinsigStr(line, headlist, yaml_cmds) + if(str(vcfHeaders.kCLINVAR_CLINSIG_LIKELY_PATHOGENIC_CODE) in clinsigStr or str(vcfHeaders.kCLINVAR_CLINSIG_PATHOGENIC_CODE) in clinsigStr): + return True + return False + +#return clinrevstatus values as a string (similar to clinsig above) +def getClinvarClinReviewStatusStr(templine, headlist, yaml_cmds): + clinvarClinRevStatusStr = getClinvarClinRevStatusHeader(yaml_cmds) + if(clinvarClinRevStatusStr in headlist): + idx = headlist.index(clinvarClinRevStatusStr) + tempLineElts = templine.rstrip("\n").split("\t") + return tempLineElts[idx] + else: + raise IndexError('could not get index of clinvar clinical review status column (' + clinvarClinRevStatusStr +') in annotated file') + print 'error could not get index of clinvar clinical review status column in annotated file' + return '' +# clinrevstatus convenience methods +def clinvarClinRevStatusStr2Array(clinrevstat_str): + return clinrevstat_str.split('|') +def getClinvarClinReviewStatusArray(templine, headlist): + return clinvarClinRevStatusStr2Array(getClinvarClinReviewStatusStr(templine, headlist)) + + +# computes clinvar stars based on clinsig + clin review status (based on revised ClinVar mid 2015 criteria) +# from http://www.ncbi.nlm.nih.gov/clinvar/docs/variation_report/#review_status +# 0 stars: No submitter provided an interpretation with assertion criteria (no assertion criteria provided), or no interpretation was provided (no assertion provided) +# 1 star: At least one submitter provided an interpretation with assertion criteria (criteria provided, single submitter) or multiple submitters provided assertion criteria but there are conflicting interpretations in which case the independent values are enumerated for clinical significance (criteria provided, conflicting interpretations) +# 2 stars: Two or more submitters providing assertion criteria provided the same interpretation (criteria provided, multiple submitters, no conflicts) +# 3 stars: reviewed by expert panel (http://www.ncbi.nlm.nih.gov/clinvar/docs/review_guidelines/) +# 4 stars: practice guideline (http://www.ncbi.nlm.nih.gov/clinvar/docs/review_guidelines/) +def clinvarStars(templine, headlist, yaml_cmds): + clinRevStatStr = getClinvarClinReviewStatusStr(templine, headlist, yaml_cmds) + + # 4 star: practice guideline + if(clinRevStatStr.find('practice_guideline') != -1): + return 4 + + # 3 star: expert panel + if(clinRevStatStr.find('exp') != -1): + return 3 + + #0, 1, and 2 star: check assertion criteria and whether assertions agree + numAssertionCriteriaProvided = clinRevStatStr.count('criteria_provided') - clinRevStatStr.count('no_assertion_criteria_provided') + if(numAssertionCriteriaProvided == 0): + return 0 + if(numAssertionCriteriaProvided == 1 and clinRevStatStr.find('criteria_provided\x2c_multiple_submitters') == -1): + return 1 + if(numAssertionCriteriaProvided > 1 or clinRevStatStr.find('criteria_provided\x2c_multiple_submitters') != -1): + if clinRevStatStr.find('conflicting_interpretations') != -1: + return 1 + #else, no conflicting interpretations + return 2 + + +#boolean, returns 1 for variant that is pathogenic according to user-defined criteria +def is_pathogenic(templine, headlist, nalg): + templinelist = templine.split("\t") + pathogenic = 0 + + sift = templinelist[headlist.index(vcfHeaders.kSiftPred)] if vcfHeaders.kSiftPred in headlist else '' + pp2 = templinelist[headlist.index(vcfHeaders.kPolyphen2Pred)] if vcfHeaders.kPolyphen2Pred in headlist else '' + lrt = templinelist[headlist.index(vcfHeaders.kLrtPred)] if vcfHeaders.kLrtPred in headlist else '' + mt = templinelist[headlist.index(vcfHeaders.kMutationTasterPred)] if vcfHeaders.kMutationTasterPred in headlist else '' + pp2_2 = templinelist[headlist.index(vcfHeaders.kPolyphen2Pred_2)] if vcfHeaders.kPolyphen2Pred_2 in headlist else '' + + # check for header mismatches + if(vcfHeaders.kSiftPred not in headlist): + print 'warning: ' + vcfHeaders.kSiftPred + ' not found in annotated header' + if(vcfHeaders.kPolyphen2Pred not in headlist): + print 'warning: ' + vcfHeaders.kPolyphen2Pred + ' not found in annotated header' + if(vcfHeaders.kLrtPred not in headlist): + print 'warning: ' + vcfHeaders.kLrtPred + ' not found in annotated header' + if(vcfHeaders.kMutationTasterPred not in headlist): + print 'warning: ' + vcfHeaders.kMutationTasterPred + ' not found in annotated header' + if(vcfHeaders.kPolyphen2Pred_2 not in headlist): + print 'warning: ' + vcfHeaders.kPolyphen2Pred_2 + ' not found in annotated header (though currently unused)' + + if sift == "D": + pathogenic+=1 + #debug + print 'SIFT=D' + if (pp2 == "P") or (pp2 == "D"): + pathogenic+=1 + #debug + print 'pp=P or D' + if lrt == "D": + pathogenic+=1 + # debug + print 'lrt=D' + if (mt == "A") or (mt == "D"): + pathogenic+=1 + #debug + print 'mt=A or D' + if pathogenic >= int(nalg): + #debug + print 'is pathogenic' + return 1 + else: + print 'not pathogenic' + return 0 + + +#CURRENTLY UNUSED +#finds variants with regulatory annotations +def is_regulatory(templine, headlist): + templinelist = templine.split("\t") + regulatory = 0 + dnase = 0 + adult_enhancer = 0 + fetal_enhancer = 0 + tfbs = 0 + transfac=0 + mirna_coding=0 + mirna_target=0 + if templinelist[headlist.index(vcfHeaders.kEncode_dnaseCluster)] != "": + if int(templinelist[headlist.index(vcfHeaders.kEncode_dnaseCluster)]) >= 300: + regulatory=1 + dnase = 1 + if templinelist[headlist.index("encode_tfbsChip_score")] != "": # warning not in annotation + if int(templinelist[headlist.index("encode_tfbsChip_score")]) >= 300: + regulatory=1 + tfbs=1 + if templinelist[headlist.index("heart_adult_enhancer")] != "": # warning not in annotation + regulatory=1 + adult_enhancer=1 + if templinelist[headlist.index("heart_fetal_enhancer")] != "": # warning not in annotation + regulatory=1 + fetal_enhancer=1 + if templinelist[headlist.index("transFac_score")] != "": # warning not in annotation + regulatory=1 + transfac=1 + if templinelist[headlist.index("miRNA")] != "": # warning not in annotation + regulatory=1 + mirna_coding=1 + if templinelist[headlist.index("targetScan")] != "": # warning not in annotation + regulatory=1 + mirna_target=1 + return regulatory, dnase, tfbs, adult_enhancer, fetal_enhancer, transfac, mirna_coding, mirna_target + + +# CURRENTLY UNUSED +#finds variants in topologically central location in network according to user defined criteria +def is_central_mod(templine, headlist, rank_thresh, phenotype): + templinelist = templine.split("\t") + if phenotype == "normal": + if templinelist[headlist.index("normal_heart_Kin")] != "": # warning not in annotation + if float(templinelist[headlist.index("normal_heart_Kin")]) >= rank_thresh: + return 1 + else: + return 0 + else: + return 0 + if phenotype == "hypertrophy": + if templinelist[headlist.index("hypertrophy_heart_Kin")] != "": # warning not in annotation + if float(templinelist[headlist.index("hypertrophy_heart_Kin")]) >= rank_thresh: + return 1 + else: + return 0 + else: + return 0 + if phenotype == "failure": + if templinelist[headlist.index("failure_heart_Kin")] != "": # warning not in annotation + if float(templinelist[headlist.index("failure_heart_Kin")]) >= rank_thresh: + return 1 + else: + return 0 + else: + return 0 + +# CURRENTLY UNUSED +#finds variants in topologically central location in network according to user defined criteria +def is_central_all(templine, headlist, rank_thresh, phenotype): + templinelist = templine.split("\t") + if phenotype == "normal": + if templinelist[headlist.index("normal_heart_globalK")] != "": + if float(templinelist[headlist.index("normal_heart_globalK")]) >= rank_thresh: + return 1 + else: + return 0 + else: + return 0 + if phenotype == "hypertrophy": + if templinelist[headlist.index("hypertrophy_heart_globalK")] != "": + if float(templinelist[headlist.index("hypertrophy_heart_globalK")]) >= rank_thresh: + return 1 + else: + return 0 + else: + return 0 + if phenotype == "failure": + if templinelist[headlist.index("failure_heart_globalK")] != "": + if float(templinelist[headlist.index("failure_heart_globalK")]) >= rank_thresh: + return 1 + else: + return 0 + else: + return 0 + +# CURRENTLY UNUSED +#finds variants in expressed regions according to user-defined criteria +def is_expressed(templine, headlist, rank_thresh, phenotype): + templinelist = templine.split("\t") + if phenotype == "normal": + if templinelist[headlist.index("normal_heart_exprs_rank")] != "": + if float(templinelist[headlist.index("normal_heart_exprs_rank")]) >= rank_thresh: + return 1 + else: + return 0 + else: + return 0 + if phenotype == "hypertrophy": + if templinelist[headlist.index("hypertrophy_heart_exprs_rank")] != "": + if float(templinelist[headlist.index("hypertrophy_heart_exprs_rank")]) >= rank_thresh: + return 1 + else: + return 0 + else: + return 0 + if phenotype == "failure": + if templinelist[headlist.index("failure_heart_exprs_rank")] != "": + if float(templinelist[headlist.index("failure_heart_exprs_rank")]) >= rank_thresh: + return 1 + else: + return 0 + else: + return 0 + +# CURRENTLY UNUSED +#finds variants in differentially expressed regions according to user-defined criteria +def is_diffexpr(templine, headlist, phenotype, q_thresh): + templinelist = templine.split("\t") + if phenotype == "hypertrophy": + if templinelist[headlist.index("sam_q_normal_hypertrophy")] != "": + if float(templinelist[headlist.index("sam_q_normal_hypertrophy")]) <= q_thresh: + return 1 + else: + return 0 + else: + return 0 + if phenotype == "failure": + if templinelist[headlist.index("sam_q_normal_failure")] != "": + if float(templinelist[headlist.index("sam_q_normal_failure")]) <= q_thresh: + return 1 + else: + return 0 + else: + return 0 + +#gives max allele frequency in a list of allele frequency annotations +def max_af(templine, headlist, bp_indexlist): + templinelist = templine.split("\t") + af = 0.00 + for i in bp_indexlist: + if templinelist[i] != "": + if float(templinelist[i]) > af: + af = float(templinelist[i]) + return af + +#parses info field of vcf file and returns tuple float for mq and mq0 +def parse_info(infofield): + infolist = infofield.split(";") + for element in infolist: + if "MQ=" in element: + mapq=float(element.replace("MQ=", "")) + elif "MQ0=" in element: + mapq0=float(element.replace("MQ0=", "")) + return mapq, mapq0 + +#merges vcf files split by chromosome, writing head from chromosome 1 to X only for now +def mergeFiles(fin_stem, f_out): + chrom_arr = ["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","X"] + + fout = open(f_out, "w") + + for chrom in chrom_arr: + fin = open(fin_stem+"_chr"+chrom+"_annotated_hmmfiltered.txt", "r") + head = fin.readline() + if chrom == "1": + fout.write(head) + + for line in fin.readlines(): + fout.write(line) + fin.close() + os.system("rm "+fin_stem+"_chr"+chrom+"_annotated_hmmfiltered.txt") + fout.close() + + +#splits vcf file by chromosome, to X only for now +def splitFiles(f_in, fout_stem): + chrom_arr = ["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","X"] + + try: + fin = open(f_in, "r") + except IOError: + print >> sys.stderr, "Error in vcfUtils.splitFiles: Cannot open input vcf file "+f_in + exit(1) + + head = get_head(f_in) + try: + f1 = open(fout_stem+"_chr1.txt", "w") + f1.write(head) + f2 = open(fout_stem+"_chr2.txt", "w") + f2.write(head) + f3 = open(fout_stem+"_chr3.txt", "w") + f3.write(head) + f4 = open(fout_stem+"_chr4.txt", "w") + f4.write(head) + f5 = open(fout_stem+"_chr5.txt", "w") + f5.write(head) + f6 = open(fout_stem+"_chr6.txt", "w") + f6.write(head) + f7 = open(fout_stem+"_chr7.txt", "w") + f7.write(head) + f8 = open(fout_stem+"_chr8.txt", "w") + f8.write(head) + f9 = open(fout_stem+"_chr9.txt", "w") + f9.write(head) + f10 = open(fout_stem+"_chr10.txt", "w") + f10.write(head) + f11 = open(fout_stem+"_chr11.txt", "w") + f11.write(head) + f12 = open(fout_stem+"_chr12.txt", "w") + f12.write(head) + f13 = open(fout_stem+"_chr13.txt", "w") + f13.write(head) + f14 = open(fout_stem+"_chr14.txt", "w") + f14.write(head) + f15 = open(fout_stem+"_chr15.txt", "w") + f15.write(head) + f16 = open(fout_stem+"_chr16.txt", "w") + f16.write(head) + f17 = open(fout_stem+"_chr17.txt", "w") + f17.write(head) + f18 = open(fout_stem+"_chr18.txt", "w") + f18.write(head) + f19 = open(fout_stem+"_chr19.txt", "w") + f19.write(head) + f20 = open(fout_stem+"_chr20.txt", "w") + f20.write(head) + f21 = open(fout_stem+"_chr21.txt", "w") + f21.write(head) + f22 = open(fout_stem+"_chr22.txt", "w") + f22.write(head) + fX = open(fout_stem+"_chrX.txt", "w") + fX.write(head) + except IOError: + print >> sys.stderr, "Error in vcfUtils.splitFiles: Improper output file specification "+f_in + exit(1) + + while 1: + temp = fin.readline() + if not temp: + break + else: + if ("chr1\t" in temp) and (('#' in temp) == 0): + f1.write(temp) + if ("chr2\t" in temp) and (('#' in temp) == 0): + f2.write(temp) + if ("chr3\t" in temp) and (('#' in temp) == 0): + f3.write(temp) + if ("chr4\t" in temp) and (('#' in temp) == 0): + f4.write(temp) + if ("chr5\t" in temp) and (('#' in temp) == 0): + f5.write(temp) + if ("chr6\t" in temp) and (('#' in temp) == 0): + f6.write(temp) + if ("chr7\t" in temp) and (('#' in temp) == 0): + f7.write(temp) + if ("chr8\t" in temp) and (('#' in temp) == 0): + f8.write(temp) + if ("chr9\t" in temp) and (('#' in temp) == 0): + f9.write(temp) + if ("chr10\t" in temp) and (('#' in temp) == 0): + f10.write(temp) + if ("chr11\t" in temp) and (('#' in temp) == 0): + f11.write(temp) + if ("chr12\t" in temp) and (('#' in temp) == 0): + f12.write(temp) + if ("chr13\t" in temp) and (('#' in temp) == 0): + f13.write(temp) + if ("chr14\t" in temp) and (('#' in temp) == 0): + f14.write(temp) + if ("chr15\t" in temp) and (('#' in temp) == 0): + f15.write(temp) + if ("chr16\t" in temp) and (('#' in temp) == 0): + f16.write(temp) + if ("chr17\t" in temp) and (('#' in temp) == 0): + f17.write(temp) + if ("chr18\t" in temp) and (('#' in temp) == 0): + f18.write(temp) + if ("chr19\t" in temp) and (('#' in temp) == 0): + f19.write(temp) + if ("chr20\t" in temp) and (('#' in temp) == 0): + f20.write(temp) + if ("chr21\t" in temp) and (('#' in temp) == 0): + f21.write(temp) + if ("chr22\t" in temp) and (('#' in temp) == 0): + f22.write(temp) + if ("chrX\t" in temp) and (('#' in temp) == 0): + fX.write(temp)