Module Expr Str Import alias Import alias Import alias Import alias Import alias identifier Import alias identifier Import alias identifier FunctionDef arguments args NameParam NameParam NameParam NameParam defaults body Expr Str Assign NameStore SubscriptLoad AttributeLoad NameLoad attr Index TupleLoad CompareEq SubscriptLoad NameLoad Index Str Num Assign NameStore SubscriptLoad AttributeLoad NameLoad attr Index TupleLoad CompareEq SubscriptLoad NameLoad Index Str Num Assign NameStore ListComp NameLoad comprehension NameStore AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad SubscriptLoad SubscriptLoad NameLoad Index Str Index NameLoad Assign NameStore SubscriptLoad AttributeLoad NameLoad attr Index NameLoad Assign NameStore Call NameLoad Call NameLoad ListComp SubscriptLoad SubscriptLoad NameLoad Index Str Index NameLoad comprehension NameStore AttributeLoad NameLoad attr Assign NameStore Dict Assign NameStore Dict Assign NameStore Dict Assign NameStore Call AttributeLoad NameLoad attr Str For NameStore NameLoad body Assign SubscriptStore NameLoad Index NameLoad ListComp NameLoad comprehension NameStore AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad SubscriptLoad SubscriptLoad NameLoad Index Str Index NameLoad Assign SubscriptStore NameLoad Index NameLoad ListComp BinOpAdd NameLoad NameLoad comprehension NameStore Call AttributeLoad SubscriptLoad AttributeLoad NameLoad attr Index TupleLoad SubscriptLoad NameLoad Index NameLoad Str attr Assign SubscriptStore NameLoad Index NameLoad Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index NameLoad Expr Call AttributeLoad SubscriptLoad NameLoad Index NameLoad attr ListComp BinOpAdd NameLoad NameLoad comprehension NameStore Call AttributeLoad SubscriptLoad AttributeLoad NameLoad attr Index TupleLoad SubscriptLoad NameLoad Index NameLoad Str attr comprehension NameStore NameLoad Return TupleLoad NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults body Expr Str If CompareEq NameLoad Str body Assign NameStore ListComp BinOpSub SubscriptLoad NameLoad Index NameLoad SubscriptLoad NameLoad Index NameLoad comprehension NameStore Call NameLoad Num Call NameLoad NameLoad Assign NameStore NameLoad orelse If CompareEq NameLoad Str body Assign NameStore ListComp Call AttributeLoad NameLoad attr BinOpDiv BinOpAdd SubscriptLoad NameLoad Index NameLoad Num BinOpAdd SubscriptLoad NameLoad Index NameLoad Num comprehension NameStore Call NameLoad Num Call NameLoad NameLoad Assign NameStore ListComp Call AttributeLoad NameLoad attr BinOpAdd SubscriptLoad NameLoad Index NameLoad Num comprehension NameStore Call NameLoad Num Call NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad Return TupleLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad SubscriptLoad NameLoad Index Str attr Assign NameStore Call AttributeLoad SubscriptLoad NameLoad Index Str attr Assign NameStore Num Assign NameStore ListLoad Assign NameStore Str Assign NameStore Dict Assign NameStore Num For NameStore Call NameLoad Num Call NameLoad NameLoad body Assign NameStore SubscriptLoad NameLoad Index NameLoad Assign NameStore SubscriptLoad NameLoad Index NameLoad If BinOpBitAnd CompareLt NameLoad BinOpAdd NameLoad NameLoad CompareEq NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad orelse If CompareGtE Call NameLoad NameLoad NameLoad body Assign TupleStore NameStore NameStore TupleLoad SubscriptLoad NameLoad Index Num SubscriptLoad NameLoad Index Num Assign SubscriptStore NameLoad Index NameLoad SubscriptLoad AttributeLoad NameLoad attr Slice NameLoad NameLoad AugAssignAdd NameStore Num Assign NameStore ListLoad Assign NameStore NameLoad Assign NameStore NameLoad Expr Call AttributeLoad NameLoad attr BinOpMod Str NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam defaults body Assign NameStore Call NameLoad NameLoad BinOpAdd NameLoad Num NameLoad Assign NameStore Call AttributeLoad NameLoad attr TupleLoad BinOpAdd Call NameLoad NameLoad Num BinOpAdd Call NameLoad NameLoad Num BinOpAdd Call NameLoad NameLoad Num Assign NameStore DictComp TupleLoad NameLoad NameLoad NameLoad ListLoad comprehension NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad comprehension NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad comprehension NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad For NameStore Call NameLoad Num NameLoad body Expr Call AttributeLoad NameLoad attr BinOpMod Str BinOpAdd NameLoad Num For NameStore NameLoad body Assign NameStore ListLoad Assign NameStore ListLoad Assign NameStore ListLoad Assign NameStore ListLoad Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr Call AttributeLoad NameLoad attr For NameStore Call NameLoad Num Call NameLoad NameLoad body Assign NameStore SubscriptLoad AttributeLoad SubscriptLoad NameLoad Index SubscriptLoad NameLoad Index NameLoad attr ExtSlice Slice Index SubscriptLoad NameLoad Index SubscriptLoad NameLoad Index Num Assign NameStore SubscriptLoad AttributeLoad SubscriptLoad NameLoad Index SubscriptLoad NameLoad Index NameLoad attr ExtSlice Slice Index SubscriptLoad NameLoad Index SubscriptLoad NameLoad Index Num Assign NameStore Call AttributeLoad NameLoad attr Call NameLoad AttributeLoad NameLoad attr BinOpSub Call NameLoad AttributeLoad NameLoad attr NameLoad Assign NameStore Call NameLoad BinOpAdd NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr Call NameLoad AttributeLoad NameLoad attr BinOpSub Call NameLoad AttributeLoad NameLoad attr NameLoad Assign NameStore Call NameLoad BinOpAdd NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr SubscriptLoad AttributeLoad NameLoad attr Slice NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr SubscriptLoad AttributeLoad NameLoad attr Slice NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Assign TupleStore NameStore NameStore Call NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr BinOpMult ListLoad NameLoad Call NameLoad NameLoad NameLoad For TupleStore NameStore NameStore Call NameLoad Call NameLoad NameLoad NameLoad NameLoad body If CompareLt SubscriptLoad NameLoad Index NameLoad NameLoad body AugAssignAdd SubscriptStore NameLoad Index NameLoad Num Assign NameStore AttributeLoad AttributeLoad SubscriptLoad NameLoad Index SubscriptLoad NameLoad Index NameLoad attr attr Assign NameStore SubscriptLoad NameLoad Index Num Assign NameStore SubscriptLoad NameLoad Index Num Assign NameStore AttributeLoad AttributeLoad SubscriptLoad NameLoad Index SubscriptLoad NameLoad Index NameLoad attr attr Assign NameStore SubscriptLoad NameLoad Index Num Assign NameStore SubscriptLoad NameLoad Index Num Assign NameStore SubscriptLoad NameLoad Index NameLoad Assign NameStore Call NameLoad BinOpAdd NameLoad NameLoad Assign NameStore SubscriptLoad NameLoad Index NameLoad Assign NameStore Call NameLoad BinOpAdd NameLoad NameLoad Expr Call AttributeLoad SubscriptLoad NameLoad Index NameLoad attr TupleLoad NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad Return TupleLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam defaults Num Num body Assign NameStore Call AttributeLoad NameLoad attr TupleLoad BinOpAdd Call NameLoad NameLoad Num BinOpAdd Call NameLoad NameLoad Num Expr Call AttributeLoad NameLoad attr Str Expr Call AttributeLoad NameLoad attr NameLoad Assign NameStore DictComp TupleLoad NameLoad NameLoad ListLoad comprehension NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad comprehension NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad Assign NameStore Call NameLoad Call AttributeLoad NameLoad attr For NameStore Call NameLoad Num NameLoad body Expr Call AttributeLoad NameLoad attr BinOpMod Str BinOpAdd NameLoad Num If CompareLt NameLoad NameLoad body Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad Call AttributeLoad SubscriptLoad AttributeLoad NameLoad attr Index TupleLoad NameLoad SubscriptLoad NameLoad Index SubscriptLoad NameLoad Index Num attr AttributeLoad NameLoad attr keyword Num attr Assign NameStore Call AttributeLoad Call AttributeLoad SubscriptLoad AttributeLoad NameLoad attr Index TupleLoad NameLoad SubscriptLoad NameLoad Index SubscriptLoad NameLoad Index Num attr AttributeLoad NameLoad attr keyword Num attr Assign TupleStore NameStore NameStore Call NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad Expr Call AttributeLoad NameLoad attr BinOpMod Str Call NameLoad Call AttributeLoad NameLoad attr For TupleStore NameStore NameStore Call NameLoad Call NameLoad NameLoad NameLoad body If CompareIn NameLoad Call AttributeLoad NameLoad attr body If CompareLt SubscriptLoad NameLoad Index NameLoad NameLoad body AugAssignAdd SubscriptStore NameLoad Index NameLoad Num Expr Call AttributeLoad SubscriptLoad NameLoad Index NameLoad attr TupleLoad SubscriptLoad NameLoad Index NameLoad SubscriptLoad NameLoad Index NameLoad Assign NameStore Call NameLoad Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr Str Expr Call AttributeLoad NameLoad attr NameLoad Return TupleLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Assign NameStore Call AttributeLoad NameLoad attr NameLoad For NameStore Call AttributeLoad NameLoad attr body If CompareLt SubscriptLoad NameLoad Index NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr BinOpMod Str Call NameLoad Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr BinOpMod Str Call NameLoad Call AttributeLoad NameLoad attr Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam defaults body FunctionDef arguments args NameParam NameParam defaults body Assign NameStore NameLoad Expr Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index SubscriptLoad NameLoad Index Num Expr Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index SubscriptLoad NameLoad Index Num Expr Call AttributeLoad AttributeLoad NameLoad attr attr BinOpMod Str Call AttributeLoad Str attr Call NameLoad NameLoad NameLoad Return NameLoad decorator_list If CompareEq NameLoad Str body Assign NameStore Call NameLoad ListLoad NameLoad NameLoad orelse If CompareEq NameLoad Str body Assign NameStore Call NameLoad ListLoad Str Str NameLoad If CompareEq NameLoad Str body Assign NameStore SubscriptLoad AttributeLoad NameLoad attr ExtSlice Slice Index NameLoad Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr keyword NameLoad keyword NameLoad keyword Str keyword Dict Str NameLoad FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam NameParam defaults body Assign TupleStore NameStore NameStore NameStore NameLoad Assign NameStore BinOpSub BinOpAdd BinOpMult NameLoad NameLoad NameLoad BinOpMult NameLoad Num Assign NameStore BinOpSub BinOpAdd BinOpMult NameLoad NameLoad NameLoad BinOpMult NameLoad Num Assign NameStore BinOpSub BinOpAdd BinOpMult NameLoad NameLoad NameLoad Num Return TupleLoad NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults body Assign TupleStore NameStore NameStore NameLoad Assign NameStore BinOpSub BinOpAdd BinOpMult NameLoad NameLoad NameLoad BinOpMult NameLoad Num Assign NameStore BinOpSub BinOpAdd BinOpMult NameLoad NameLoad NameLoad BinOpMult NameLoad Num Return TupleLoad NameLoad NameLoad decorator_list Assign NameStore Num If CompareEq NameLoad Str body For NameStore NameLoad body For NameStore SubscriptLoad NameLoad Index NameLoad body Assign TupleStore NameStore NameStore Call NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad Assign NameStore ListLoad Call AttributeLoad Str attr Call NameLoad NameLoad TupleLoad Str NameLoad NameLoad NameLoad Expr Call AttributeLoad NameLoad attr SubscriptLoad AttributeLoad NameLoad attr Index TupleLoad SubscriptLoad NameLoad Index Num SubscriptLoad NameLoad Index SubscriptLoad NameLoad Index Num Expr Call AttributeLoad NameLoad attr SubscriptLoad AttributeLoad NameLoad attr Index TupleLoad SubscriptLoad NameLoad Index Num SubscriptLoad NameLoad Index SubscriptLoad NameLoad Index Num Expr Call AttributeLoad AttributeLoad NameLoad attr attr BinOpMod Str Call AttributeLoad Str attr Call NameLoad NameLoad NameLoad AugAssignAdd NameStore Num orelse If CompareEq NameLoad Str body For NameStore Call AttributeLoad NameLoad attr body Assign TupleStore NameStore NameStore NameStore Call NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad For NameStore SubscriptLoad NameLoad Index NameLoad body Assign TupleStore NameStore NameStore NameStore NameStore NameStore NameStore NameStore NameStore NameLoad Assign NameStore Call AttributeLoad Str attr Call NameLoad NameLoad TupleLoad Str NameLoad NameLoad NameLoad BinOpSub NameLoad NameLoad NameLoad Assign NameStore SubscriptLoad AttributeLoad NameLoad attr ExtSlice Slice NameLoad NameLoad Index NameLoad Assign SubscriptStore NameLoad Index Str NameLoad Assign NameStore SubscriptLoad AttributeLoad NameLoad attr ExtSlice Slice NameLoad NameLoad Index SubscriptLoad NameLoad Index SubscriptLoad NameLoad Index Num Expr Call AttributeLoad NameLoad attr AttributeLoad SubscriptLoad AttributeLoad NameLoad attr Slice NameLoad NameLoad attr keyword NameLoad keyword NameLoad Assign SubscriptStore AttributeLoad NameLoad attr ExtSlice Slice NameLoad NameLoad Index SubscriptLoad NameLoad Index SubscriptLoad NameLoad Index Num NameLoad Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr keyword NameLoad keyword NameLoad keyword Str keyword Dict Str NameLoad AugAssignAdd NameStore Num decorator_list FunctionDef arguments args NameParam defaults NameLoad body Expr Str If UnaryOpNot NameLoad body Assign NameStore AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr keyword Str keyword SubscriptLoad Call NameLoad Index Str Expr Call AttributeLoad NameLoad attr Str Str keyword Str keyword Str keyword Str Expr Call AttributeLoad NameLoad attr Str Str keyword Str keyword Str keyword Str Expr Call AttributeLoad NameLoad attr Str Str keyword Str keyword Str keyword Str Expr Call AttributeLoad NameLoad attr Str Str keyword Str keyword Str keyword Str Expr Call AttributeLoad NameLoad attr Str Str keyword Str keyword Str keyword Str Expr Call AttributeLoad NameLoad attr Str Str keyword Str keyword Str keyword Str Expr Call AttributeLoad NameLoad attr Str Str keyword Str keyword Str keyword Str Expr Call AttributeLoad NameLoad attr Str Str keyword Str keyword Str keyword Str Expr Call AttributeLoad NameLoad attr Str Str keyword Str keyword Str keyword Str Expr Call AttributeLoad NameLoad attr Str Str keyword Str keyword Str keyword TupleLoad Str Str keyword Str Expr Call AttributeLoad NameLoad attr Str Str keyword Str keyword Str keyword Str Expr Call AttributeLoad NameLoad attr Str Str keyword Str keyword Str keyword Str Expr Call AttributeLoad NameLoad attr Str Str keyword Str keyword Str keyword Str Expr Call AttributeLoad NameLoad attr Str Str keyword Str keyword Str keyword Str Expr Call AttributeLoad NameLoad attr Str Str keyword Str keyword Str keyword TupleLoad Str Str keyword Str Expr Call AttributeLoad NameLoad attr Str Str keyword Str keyword Str keyword Str Expr Call AttributeLoad NameLoad attr Str Str keyword Str keyword Str keyword Str Expr Call AttributeLoad NameLoad attr Str Str keyword Str keyword Str keyword Str Expr Call AttributeLoad NameLoad attr Str Str keyword Str keyword Str keyword TupleLoad Str Str keyword Str Expr Call AttributeLoad NameLoad attr Str Str keyword Str keyword Str keyword Str Expr Call AttributeLoad NameLoad attr Str Str keyword Str keyword Str keyword Str Expr Call AttributeLoad NameLoad attr Str Str keyword Str keyword Str keyword Str keyword Str Expr Call AttributeLoad NameLoad attr keyword NameLoad keyword Str keyword Str keyword Str keyword NameLoad keyword NameLoad keyword NameLoad keyword NameLoad keyword NameLoad keyword NameLoad keyword NameLoad keyword NameLoad keyword Num keyword NameLoad keyword Num keyword Num keyword Num keyword Num keyword Num keyword Num keyword NameLoad keyword NameLoad keyword NameLoad keyword Str Assign TupleStore NameStore NameStore Call AttributeLoad NameLoad attr NameLoad keyword NameLoad keyword NameLoad Assign NameStore Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr keyword Str If CompareEq AttributeLoad NameLoad attr Str body Assign NameStore Call AttributeLoad NameLoad attr keyword ListLoad Str Str Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr keyword NameLoad orelse Assign NameStore NameLoad If UnaryOpNot AttributeLoad NameLoad attr body Raise Call NameLoad Str If CompareEq AttributeLoad NameLoad attr Str body If CompareGt AttributeLoad NameLoad attr AttributeLoad NameLoad attr body Raise Call NameLoad BinOpMod Str TupleLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr Assign NameStore Call NameLoad Call AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr Assign NameStore Str Assert BoolOpAnd CompareIn Str NameLoad CompareIn Str NameLoad NameLoad Assign NameStore BinOpMod Str TupleLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr Assert CompareLt AttributeLoad NameLoad attr AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr keyword ListLoad Str Str Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr keyword NameLoad If UnaryOpNot AttributeLoad NameLoad attr body If BoolOpAnd CompareEq AttributeLoad NameLoad attr Str CompareEq AttributeLoad NameLoad attr Str body Raise Call NameLoad Str orelse If CompareNotEq AttributeLoad NameLoad attr Str body Assign AttributeStore NameLoad attr Str If UnaryOpNot AttributeLoad NameLoad attr body Assign AttributeStore NameLoad attr AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr keyword Str Assign TupleStore NameStore NameStore NameStore Call NameLoad NameLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr BinOpMod Str Call NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr BinOpMod Str Call NameLoad NameLoad If CompareEq AttributeLoad NameLoad attr Str body Expr Call AttributeLoad NameLoad attr Str Assign NameStore Call NameLoad NameLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr NameLoad NameLoad If CompareEq Call NameLoad NameLoad Num body Raise Call NameLoad Str Expr Call AttributeLoad NameLoad attr Str Assign TupleStore NameStore NameStore Call NameLoad NameLoad NameLoad NameLoad NameLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr NameLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr orelse If CompareEq AttributeLoad NameLoad attr Str body Expr Call AttributeLoad NameLoad attr Str Assign TupleStore NameStore NameStore Call NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr Assign NameStore Call NameLoad NameLoad NameLoad AttributeLoad NameLoad attr If CompareEq Call NameLoad NameLoad Num body Raise Call NameLoad Str Expr Call AttributeLoad NameLoad attr Str Expr Call NameLoad NameLoad AttributeLoad NameLoad attr NameLoad NameLoad NameLoad keyword AttributeLoad NameLoad attr keyword AttributeLoad NameLoad attr keyword AttributeLoad NameLoad attr keyword AttributeLoad NameLoad attr keyword AttributeLoad NameLoad attr keyword AttributeLoad NameLoad attr keyword AttributeLoad NameLoad attr keyword AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr decorator_list If CompareEq NameLoad Str body Expr Call AttributeLoad NameLoad attr Call NameLoad AttributeLoad NameLoad attr
N/A N/A 
data2spike.py - generate spike-in from a data frame
=====================================================

:Author: Tom smith
:Release: $Id: data2spike.py
:Date: |today|
:Tags: Genomics Statistics Power


Purpose
-------
This scripts can be used to generate spike-ins from a dataframe.
The output can be used to perform a downstream power analysis.

Usage
-----
Spike-ins are generated over a range of initial values and simulated
differences. Additionally, cluster spike-ins are generate over a range
of subcluster sizes. The range and bin width is parametised, as is the
the minimum and maximum number of spike ins required in each bin. The
number of randomisation iterations can be modified in order to
generate sufficient numbers of spike ins and/or optimise run time.

Input
+++++
The input to this script is a dataframe containing one item per row
(e.g gene, CpG).

The dataframe must contain rows with numerical data for shuffling. The
dataframe can contain additional columns which are shuffled alongside
the shuffling columns, e.g associated data columns or sample-specific
columns

If cluster spike-ins need to be generated, the dataframe must contain
columns called "contig" and "position" from which to derive the clusters.

The script further requires a design table describing the groups and columns.
The design table has four columns::

      track   include group   pair
      GS1        1       S       1
      GS2        1       S       1
      GD1        1       D       1
      GD2        1       D       1


track
     name of track - should correspond to column header in the counts
     table.
include
     flag to indicate whether or not to include this data in the output
group
     group indicator - experimental group
pair
     pair that sample belongs to (for paired tests)

Output
++++++

The original dataframe is outputted along with the spike-ins.
Optionally, the spike-ins can be outputted seperately.  If row
spike-ins need to be appended the user must specify an idendification
column for the dataframe.

 N/A copy N/A random N/A sys N/A re N/A pandas pd N/A numpy np N/A CGAT.Experiment E groupMappers N/A N/A design_table spike_regex shuffle_suffix keep_suffix N/A N/A N/A from design table, extract groups and return dictionaries mapping
    groups to tracks N/A design_table N/A N/A design_table ix N/A N/A N/A N/A design_table N/A include 1 N/A design_table N/A N/A design_table ix N/A N/A N/A N/A design_table N/A pair 1 N/A keep N/A ix N/A ix N/A design_table index N/A N/A re match spike_regex N/A N/A design_table N/A track N/A ix N/A design_table N/A N/A design_table ix N/A keep N/A groups N/A list N/A set N/A N/A N/A design_table N/A group N/A ix N/A ix N/A design_table index N/A groups_to_keep_ix N/A N/A groups_to_keep_tracks N/A N/A groups_to_spike_tracks N/A N/A keep_suffix N/A N/A keep_suffix split , N/A group groups N/A N/A N/A groups_to_keep_ix N/A group N/A ix N/A ix N/A design_table index N/A N/A re match group N/A N/A design_table N/A group N/A ix N/A N/A groups_to_spike_tracks N/A group N/A N/A x shuffle_suffix N/A x N/A N/A N/A N/A design_table ix N/A N/A N/A groups_to_keep_ix N/A group track tolist N/A N/A groups_to_keep_tracks N/A group N/A N/A copy copy N/A groups_to_spike_tracks N/A group N/A N/A N/A N/A groups_to_keep_tracks N/A group extend N/A N/A x y N/A x N/A N/A N/A N/A design_table ix N/A N/A N/A groups_to_keep_ix N/A group track tolist N/A y keep_suffix N/A N/A groups groups_to_keep_tracks groups_to_spike_tracks N/A means2idxarrays N/A N/A g1 g2 i_bins c_bins difference N/A N/A N/A take two arrays of values and return the initial values
    and differences as numpy digitised arrays N/A N/A difference relative N/A N/A change N/A N/A N/A g2 N/A x N/A g1 N/A x N/A x N/A range 0 N/A len g1 N/A initial g1 N/A N/A N/A difference logfold N/A N/A change N/A N/A N/A np log2 N/A N/A N/A g2 N/A x 1.0 N/A N/A g1 N/A x 1.0 N/A x N/A range 0 N/A len g1 N/A initial N/A N/A N/A np log2 N/A N/A g1 N/A x 1.0 N/A x N/A range 0 N/A len g1 N/A change_idx N/A N/A np digitize change c_bins N/A initial_idx N/A N/A np digitize initial i_bins N/A N/A change_idx initial_idx N/A findClusters N/A N/A df distance size tracks_map groups N/A N/A N/A define clusters of genomic loci depending on thresholds for
    size and minimum members per cluster N/A positions N/A N/A N/A df N/A position tolist N/A contigs N/A N/A N/A df N/A contig tolist N/A current_pos 0 N/A cluster_ix N/A N/A current_contig N/A cluster_dfs N/A N/A n 0 N/A ix N/A range 0 N/A len positions N/A N/A next_pos N/A positions N/A ix N/A next_contig N/A contigs N/A ix N/A N/A N/A next_pos N/A current_pos distance N/A next_contig current_contig N/A N/A N/A N/A cluster_ix append ix N/A N/A N/A N/A len cluster_ix size N/A N/A N/A start end N/A N/A cluster_ix N/A 0 N/A cluster_ix N/A -1 N/A N/A cluster_dfs N/A n N/A N/A df loc N/A start end N/A n 1 N/A cluster_ix N/A N/A current_pos next_pos N/A current_contig next_contig N/A N/A N/A E info N/A found %i clusters n N/A cluster_dfs N/A shuffleCluster N/A N/A i_bins c_bins tracks_map groups difference s_max i clusters_dict s_bins_max s_bins_min s_bins_width N/A N/A N/A s_bins N/A range s_bins_min N/A s_bins_max 1 s_bins_width N/A counts N/A N/A np zeros N/A N/A N/A len i_bins 1 N/A N/A len c_bins 1 N/A N/A len s_bins 1 N/A indices N/A N/A key1 key2 key3 N/A N/A key1 N/A N/A np digitize i_bins i_bins N/A key2 N/A N/A np digitize c_bins c_bins N/A key3 N/A N/A np digitize s_bins s_bins N/A iteration N/A range 0 i N/A N/A N/A N/A E info N/A performing shuffling iteration number %i.. N/A iteration 1 N/A size s_bins N/A N/A group1_mean N/A N/A group2_mean N/A N/A g1_rand_s N/A N/A g2_rand_s N/A N/A g1_rand N/A N/A N/A np random permutation N/A N/A clusters_dict keys N/A g2_rand N/A N/A N/A np random permutation N/A N/A clusters_dict keys N/A perm N/A range 0 N/A len g1_rand N/A N/A cluster1 N/A N/A N/A clusters_dict N/A N/A g1_rand N/A perm ix N/A N/A N/A N/A tracks_map N/A N/A groups N/A 0 N/A cluster2 N/A N/A N/A clusters_dict N/A N/A g2_rand N/A perm ix N/A N/A N/A N/A tracks_map N/A N/A groups N/A 1 N/A c1_rand_s N/A N/A random randint N/A min N/A cluster1 index N/A N/A max N/A cluster1 index size N/A c1_e N/A int N/A c1_rand_s size N/A c2_rand_s N/A N/A random randint N/A min N/A cluster2 index N/A N/A max N/A cluster2 index size N/A c2_e N/A int N/A c2_rand_s size N/A c1_mean N/A N/A np mean N/A N/A np mean N/A N/A cluster1 ix N/A c1_rand_s c1_e N/A c2_mean N/A N/A np mean N/A N/A np mean N/A N/A cluster2 ix N/A c2_rand_s c2_e N/A N/A N/A group1_mean append c1_mean N/A N/A N/A group2_mean append c2_mean N/A N/A N/A g1_rand_s append c1_rand_s N/A N/A N/A g2_rand_s append c2_rand_s N/A N/A change_idx initial_idx N/A means2idxarrays group1_mean group2_mean i_bins c_bins difference N/A size_idx N/A N/A np digitize N/A N/A size N/A len initial_idx s_bins N/A N/A idx coord N/A enumerate N/A zip initial_idx change_idx size_idx N/A N/A N/A N/A counts N/A coord s_max N/A N/A N/A counts N/A coord 1 N/A cluster1_ix N/A N/A N/A clusters_dict N/A N/A g1_rand N/A idx index values N/A cluster1_start N/A cluster1_ix N/A 0 N/A cluster1_end N/A cluster1_ix N/A -1 N/A cluster2_ix N/A N/A N/A clusters_dict N/A N/A g2_rand N/A idx index values N/A cluster2_start N/A cluster2_ix N/A 0 N/A cluster2_end N/A cluster2_ix N/A -1 N/A c1_rand_s N/A g1_rand_s N/A idx N/A c1_rand_e N/A int N/A c1_rand_s size N/A c2_rand_s N/A g2_rand_s N/A idx N/A c2_rand_e N/A int N/A c2_rand_s size N/A N/A N/A N/A indices N/A coord append N/A cluster1_start cluster1_end cluster2_start cluster2_end c1_rand_s c1_rand_e c2_rand_s c2_rand_e N/A N/A indices counts N/A shuffleRows N/A N/A df i_bins c_bins tracks_map groups difference s_max i N/A 100 1 N/A N/A counts N/A N/A np zeros N/A N/A N/A len i_bins 1 N/A N/A len c_bins 1 N/A N/A N/A E info Initial count table: N/A N/A N/A E info counts N/A indices N/A N/A key1 key2 N/A N/A key1 N/A N/A np digitize i_bins i_bins N/A key2 N/A N/A np digitize c_bins c_bins N/A min_occup N/A min N/A N/A counts flatten N/A iteration N/A range 0 i N/A N/A N/A N/A E info N/A performing shuffling iteration number %i.. N/A iteration 1 N/A N/A min_occup s_max N/A N/A group1_rand N/A N/A N/A np random permutation N/A df index N/A group2_rand N/A N/A N/A np random permutation N/A df index N/A group1_mean N/A N/A N/A N/A N/A N/A df ix N/A N/A group1_rand N/A tracks_map N/A N/A groups N/A 0 apply N/A np mean axis 1 tolist N/A group2_mean N/A N/A N/A N/A N/A N/A df ix N/A N/A group2_rand N/A tracks_map N/A N/A groups N/A 1 apply N/A np mean axis 1 tolist N/A N/A change_idx initial_idx N/A means2idxarrays group1_mean group2_mean i_bins c_bins difference N/A N/A N/A E info N/A Max %s N/A str N/A N/A initial_idx max N/A N/A idx coord N/A enumerate N/A zip initial_idx change_idx N/A N/A N/A coord N/A N/A indices keys N/A N/A N/A N/A counts N/A coord s_max N/A N/A N/A counts N/A coord 1 N/A N/A N/A N/A indices N/A coord append N/A N/A group1_rand N/A idx N/A group2_rand N/A idx N/A min_occup N/A min N/A N/A counts flatten N/A N/A N/A E info Final count table: N/A N/A N/A E info counts N/A N/A indices counts N/A thresholdBins N/A N/A indices counts s_min N/A N/A N/A output_indices_keep N/A N/A copy copy indices N/A key N/A N/A indices keys N/A N/A N/A N/A counts N/A key s_min N/A N/A N/A N/A output_indices_keep pop key N/A N/A N/A E info N/A %s bins retained N/A len N/A N/A output_indices_keep keys N/A N/A N/A E info N/A Just to check, the largest bin has %i subregions N/A max N/A N/A counts flatten N/A output_indices_keep N/A outputSpikes N/A N/A df id_column indices tracks_map groups method spike_type min_cbin width_cbin min_ibin width_ibin min_sbin width_sbin N/A N/A printHeader N/A N/A keep_columns groups N/A N/A N/A header keep_columns N/A N/A N/A header extend N/A tracks_map N/A N/A groups N/A 0 N/A N/A N/A header extend N/A tracks_map N/A N/A groups N/A 1 N/A N/A N/A N/A sys stdout write N/A %s
 N/A N/A join N/A map str header N/A header N/A N/A N/A spike_type row N/A N/A keep_cols N/A printHeader N/A id_column groups N/A N/A N/A spike_type cluster N/A N/A keep_cols N/A printHeader N/A contig position groups N/A N/A method append N/A N/A df N/A N/A df ix N/A N/A N/A keep_cols N/A N/A N/A df to_csv N/A sys stdout index False header False sep dtype N/A position int getInitialChangeSize N/A N/A key width_ibin min_ibin width_cbin min_cbin width_s_bin min_s_bin N/A N/A N/A N/A initial_bin change_bin size_bin key N/A initial N/A N/A N/A initial_bin width_ibin min_ibin N/A width_ibin 0.5 N/A change N/A N/A N/A change_bin width_cbin min_cbin N/A width_cbin 0.5 N/A size N/A N/A N/A size_bin width_sbin min_sbin 1 N/A N/A initial change size N/A getInitialChange N/A N/A key width_ibin min_ibin width_cbin min_cbin N/A N/A N/A N/A initial_bin change_bin key N/A initial N/A N/A N/A initial_bin width_ibin min_ibin N/A width_ibin 0.5 N/A change N/A N/A N/A change_bin width_cbin min_cbin N/A width_cbin 0.5 N/A N/A initial change N/A N/A n 0 N/A N/A spike_type row N/A N/A key indices N/A N/A pair N/A indices N/A key N/A N/A N/A initial change N/A getInitialChange key width_ibin min_ibin width_cbin min_cbin N/A row N/A N/A N/A _ join N/A map str N/A spike-in initial change n N/A N/A N/A row extend N/A N/A df ix N/A N/A N/A pair N/A 0 N/A tracks_map N/A N/A groups N/A 0 N/A N/A N/A row extend N/A N/A df ix N/A N/A N/A pair N/A 1 N/A tracks_map N/A N/A groups N/A 1 N/A N/A N/A N/A sys stdout write N/A %s
 N/A N/A join N/A map str row N/A n 1 N/A N/A N/A spike_type cluster N/A N/A key N/A N/A indices keys N/A N/A N/A initial change size N/A getInitialChangeSize key width_ibin min_ibin width_cbin min_cbin width_sbin min_sbin N/A values N/A indices N/A key N/A N/A N/A c1s c1e c2s c2e c1rs c1re c2rs c2re values N/A cluster_id N/A N/A _ join N/A map str N/A spike-in initial change size N/A c1rs c1s n N/A temp_cluster_df N/A N/A df ix N/A N/A c1s c1e N/A keep_cols N/A N/A temp_cluster_df N/A contig cluster_id N/A temp_cluster_swap N/A N/A df ix N/A N/A c2rs c2re N/A N/A tracks_map N/A N/A groups N/A 1 N/A N/A N/A temp_cluster_swap set_index N/A N/A N/A df ix N/A c1rs c1re index drop True inplace True N/A N/A N/A temp_cluster_df ix N/A N/A c1rs c1re N/A N/A tracks_map N/A N/A groups N/A 1 temp_cluster_swap N/A N/A N/A temp_cluster_df to_csv N/A sys stdout index False header False sep dtype N/A position int N/A n 1 N/A main N/A N/A argv N/A None N/A N/A script main.
    parses command line options in sys.argv, unless *argv* is given.
     N/A N/A argv N/A N/A argv N/A sys argv N/A parser N/A N/A E OptionParser version %prog version: $Id$ usage N/A N/A globals N/A __doc__ N/A N/A N/A parser add_option -t --design-file-tsv dest design_file type string help filename with design [default=%default]. N/A N/A N/A parser add_option -i --change-bin-min dest min_cbin type float help minimum bin for change bins [default=%default]. N/A N/A N/A parser add_option -x --change-bin-max dest max_cbin type float help maximum bin for change bins [default=%default]. N/A N/A N/A parser add_option -w --change-bin-width dest width_cbin type float help bin width for change bins [default=%default]. N/A N/A N/A parser add_option -s --initial-bin-min dest min_ibin type float help minimum bin for initial bins[default=%default]. N/A N/A N/A parser add_option -e --initial-bin-max dest max_ibin type float help maximum bin for intitial bins[default=%default]. N/A N/A N/A parser add_option -y --initial-bin-width dest width_ibin type float help bin width intitial bins[default=%default]. N/A N/A N/A parser add_option -l --spike-minimum dest min_spike type int help minimum number of spike-ins required within each bin                      [default=%default]. N/A N/A N/A parser add_option -u --spike-maximum dest max_spike type int help maximum number of spike-ins allowed within each bin                      [default=%default]. N/A N/A N/A parser add_option -d --difference-method dest difference type choice choices N/A relative logfold help method to use for calculating difference                      [default=%default]. N/A N/A N/A parser add_option -r --iterations dest iterations type int help number of iterations [default=%default]. N/A N/A N/A parser add_option -a --id_columns dest id action append help name of identification column(s)                      [default=%default]. N/A N/A N/A parser add_option -c --cluster-maximum-distance dest cluster_max_distance type int help maximum distance between adjacent loci in cluster                      [default=%default]. N/A N/A N/A parser add_option -b --cluster-minimum-size dest cluster_min_size type int help minimum number of loci required per cluster                      [default=%default]. N/A N/A N/A parser add_option -f --spike-type dest spike_type type choice choices N/A row cluster help spike in type [default=%default]. N/A N/A N/A parser add_option -g --subcluster-min-size dest min_sbin type int help minimum size of subcluster                      [default=%default]. N/A N/A N/A parser add_option -j --subcluster-max-size dest max_sbin type int help maximum size of subcluster                      [default=%default]. N/A N/A N/A parser add_option -k --subcluster-bin-width dest width_sbin type int help bin width for subcluster size                      [default=%default]. N/A N/A N/A parser add_option -o --output-method dest output_method type choice choices N/A append seperate help defines whether the spike-ins should be appended                      to the original table or seperately [default=%default]. N/A N/A N/A parser add_option -p --shuffle-column-suffix dest shuffle_suffix type string help the suffix of the columns which are to be shuffled                      [default=%default]. N/A N/A N/A parser add_option -q --keep-column-suffix dest keep_suffix type string help a list of suffixes for the columns which are to be                      keep along with the shuffled columns[default=%default]. N/A N/A N/A parser add_option -z --spike-regex dest spike_regex type string action append help a regex to identify tracks for shuffling                      [default=%default]. N/A N/A N/A parser set_defaults design_file None output_method seperate difference relative spike_type row genome_file None min_cbin None max_cbin None width_cbin None min_ibin None max_ibin None width_ibin None id_columns None max_spike 100 min_spike None iterations 1 cluster_max_distance 100 cluster_min_size 10 min_sbin 1 max_sbin 9 width_sbin 2 id_column None shuffle_suffix None keep_suffix None spike_regex .* N/A N/A options args N/A N/A E Start parser argv argv add_output_options True N/A df N/A N/A pd read_table N/A sys stdin sep N/A N/A N/A options spike_type cluster N/A N/A df_sort N/A N/A df sort columns N/A contig position N/A N/A N/A df_sort set_index N/A df index inplace True N/A N/A df_sort df N/A N/A N/A options design_file N/A N/A N/A ValueError a design table is required. N/A N/A N/A options spike_type cluster N/A N/A N/A N/A options max_sbin N/A options cluster_min_size N/A N/A N/A ValueError N/A maximum size of subscluster bin: %s            is greater than minimum size of cluster: %s N/A N/A options max_sbin N/A options cluster_min_size N/A df_columns N/A set N/A N/A N/A N/A df columns values tolist N/A msg cluster analysis requires columns named 'contig' and        'position' in the dataframe N/A N/A N/A contig df_columns N/A position df_columns msg N/A msg2 N/A the minimum cluster size (%s) must be larger than the maximum
        size of subcluster to be shuffled (%s) N/A N/A options cluster_min_size N/A options max_sbin N/A N/A N/A options max_sbin N/A options cluster_min_size msg2 N/A df_sort N/A N/A df sort columns N/A contig position N/A N/A N/A df_sort set_index N/A df index inplace True N/A N/A N/A options id_column N/A N/A N/A N/A N/A options output_method append N/A N/A options spike_type row N/A N/A N/A ValueError id column must be specified to append rows N/A N/A N/A N/A options output_method append N/A N/A N/A options id_column id N/A N/A N/A options min_spike N/A N/A N/A options min_spike N/A options max_spike N/A design_table N/A N/A pd read_table N/A options design_file sep N/A N/A groups g_to_keep_tracks g_to_spike_tracks N/A groupMappers design_table N/A options spike_regex N/A options shuffle_suffix N/A options keep_suffix N/A change_bins N/A N/A np arange N/A options min_cbin N/A options max_cbin N/A options width_cbin N/A N/A N/A E info N/A Column boundaries are: %s N/A str change_bins N/A initial_bins N/A N/A np arange N/A options min_ibin N/A options max_ibin N/A options width_ibin N/A N/A N/A E info N/A Row boundaries are: %s N/A str initial_bins N/A N/A N/A options spike_type cluster N/A N/A N/A N/A E info looking for clusters... N/A clusters_dict N/A findClusters df_sort N/A options cluster_max_distance N/A options cluster_min_size g_to_spike_tracks groups N/A N/A N/A len clusters_dict 0 N/A N/A N/A Exception no clusters were found, check parameters N/A N/A N/A E info repeatedly shuffling subcluster regions... N/A N/A output_indices counts N/A shuffleCluster initial_bins change_bins g_to_spike_tracks groups N/A options difference N/A options max_spike N/A options iterations clusters_dict N/A options max_sbin N/A options min_sbin N/A options width_sbin N/A N/A N/A N/A options spike_type row N/A N/A N/A N/A E info repeatedly shuffling rows... N/A N/A output_indices counts N/A shuffleRows df initial_bins change_bins g_to_spike_tracks groups N/A options difference N/A options max_spike N/A options iterations N/A filled_bins N/A thresholdBins output_indices counts N/A options min_spike N/A N/A N/A len filled_bins 0 N/A N/A N/A Exception No bins contained a sufficient number of spike-ins N/A N/A N/A E info outputting spike-ins... N/A N/A outputSpikes df_sort N/A options id_column filled_bins g_to_keep_tracks groups method N/A options output_method spike_type N/A options spike_type min_cbin N/A options min_cbin width_cbin N/A options width_cbin min_ibin N/A options min_ibin width_ibin N/A options width_ibin min_sbin N/A options min_sbin width_sbin N/A options width_sbin N/A N/A N/A E Stop N/A N/A N/A __name__ __main__ N/A N/A N/A N/A sys exit N/A main N/A sys argv