Mercurial > repos > pjbriggs > rnachipintegrator
changeset 1:ec554325f16a draft
Uploaded initial test toolshed version 1.0.0.0.
author | pjbriggs |
---|---|
date | Wed, 24 Feb 2016 09:27:54 -0500 |
parents | 0abe6bac47a6 |
children | d37526cd12aa |
files | install_tool_deps.sh make_test_data.sh make_test_data/features.txt make_test_data/mm9_canonical_genes.tsv make_test_data/mm9_peaks.txt make_test_data/mm9_summits.txt make_test_data/peaks.txt make_test_data/summits.txt package_rnachipintegrator_wrapper.sh rnachipintegrator-1.0.0.tgz run_planemo_tests.sh test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/RnaChipIntegrator/ChangeLog test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/RnaChipIntegrator/INSTALL test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/RnaChipIntegrator/LICENSE test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/RnaChipIntegrator/README.rst test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/bin/RnaChipIntegrator test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/bin/vba_extract.py test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/env.sh test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/RnaChipIntegrator-1.0.0-py2.7.egg-info/PKG-INFO test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/RnaChipIntegrator-1.0.0-py2.7.egg-info/SOURCES.txt test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/RnaChipIntegrator-1.0.0-py2.7.egg-info/dependency_links.txt test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/RnaChipIntegrator-1.0.0-py2.7.egg-info/entry_points.txt test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/RnaChipIntegrator-1.0.0-py2.7.egg-info/installed-files.txt test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/RnaChipIntegrator-1.0.0-py2.7.egg-info/not-zip-safe test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/RnaChipIntegrator-1.0.0-py2.7.egg-info/requires.txt test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/RnaChipIntegrator-1.0.0-py2.7.egg-info/top_level.txt test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/XlsxWriter-0.8.4-py2.7.egg-info/PKG-INFO test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/XlsxWriter-0.8.4-py2.7.egg-info/SOURCES.txt test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/XlsxWriter-0.8.4-py2.7.egg-info/dependency_links.txt test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/XlsxWriter-0.8.4-py2.7.egg-info/installed-files.txt test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/XlsxWriter-0.8.4-py2.7.egg-info/top_level.txt test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/rnachipintegrator/Features.py test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/rnachipintegrator/Features.pyc test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/rnachipintegrator/Peaks.py test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/rnachipintegrator/Peaks.pyc test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/rnachipintegrator/__init__.py test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/rnachipintegrator/__init__.pyc test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/rnachipintegrator/analysis.py test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/rnachipintegrator/analysis.pyc test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/rnachipintegrator/cli.py test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/rnachipintegrator/cli.pyc test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/rnachipintegrator/distances.py test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/rnachipintegrator/distances.pyc test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/rnachipintegrator/output.py test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/rnachipintegrator/output.pyc test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/rnachipintegrator/utils.py test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/rnachipintegrator/utils.pyc test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/rnachipintegrator/xls_output.py test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/rnachipintegrator/xls_output.pyc test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/__init__.py test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/__init__.pyc test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/app.py test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/app.pyc test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/chart.py test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/chart.pyc test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/chart_area.py test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/chart_area.pyc test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/chart_bar.py test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/chart_bar.pyc test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/chart_column.py test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/chart_column.pyc test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/chart_doughnut.py test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/chart_doughnut.pyc test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/chart_line.py test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/chart_line.pyc test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/chart_pie.py test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/chart_pie.pyc test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/chart_radar.py test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/chart_radar.pyc test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/chart_scatter.py test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/chart_scatter.pyc test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/chart_stock.py test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/chart_stock.pyc test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/chartsheet.py test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/chartsheet.pyc test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/comments.py test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/comments.pyc test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/compat_collections.py test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/compat_collections.pyc test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/compatibility.py test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/compatibility.pyc test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/contenttypes.py test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/contenttypes.pyc test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/core.py test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/core.pyc test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/drawing.py test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/drawing.pyc test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/format.py test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/format.pyc test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/packager.py test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/packager.pyc test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/relationships.py test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/relationships.pyc test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/shape.py test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/shape.pyc test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/sharedstrings.py test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/sharedstrings.pyc test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/styles.py test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/styles.pyc test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/table.py test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/table.pyc test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/theme.py test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/theme.pyc test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/utility.py test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/utility.pyc test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/vml.py test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/vml.pyc test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/workbook.py test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/workbook.pyc test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/worksheet.py test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/worksheet.pyc test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/xmlwriter.py test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/xmlwriter.pyc test.tool_dependencies.rnachipintegrator/xlsxwriter/0.8.4/bin/vba_extract.py test.tool_dependencies.rnachipintegrator/xlsxwriter/0.8.4/env.sh test.tool_dependencies.rnachipintegrator/xlsxwriter/0.8.4/lib/python/XlsxWriter-0.8.4-py2.7.egg test.tool_dependencies.rnachipintegrator/xlsxwriter/0.8.4/lib/python/easy-install.pth test.tool_dependencies.rnachipintegrator/xlsxwriter/0.8.4/lib/python/site.py test.tool_dependencies.rnachipintegrator/xlsxwriter/0.8.4/lib/python/site.pyc tool_data_table_conf.xml.test |
diffstat | 120 files changed, 0 insertions(+), 27277 deletions(-) [+] |
line wrap: on
line diff
--- a/install_tool_deps.sh Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,64 +0,0 @@ -#!/bin/bash -e -# -# Install the tool dependencies for RnaChipIntegrator for testing from command line -# -# Installation directory -TOP_DIR=$1 -if [ -z "$TOP_DIR" ] ; then - echo Usage: $(basename $0) DIR - exit -fi -if [ -z "$(echo $TOP_DIR | grep ^/)" ] ; then - TOP_DIR=$(pwd)/$TOP_DIR -fi -if [ ! -d "$TOP_DIR" ] ; then - mkdir -p $TOP_DIR -fi -cd $TOP_DIR -# RnaChipIntegrator 1.0.0 -VERSION=1.0.0 -INSTALL_DIR=$TOP_DIR/rnachipintegrator/$VERSION -mkdir -p $INSTALL_DIR -wd=$(mktemp -d) -pushd $wd -wget https://pypi.python.org/packages/source/R/RnaChipIntegrator/RnaChipIntegrator-${VERSION}.tar.gz -tar zxf RnaChipIntegrator-${VERSION}.tar.gz -cd RnaChipIntegrator-$VERSION -pip install --no-use-wheel --install-option "--prefix=$INSTALL_DIR" . -popd -rm -rf $wd/* -rmdir $wd -cat > rnachipintegrator/$VERSION/env.sh <<EOF -#!/bin/sh -# Source this to setup rnachipintegrator/$VERSION -echo Setting up RnaChipIntegrator $VERSION -export PATH=$INSTALL_DIR/bin:\$PATH -export PYTHONPATH=$INSTALL_DIR/lib/python2.7/site-packages:\$PYTHONPATH -# -EOF -# xlsxwriter 0.8.4 -INSTALL_DIR=$TOP_DIR/xlsxwriter/0.8.4 -mkdir -p $INSTALL_DIR -wd=$(mktemp -d) -pushd $wd -wget -q https://pypi.python.org/packages/source/X/XlsxWriter/XlsxWriter-0.8.4.tar.gz -tar xzf XlsxWriter-0.8.4.tar.gz -cd XlsxWriter-0.8.4 -OLD_PYTHONPATH=$PYTHONPATH -mkdir -p $INSTALL_DIR/lib/python -export PYTHONPATH=$PYTHONPATH:$INSTALL_DIR/lib/python -python setup.py install --install-lib $INSTALL_DIR/lib/python --install-scripts $INSTALL_DIR/bin -popd -rm -rf $wd/* -rmdir $wd -export PYTHONPATH=$OLD_PYTHONPATH -cat > xlsxwriter/0.8.4/env.sh <<EOF -#!/bin/sh -# Source this to setup xlsxwriter/0.8.4 -echo Setting up xlsxwriter 0.8.4 -export PYTHONPATH=$INSTALL_DIR/lib/python:\$PYTHONPATH -export PATH=$INSTALL_DIR/bin:\$PATH -# -EOF -## -#
--- a/make_test_data.sh Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,126 +0,0 @@ -#!/bin/bash -e -# -# List of dependencies -TOOL_DEPENDENCIES="rnachipintegrator/0.5.0-alpha.7 - xlsxwriter/0.8.4" -# Where to find them -TOOL_DEPENDENCIES_DIR=$(pwd)/test.tool_dependencies.rnachipintegrator -if [ ! -d $TOOL_DEPENDENCIES_DIR ] ; then - echo WARNING $TOOL_DEPENDENCIES_DIR not found >&2 - echo Creating tool dependencies dir - mkdir -p $TOOL_DEPENDENCIES_DIR - echo Installing tool dependencies - $(dirname $0)/install_tool_deps.sh $TOOL_DEPENDENCIES_DIR -fi -# Load dependencies -for dep in $TOOL_DEPENDENCIES ; do - env_file=$TOOL_DEPENDENCIES_DIR/$dep/env.sh - if [ -e $env_file ] ; then - . $env_file - else - echo ERROR no env.sh file found for $dep >&2 - exit 1 - fi -done -# -# rnachipintegrator_canonical_genes -# -# Test #1 -RnaChipIntegrator --name=mm9 \ - --cutoff=50000 \ - --number=4 \ - --xlsx \ - --compact \ - test-data/mm9_canonical_genes.tsv test-data/mm9_summits.txt -mv mm9_gene_centric.txt test-data/mm9_summits_per_feature.out -mv mm9_peak_centric.txt test-data/mm9_features_per_summit.out -mv mm9.xlsx test-data/mm9_summits.xlsx -# -# Test #2 -RnaChipIntegrator --name=mm9 \ - --cutoff=50000 \ - --number=4 \ - --xlsx \ - --compact \ - test-data/mm9_canonical_genes.tsv test-data/mm9_peaks.txt -mv mm9_gene_centric.txt test-data/mm9_peaks_per_feature1.out -mv mm9_peak_centric.txt test-data/mm9_features_per_peak1.out -mv mm9.xlsx test-data/mm9_peaks1.xlsx -# -# Test #3 -RnaChipIntegrator --name=mm9 \ - --cutoff=50000 \ - --number=4 \ - --xlsx \ - --summary \ - --pad \ - test-data/mm9_canonical_genes.tsv test-data/mm9_peaks.txt -mv mm9_gene_centric.txt test-data/mm9_peaks_per_feature3.out -mv mm9_peak_centric.txt test-data/mm9_features_per_peak3.out -mv mm9_gene_centric_summary.txt test-data/mm9_peaks_per_feature3.summary -mv mm9_peak_centric_summary.txt test-data/mm9_features_per_peak3.summary -mv mm9.xlsx test-data/mm9_peaks3.xlsx -# -# rnachipintegrator_wrapper -# -# Test #1 -RnaChipIntegrator --name=test \ - --cutoff=130000 \ - --number=4 \ - --promoter_region=-10000,2500 \ - --xlsx \ - --compact \ - test-data/features.txt test-data/summits.txt -mv test_gene_centric.txt test-data/summits_per_feature.out -mv test_peak_centric.txt test-data/features_per_summit.out -mv test.xlsx test-data/summits.xlsx -# -# Test #2 -RnaChipIntegrator --name=test \ - --cutoff=130000 \ - --number=4 \ - --promoter_region=-10000,2500 \ - --xlsx \ - --compact \ - test-data/features.txt test-data/peaks.txt -mv test_gene_centric.txt test-data/peaks_per_feature1.out -mv test_peak_centric.txt test-data/features_per_peak1.out -mv test.xlsx test-data/peaks1.xlsx -# -# Test #3 -RnaChipIntegrator --name=test \ - --cutoff=130000 \ - --number=4 \ - --xlsx \ - test-data/features.txt test-data/peaks.txt -mv test_gene_centric.txt test-data/peaks_per_feature2.out -mv test_peak_centric.txt test-data/features_per_peak2.out -mv test.xlsx test-data/peaks2.xlsx -# -# Test #4 -RnaChipIntegrator --name=test \ - --cutoff=130000 \ - --number=4 \ - --only-DE \ - --xlsx \ - --compact \ - test-data/features.txt test-data/peaks.txt -mv test_gene_centric.txt test-data/peaks_per_feature3.out -mv test_peak_centric.txt test-data/features_per_peak3.out -mv test.xlsx test-data/peaks3.xlsx -# -# Test #5 -RnaChipIntegrator --name=test \ - --cutoff=130000 \ - --number=4 \ - --xlsx \ - --summary \ - --pad \ - test-data/features.txt test-data/peaks.txt -mv test_gene_centric.txt test-data/peaks_per_feature4.out -mv test_peak_centric.txt test-data/features_per_peak4.out -mv test_gene_centric_summary.txt test-data/peaks_per_feature4.summary -mv test_peak_centric_summary.txt test-data/features_per_peak4.summary -mv test.xlsx test-data/peaks4.xlsx -## -#
--- a/make_test_data/features.txt Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,957 +0,0 @@ -#RefSeq_Gene Symbol chr1 start stop strand diff_exp -AF064749_Col6a3 chr1 92566771 92800755 - 1 -AK015559_4930472D16Rik chr1 25020851 25021989 - 1 -AK030377_A330023F24Rik chr1 196781953 196826186 - 1 -AK080193_A530079E22Rik chr1 89401837 89403491 - 1 -AK082264_C230030N03Rik chr1 34735043 34781084 + 1 -BC006931_AI597479 chr1 43153807 43172843 + 1 -BC021773_Glb1l chr1 75193364 75207353 - 1 -BC023951_D1Ertd622e chr1 99540054 99558631 - 1 -BC028767_3110009E18Rik chr1 122017764 122114603 + 1 -BC031781_BC031781 chr1 182781250 182798240 + 1 -BC034187_BC035947 chr1 78493611 78497758 - 1 -BC043098_Fam168b chr1 34870072 34917183 - 1 -BC049091_D1Bwg0212e chr1 39592545 39603734 + 1 -BC049713_Ankrd45 chr1 163072817 163099826 + 1 -BC050813_4921511C04Rik chr1 37157481 37244861 + 1 -BC051128_4921521F21Rik chr1 65059273 65079312 - 1 -BC052693_2810422O20Rik chr1 165924541 165927371 + 1 -BC052931_A630001G21Rik chr1 87601462 87674840 - 1 -BC053100_5730559C18Rik chr1 138110108 138130841 - 1 -BC054802_9630058J23Rik chr1 181476521 181558044 + 1 -BC055845_2810025M15Rik chr1 159342483 159350353 + 1 -BC055955_A130010J15Rik chr1 194999663 195004015 + 1 -BC057872_Rab3gap2 chr1 187028006 187110623 + 1 -BC058417_2610017I09Rik chr1 42648822 42751667 - 1 -BC059254_Phlpp chr1 108042052 108306367 + 1 -BC070435_Fam123c chr1 34620070 34671545 + 1 -BC070446_Fam135a chr1 24017617 24107170 - 1 -BC071241_9430016H08Rik chr1 57463192 57497936 + 1 -BC072639_2010300C02Rik chr1 37646877 37776659 - 1 -BC080290_5033414K04Rik chr1 84032539 84360735 - 0 -BC082310_9430031J16Rik chr1 81073525 81338329 + 0 -BC089525_2310007B03Rik chr1 95047933 95063386 - 0 -BC089561_Cep350 chr1 157692096 157820375 - 0 -BC147491_A230074B11Rik chr1 37083441 37133840 + 0 -BC147657_9630028B13Rik chr1 187253234 187265698 - 0 -ENSMUST00000027997_Rgs5 chr1 171625108 171625913 + 0 -ENSMUST00000051203_1700001G17Rik chr1 33726669 33727551 + 0 -ENSMUST00000054333_A130050O07Rik chr1 139823828 139826840 + 0 -ENSMUST00000056879_C230029F24Rik chr1 49301475 49397265 + 0 -ENSMUST00000057543_A730013G03Rik chr1 194659323 194661397 - 0 -ENSMUST00000062637_4930470H14Rik chr1 175156866 175201240 + 0 -ENSMUST00000070048_ENSMUSG00000056128 chr1 92571736 92576368 + 0 -ENSMUST00000070987_EG433384 chr1 183781705 183783320 - 0 -ENSMUST00000072395_Olfr1406 chr1 175113651 175120746 - 0 -ENSMUST00000094288_Wdr64 chr1 177654798 177798070 + 0 -ENSMUST00000094950_Pgap1 chr1 54529849 54614539 - 0 -ENSMUST00000097776_Cnnm3 chr1 36567938 36585164 + 0 -EU429481_Igfn1 chr1 137825893 137890307 - 0 -FJ024495_Ildr2 chr1 168236882 168239692 - 0 -FJ210934_Unc80 chr1 66514856 66556109 + 0 -NM_001001565_Chpf chr1 75470923 75476437 - 0 -NM_001001809_Olfr218 chr1 175130421 175134469 + 0 -NM_001001883_Hecw2 chr1 53867026 54252002 - 0 -NM_001003917_Atg9a chr1 75177439 75189181 - 0 -NM_001004173_Sgpp2 chr1 78306692 78416864 + 0 -NM_001005423_Mreg chr1 72170192 72258895 - 0 -NM_001005507_Smg7 chr1 154684125 154750410 - 0 -NM_001005508_Arhgap30 chr1 173319072 173340822 + 0 -NM_001005520_Olfr244 chr1 176032571 176067605 - 0 -NM_001008419_Aox3l1 chr1 58335180 58437083 + 0 -NM_001008426_EG433365 chr1 155721475 155724001 + 0 -NM_001008533_Adora1 chr1 136095799 136181661 - 0 -NM_001009940_Il19 chr1 132786042 132915234 - 0 -NM_001011525_Olfr1415 chr1 94376258 94381054 - 0 -NM_001011525_Olfr1415 chr1 94407669 94418761 - 0 -NM_001011684_Nms chr1 38995917 39007113 + 0 -NM_001011873_Xkr9 chr1 13658862 13691794 + 0 -NM_001011874_Xkr4 chr1 3203722 3713108 - 0 -NM_001012330_Zfp238 chr1 179359958 179380892 + 0 -NM_001013374_Lman2l chr1 36362897 36502078 - 0 -NM_001013382_Lrrc52 chr1 169375806 169397136 - 0 -NM_001013771_Gm973 chr1 59573136 59693241 + 0 -NM_001013779_Aim2 chr1 175385835 175396165 + 0 -NM_001014974_Ttll4 chr1 74708314 74748400 + 0 -NM_001024721_BC094916 chr1 175451304 175466101 - 0 -NM_001024945_Qsox1 chr1 157625296 157670499 - 0 -NM_001025156_Ccdc93 chr1 123208865 123403037 + 0 -NM_001025565_Lhx9 chr1 140694768 140740509 - 0 -NM_001025602_Il1rl1 chr1 40462708 40522260 + 0 -NM_001029984_Fcrlb chr1 172836813 172843072 - 0 -NM_001037170_Tomm40l chr1 173147934 173152645 - 0 -NM_001037725_Fam117b chr1 59937517 60042190 + 0 -NM_001037918_Lipt1 chr1 37928603 37934232 + 0 -NM_001037999_Dbi chr1 122009883 122046068 - 0 -NM_001038592_Glrx2 chr1 145585774 145608282 + 0 -NM_001038619_Dnm3 chr1 163902671 164408155 - 0 -NM_001039126_Asb1 chr1 93437143 93461729 + 0 -NM_001039472_Kif21b chr1 138027986 138074578 + 0 -NM_001039475_Slco6b1 chr1 98802763 98894139 - 0 -NM_001039482_Klhl20 chr1 163018528 163061699 - 0 -NM_001039483_Tmco1 chr1 169238419 169279112 + 0 -NM_001039484_Kcnj10 chr1 174258852 174304216 + 0 -NM_001039493_Plekhm3 chr1 64832557 65032270 - 0 -NM_001039495_Ccdc108 chr1 74947239 74982168 - 0 -NM_001039509_Pnkd chr1 74331504 74400245 + 0 -NM_001039710_Coq10b chr1 55101051 55129538 + 0 -NM_001039934_Mtap2 chr1 66187374 66489157 + 0 -NM_001042634_Clk1 chr1 58467034 58480936 - 0 -NM_001045481_Ifi203 chr1 175804708 175928457 - 0 -NM_001077189_Fcgr2b chr1 172890316 172916060 - 0 -NM_001077353_Gsta3 chr1 21230690 21255722 + 0 -NM_001077403_Nrp2 chr1 62724499 63100251 + 0 -NM_001081023_Cacna1s chr1 137949297 138016348 + 0 -NM_001081078_Lct chr1 130174327 130224881 - 0 -NM_001081079_Ogfrl1 chr1 23278472 23451348 - 0 -NM_001081259_Mfsd7b chr1 192825304 192850534 - 0 -NM_001081275_1700009P17Rik chr1 173032694 173057075 + 0 -NM_001081361_Mosc1 chr1 186610666 186635172 - 0 -NM_001081756_E030049G20Rik chr1 128277776 128727190 - 0 -NM_001082573_Crygc chr1 65118108 65146863 - 0 -NM_001083897_Mpzl1 chr1 167522314 167564669 - 0 -NM_001085409_Steap3 chr1 122037552 122169282 - 0 -NM_001099637_Cep170 chr1 178663793 178744307 - 0 -NM_001103182_Lin9 chr1 182572002 182620816 + 0 -NM_001105667_Dtymk chr1 95689006 95698492 - 0 -NM_001110783_Ank1 chr1 77759424 77766452 - 0 -NM_001110831_Dnpep chr1 75304471 75314673 - 0 -NM_001111059_Cd34 chr1 196683888 196826273 + 0 -NM_001111279_Wdfy1 chr1 79689958 79772698 - 0 -NM_001111314_Ngef chr1 89373415 89470499 - 0 -NM_001111316_Ptprc chr1 139959456 140088994 - 0 -NM_001111320_Idh1 chr1 65185668 65233033 - 0 -NM_001113394_Cd247 chr1 167711216 167807397 + 0 -NM_001122685_Rhbdd1 chr1 82313047 82441937 + 0 -NM_001126046_Fam178b chr1 36619544 36740008 - 0 -NM_001128605_Psen2 chr1 182157140 182247499 - 0 -NM_001128609_Dedd chr1 173258959 173273620 + 0 -NM_001130174_Tnnt2 chr1 137732931 137748838 + 0 -NM_001134829_Lpgat1 chr1 193521144 193605705 + 0 -NM_001136070_Lgtn chr1 133049773 133084235 + 0 -NM_001142647_Tmem194b chr1 52687569 52708760 + 0 -NM_001159649_Lax1 chr1 135575626 135586665 - 0 -NM_001159719_Sept2 chr1 95375046 95406820 + 0 -NM_001159730_Pdc chr1 152154402 152181077 + 0 -NM_007381_Acadl chr1 66861363 66909886 - 0 -NM_007415_Parp1 chr1 182499033 182531385 + 0 -NM_007422_Adss chr1 179693113 179888685 - 0 -NM_007432_Akp3 chr1 89021583 89042994 + 0 -NM_007433_Akp5 chr1 88983274 88986861 - 0 -NM_007453_Prdx6 chr1 163170243 163210238 - 0 -NM_007463_Speg chr1 75371872 75428879 + 0 -NM_007495_Astn1 chr1 160292424 160626748 + 0 -NM_007498_Atf3 chr1 192994178 193057173 - 0 -NM_007525_Bard1 chr1 71076934 71149526 - 0 -NM_007561_Bmpr2 chr1 59820296 59927706 + 0 -NM_007570_Btg2 chr1 135971251 135991759 - 0 -NM_007576_C4bp chr1 132531357 132558199 - 0 -NM_007642_Cd28 chr1 60763315 60830749 + 0 -NM_007649_Cd48 chr1 173603288 173635385 + 0 -NM_007685_Cfc1 chr1 34592493 34601156 + 0 -NM_007695_Chi3l1 chr1 136069840 136086738 + 0 -NM_007722_Cxcr7 chr1 92100063 92112863 + 0 -NM_007733_Col19a1 chr1 24258667 24602262 - 0 -NM_007734_Col4a3 chr1 82583506 82718629 + 0 -NM_007735_Col4a4 chr1 82438140 82584744 - 0 -NM_007737_Col5a2 chr1 45431177 45560226 - 0 -NM_007740_Col9a1 chr1 24164692 24268636 + 0 -NM_007758_Cr2 chr1 196963005 197003002 - 0 -NM_007768_Crp chr1 174620782 174763152 + 0 -NM_007774_Cryga chr1 65146986 65150012 - 0 -NM_007776_Crygd chr1 65108417 65110024 - 0 -NM_007777_Cryge chr1 65095133 65097767 - 0 -NM_007791_Csrp1 chr1 137526251 137648807 + 0 -NM_007799_Ctse chr1 133534879 133572077 + 0 -NM_007827_Daf2 chr1 132285116 132319576 - 0 -NM_007842_Dhx9 chr1 155302618 155334755 - 0 -NM_007853_Degs1 chr1 184205901 184212915 - 0 -NM_007921_Elf3 chr1 137149649 137155139 - 0 -NM_007923_Elk4 chr1 133904204 133929189 + 0 -NM_007936_Epha4 chr1 77280640 77511653 - 0 -NM_007955_Ptprv chr1 137004306 137029151 - 0 -NM_007976_F5 chr1 166081877 166150388 + 0 -NM_008030_Fmo3 chr1 164883934 164914811 - 0 -NM_008057_Fzd7 chr1 59538966 59546428 + 0 -NM_008059_G0s2 chr1 195098362 195108977 - 0 -NM_008131_Glul chr1 155746721 155757023 + 0 -NM_008132_Glrp1 chr1 90396446 90406631 - 0 -NM_008209_Mr1 chr1 156951231 157006024 - 0 -NM_008210_H3f3a chr1 182694052 182744054 - 0 -NM_008250_Hlx chr1 186542564 186592227 - 0 -NM_008288_Hsd11b1 chr1 195047814 195090228 - 0 -NM_008299_Dnajb3 chr1 90101307 90102337 - 0 -NM_008311_Htr2b chr1 87995611 88008576 - 0 -NM_008327_Ifi202b chr1 175892699 175912872 - 0 -NM_008329_Ifi204 chr1 175677424 175929523 - 0 -NM_008342_Igfbp2 chr1 72840313 72899038 + 0 -NM_008362_Il1r1 chr1 40274145 40373439 + 0 -NM_008365_Il18r1 chr1 40522407 40557703 + 0 -NM_008384_Inpp1 chr1 52826936 52890006 - 0 -NM_008429_Kcnj9 chr1 174250632 174259434 - 0 -NM_008440_Kif1a chr1 94912041 94998420 - 0 -NM_008484_Lamb3 chr1 195033913 195170047 + 0 -NM_008485_Lamc2 chr1 154969890 155033557 - 0 -NM_008510_Xcl1 chr1 166861801 166916999 - 0 -NM_008515_Lrrfip1 chr1 92895314 93025509 + 0 -NM_008534_Ly9 chr1 173518153 173537531 - 0 -NM_008551_Mapkapk2 chr1 132950274 133013820 - 0 -NM_008563_Mcm3 chr1 20792654 20810343 - 0 -NM_008567_Mcm6 chr1 130228167 130256262 - 0 -NM_008575_Mdm4 chr1 134877138 134927144 - 0 -NM_008623_Mpz chr1 173081953 173091254 + 0 -NM_008651_Mybl1 chr1 9635825 9690280 - 0 -NM_008667_Nab1 chr1 52487127 52611216 - 0 -NM_008678_Ncoa2 chr1 13129206 13399268 - 0 -NM_008696_Map4k4 chr1 39958025 40102235 + 0 -NM_008719_Npas2 chr1 39250631 39420071 + 0 -NM_008763_Olfr16 chr1 174886928 174887857 + 0 -NM_008765_Orc2l chr1 58519275 58561933 - 0 -NM_008781_Pax3 chr1 78047196 78193701 - 0 -NM_008795_Pctk3 chr1 133972174 134036519 - 0 -NM_008798_Pdcd1 chr1 95931620 95977526 - 0 -NM_008801_Pde6d chr1 88427331 88479102 - 0 -NM_008825_Pfkfb2 chr1 132566787 132625820 - 0 -NM_008866_Lypla1 chr1 4797815 4844373 + 0 -NM_008869_Pla2g4a chr1 151661289 151808414 - 0 -NM_008882_Plxna2 chr1 196411150 196654445 + 0 -NM_008900_Pou3f3 chr1 42662066 42757055 + 0 -NM_008911_Ppox chr1 173200042 173211335 - 0 -NM_008922_Prim2 chr1 33510658 33727287 - 0 -NM_008937_Prox1 chr1 191943166 191999411 - 0 -NM_008976_Ptpn14 chr1 191512039 191694746 + 0 -NM_008985_Ptprn chr1 75243625 75261057 - 0 -NM_008998_Rab17 chr1 92842177 92905581 - 0 -NM_008999_Rab23 chr1 33776747 33799402 + 0 -NM_009049_Resp18 chr1 75268774 75274970 - 0 -NM_009061_Rgs2 chr1 145846468 145858945 - 0 -NM_009062_Rgs4 chr1 171671620 171743114 - 0 -NM_009063_Rgs5 chr1 171585632 171625107 + 0 -NM_009107_Rxrg chr1 169399669 169569753 + 0 -NM_009118_Sag chr1 89700275 89741733 + 0 -NM_009126_Serpinb3a chr1 108942184 108948902 - 0 -NM_009129_Scg2 chr1 79431244 79436675 - 0 -NM_009183_St8sia4 chr1 97484259 97672426 - 0 -NM_009190_Vps4b chr1 108665873 108739123 - 0 -NM_009208_Slc4a3 chr1 75539833 75564973 + 0 -NM_009230_Soat1 chr1 158354679 158417632 - 0 -NM_009255_Serpine2 chr1 79778648 79891246 - 0 -NM_009257_Serpinb5 chr1 108757652 108779925 + 0 -NM_009283_Stat1 chr1 51740305 52218707 + 0 -NM_009307_Syt2 chr1 136543209 136659150 + 0 -NM_009334_Tcfap2b chr1 19198995 19228906 + 0 -NM_009352_Terf1 chr1 15785995 15845901 + 0 -NM_009355_Tesp1 chr1 34554997 34559905 + 0 -NM_009356_Tesp2 chr1 34594321 34617749 - 0 -NM_009367_Tgfb2 chr1 188337162 188544530 - 0 -NM_009399_Tnfrsf11a chr1 107677300 107859295 + 0 -NM_009407_Tnp1 chr1 73061657 73062512 - 0 -NM_009418_Tpp2 chr1 43936027 44065003 + 0 -NM_009447_Tuba4a chr1 75210818 75219831 - 0 -NM_009452_Tnfsf4 chr1 163212600 163374314 + 0 -NM_009460_Sumo1 chr1 59643412 59727658 - 0 -NM_009480_Usf1 chr1 173341335 173348954 + 0 -NM_009509_Vil1 chr1 74455970 74485488 + 0 -NM_009518_Wnt10a chr1 74838090 74898253 + 0 -NM_009526_Wnt6 chr1 74818493 74831875 + 0 -NM_009533_Xrcc5 chr1 72354001 72453365 + 0 -NM_009539_Zap70 chr1 36818663 36839663 + 0 -NM_009579_Slc30a1 chr1 193730666 193737101 + 0 -NM_009581_Zp3r chr1 132473290 132526179 - 0 -NM_009604_Chrng chr1 89102267 89109269 + 0 -NM_009676_Aox1 chr1 58086687 58165423 + 0 -NM_009721_Atp1b1 chr1 166367243 166524675 - 0 -NM_009741_Bcl2 chr1 108362593 108614036 - 0 -NM_009782_Cacna1e chr1 156242220 156916799 - 0 -NM_009786_Cacybp chr1 162132500 162143003 - 0 -NM_009791_Aspm chr1 141351360 141393207 + 0 -NM_009794_Capn2 chr1 184394108 184479307 - 0 -NM_009803_Nr1i3 chr1 173122612 173149661 + 0 -NM_009812_Casp8 chr1 58818409 58904327 + 0 -NM_009813_Casq1 chr1 174140028 174150006 - 0 -NM_009826_Rb1cc1 chr1 6196277 6266709 + 0 -NM_009843_Ctla4 chr1 60943864 61098205 + 0 -NM_009872_Cdk5r2 chr1 74901511 74904288 + 0 -NM_009909_Il8rb chr1 74200075 74207820 + 0 -NM_009911_Cxcr4 chr1 130436268 130609324 - 0 -NM_009918_Cnga3 chr1 37275192 37321882 + 0 -NM_009930_Col3a1 chr1 45368295 45413500 + 0 -NM_009938_Copa chr1 174012565 174052450 + 0 -NM_010016_Cd55 chr1 132326379 132359520 - 0 -NM_010043_Des chr1 75356887 75365134 + 0 -NM_010045_Darc chr1 175234342 175263520 - 0 -NM_010094_Lefty1 chr1 182865132 182868532 + 0 -NM_010098_Opn3 chr1 177592560 177622774 - 0 -NM_010133_En1 chr1 122494080 122540975 + 0 -NM_010135_Enah chr1 183776371 183949877 - 0 -NM_010145_Ephx1 chr1 182919689 182951015 - 0 -NM_010164_Eya1 chr1 14117632 14318907 - 0 -NM_010177_Fasl chr1 163710820 163718844 - 0 -NM_010184_Fcer1a chr1 175148098 175157377 - 0 -NM_010185_Fcer1g chr1 173159708 173164476 - 0 -NM_010188_Fcgr3 chr1 172916162 173015807 - 0 -NM_010209_Fh1 chr1 177427308 177555746 - 0 -NM_010212_Fhl2 chr1 43179941 43255166 - 0 -NM_010231_Fmo1 chr1 164744557 164796721 - 0 -NM_010233_Fn1 chr1 71632113 71736637 - 0 -NM_010262_Gbx2 chr1 91824531 91831059 - 0 -NM_010267_Gdap1 chr1 17135463 17385513 + 0 -NM_010341_Nmur1 chr1 88282479 88297441 - 0 -NM_010472_Agfg1 chr1 82836048 82918151 + 0 -NM_010476_Hsd17b7 chr1 171879671 171899542 - 0 -NM_010483_Htr5b chr1 123406263 123425032 - 0 -NM_010500_Ier5 chr1 156943491 156946949 - 0 -NM_010518_Igfbp5 chr1 72904507 72921468 - 0 -NM_010544_Ihh chr1 74991633 75093213 - 0 -NM_010548_Il10 chr1 132916424 132921547 + 0 -NM_010552_Il17a chr1 20660053 20766059 + 0 -NM_010553_Il18rap chr1 40572207 40606867 + 0 -NM_010555_Il1r2 chr1 40130058 40182052 + 0 -NM_010564_Inha chr1 75503647 75506924 + 0 -NM_010566_Inpp5d chr1 89504177 89645401 + 0 -NM_010570_Irs1 chr1 82229682 82233665 + 0 -NM_010570_Irs1 chr1 82229686 82300552 - 0 -NM_010584_Itln1 chr1 173448254 173495879 - 0 -NM_010600_Kcnh1 chr1 194014507 194368391 + 0 -NM_010607_Kcnk2 chr1 191031813 191229415 - 0 -NM_010629_Kifap3 chr1 165671988 165847216 + 0 -NM_010633_Uhmk1 chr1 172123558 172145524 - 0 -NM_010678_Aff3 chr1 38232856 38782360 - 0 -NM_010683_Lamc1 chr1 155065803 155179906 - 0 -NM_010712_Lhx4 chr1 157520057 157598794 - 0 -NM_010732_Lrrn2 chr1 134776870 134865321 + 0 -NM_010766_Marco chr1 122261022 122466383 - 0 -NM_010778_Cd46 chr1 196861976 196919007 - 0 -NM_010827_Msc chr1 14520272 14746075 - 0 -NM_010834_Mstn chr1 53118495 53124923 + 0 -NM_010863_Myo1b chr1 51806622 51973696 - 0 -NM_010865_Myoc chr1 164569268 164581467 + 0 -NM_010879_Nck2 chr1 43501442 43627345 + 0 -NM_010880_Ncl chr1 88241155 88255995 - 0 -NM_010892_Nek2 chr1 193645343 193656921 + 0 -NM_010916_Nhlh1 chr1 173982425 173987707 - 0 -NM_010933_Nppc chr1 88512597 88567147 - 0 -NM_011011_Oprk1 chr1 5578025 5596202 + 0 -NM_011063_Pea15a chr1 174126043 174136915 - 0 -NM_011066_Per2 chr1 93312559 93386413 - 0 -NM_011070_Pfdn2 chr1 173275115 173289384 + 0 -NM_011082_Pigr chr1 132723238 132748826 + 0 -NM_011086_Pikfyve chr1 65225807 65332228 + 0 -NM_011111_Serpinb2 chr1 109407675 109422169 + 0 -NM_011198_Ptgs2 chr1 151947054 152026155 + 0 -NM_011206_Ptpn18 chr1 34516613 34532568 + 0 -NM_011267_Rgs16 chr1 155574693 155592596 + 0 -NM_011273_Xpr1 chr1 157103002 157264554 - 0 -NM_011277_Rnf2 chr1 153305192 153359013 - 0 -NM_011283_Rp1 chr1 3989638 4469288 - 0 -NM_011318_Apcs chr1 174824092 174855560 - 0 -NM_011345_Sele chr1 165978323 165988607 + 0 -NM_011346_Sell chr1 165992132 166007817 + 0 -NM_011347_Selp chr1 166045416 166080154 + 0 -NM_011439_Sox13 chr1 135278853 135384763 - 0 -NM_011441_Sox17 chr1 4481009 4487839 - 0 -NM_011459_Serpinb8 chr1 109486542 109586251 + 0 -NM_011465_Spna1 chr1 176102906 176178561 + 0 -NM_011487_Stat4 chr1 52036485 52164030 + 0 -NM_011494_Stk16 chr1 75207414 75212181 + 0 -NM_011541_Tcea1 chr1 4847584 4889703 + 0 -NM_011590_Timm17a chr1 137197272 137210335 - 0 -NM_011633_Traf5 chr1 193821096 193916369 - 0 -NM_011650_Tsn chr1 120194658 120208016 - 0 -NM_011729_Ercc5 chr1 44204270 44256568 + 0 -NM_011770_Ikzf2 chr1 69574124 69733875 - 0 -NM_011780_Adam23 chr1 63482194 63639230 + 0 -NM_011780_Adam23 chr1 63640970 63642850 + 0 -NM_011785_Akt3 chr1 178940936 179188314 - 0 -NM_011794_Bpnt1 chr1 187156058 187181696 + 0 -NM_011796_Capn10 chr1 94830953 94844518 + 0 -NM_011800_Cdh20 chr1 106665116 106892058 + 0 -NM_011804_Creg1 chr1 167693878 167710825 + 0 -NM_011811_Farsb chr1 78414533 78506689 - 0 -NM_011825_Grem2 chr1 176763926 176859770 - 0 -NM_011880_Rgs7 chr1 176989221 177422985 - 0 -NM_011882_Rnasel chr1 155596576 155619417 + 0 -NM_011931_Rfwd2 chr1 161159948 161307408 + 0 -NM_011935_Esrrg chr1 189432683 190062059 + 0 -NM_012009_Sh2d1b1 chr1 172162900 172220030 + 0 -NM_012012_Exo1 chr1 177810732 177841721 + 0 -NM_012049_Nit1 chr1 173270709 173276021 - 0 -NM_012058_Srp9 chr1 183988019 184062514 + 0 -NM_013474_Apoa2 chr1 173151908 173156502 + 0 -NM_013489_Cd84 chr1 173769848 173820852 + 0 -NM_013499_Cr1l chr1 196924298 196957754 - 0 -NM_013612_Slc11a1 chr1 74421758 74433050 + 0 -NM_013626_Pam chr1 99691711 100053468 - 0 -NM_013673_Sp100 chr1 84943347 87618694 + 0 -NM_013715_Cops5 chr1 10014683 10028315 - 0 -NM_013729_Mixl1 chr1 182623184 182634680 - 0 -NM_013730_Slamf1 chr1 173682982 173731471 + 0 -NM_013750_Phlda3 chr1 137662671 137665710 + 0 -NM_013784_Pign chr1 107385512 107560244 - 0 -NM_013835_Trove2 chr1 145597816 145624178 - 0 -NM_013862_Rabgap1l chr1 162149308 162739582 - 0 -NM_013919_Usp21 chr1 173212080 173218102 - 0 -NM_015750_Neu2 chr1 89348720 89494397 + 0 -NM_015780_Cfhr1 chr1 141443639 141456806 - 0 -NM_015811_Rgs1 chr1 146060709 146118313 - 0 -NM_015818_Hs6st1 chr1 36125255 36163289 + 0 -NM_016696_Gpc1 chr1 94728253 94757346 + 0 -NM_016702_Agxt chr1 95031777 95041991 + 0 -NM_016716_Cul3 chr1 80261498 80323399 - 0 -NM_016717_Scly chr1 93192544 93217635 + 0 -NM_016749_Mybph chr1 136090025 136097809 + 0 -NM_016778_Bok chr1 95579016 95592340 + 0 -NM_016796_Vamp4 chr1 164500371 164532593 + 0 -NM_016805_Hnrnpu chr1 180251245 180298730 - 0 -NM_016846_Rgl1 chr1 154357421 154613475 - 0 -NM_016851_Irf6 chr1 194979326 194998230 + 0 -NM_016894_Ramp1 chr1 93076419 93120251 + 0 -NM_016894_Ramp1 chr1 93120257 93121772 + 0 -NM_016916_Blcap chr1 46068602 46087314 - 0 -NM_016917_Slc40a1 chr1 45964925 45999090 - 0 -NM_016923_Ly96 chr1 16678152 16699618 + 0 -NM_016928_Tlr5 chr1 184884929 184903333 + 0 -NM_016960_Ccl20 chr1 83112527 83138624 + 0 -NM_017480_Icos chr1 61034747 61057162 + 0 -NM_018729_Cd244 chr1 173481630 173515439 + 0 -NM_018750_Rassf5 chr1 133072991 133144761 - 0 -NM_018775_Tbc1d8 chr1 39428350 39544345 - 0 -NM_018796_Eef1b2 chr1 63221360 63227060 + 0 -NM_018817_Smarcal1 chr1 72629842 72679806 + 0 -NM_018868_Nop58 chr1 59741819 59769026 + 0 -NM_018872_Tmem131 chr1 36841788 37000491 - 0 -NM_018881_Fmo2 chr1 164804452 164828875 - 0 -NM_019432_Tmem37 chr1 121962801 121979194 - 0 -NM_019445_Fmn2 chr1 176431685 176752860 + 0 -NM_019479_Hes6 chr1 93308097 93310595 - 0 -NM_019484_Refbp2 chr1 173433397 173434881 + 0 -NM_019562_Uchl5 chr1 145623774 145654586 + 0 -NM_019570_Rev1 chr1 38109638 38186507 - 0 -NM_019645_Pkp1 chr1 137767972 137815881 - 0 -NM_019685_Ruvbl1 chr1 141824644 141826247 - 0 -NM_019759_Dpt chr1 166726785 166754377 + 0 -NM_019777_Ikbke chr1 133151052 133176163 - 0 -NM_019790_Tmeff2 chr1 50957501 51282275 + 0 -NM_019933_Ptpn4 chr1 121556050 121771541 - 0 -NM_019993_Aldh9a1 chr1 169280142 169298663 + 0 -NM_020025_B3galt2 chr1 145487786 145497516 + 0 -NM_020579_B4galt3 chr1 173199650 173207025 + 0 -NM_020588_Tmem183a chr1 136242675 136258707 - 0 -NM_020604_Jph1 chr1 16837549 17087942 - 0 -NM_021285_Myl1 chr1 66948125 66992032 - 0 -NM_021295_Lancl1 chr1 67004053 67085447 - 0 -NM_021306_Ecel1 chr1 89039384 89053076 - 0 -NM_021312_Wdr12 chr1 60099363 60155552 - 0 -NM_021313_Rnf25 chr1 74640329 74648026 - 0 -NM_021342_Kcne4 chr1 78791793 78816579 + 0 -NM_021350_Chml chr1 177615948 177618649 - 0 -NM_021374_Rgs20 chr1 4899617 5060346 - 0 -NM_021380_Il20 chr1 132803344 132808275 - 0 -NM_021383_Rqcd1 chr1 74542393 74577404 + 0 -NM_021400_Prg4 chr1 152296956 152333784 - 0 -NM_021408_Ush2a chr1 190085902 190292167 + 0 -NM_021421_Angel2 chr1 192748297 192770827 + 0 -NM_021433_Stx6 chr1 157005819 157054716 + 0 -NM_021467_Tnni1 chr1 137676021 137713725 + 0 -NM_021511_Rrs1 chr1 9535513 9537532 + 0 -NM_021537_Stk25 chr1 95517348 95555233 - 0 -NM_021541_Cryba2 chr1 74936508 74939802 - 0 -NM_021600_Chrnd chr1 89087192 89096645 + 0 -NM_021605_Nek7 chr1 140379472 140516775 - 0 -NM_021607_Ncstn chr1 173996154 174012927 - 0 -NM_021610_Gpa33 chr1 168060559 168118074 + 0 -NM_022018_Fam129a chr1 153370940 153589282 + 0 -NM_022019_Dusp10 chr1 185755009 185899515 + 0 -NM_022312_Tnr chr1 161327058 161857057 + 0 -NM_022320_Gpr35 chr1 94683531 94882968 + 0 -NM_022327_Ralb chr1 121363651 121401351 - 0 -NM_022329_Ifrg15 chr1 157883344 157900866 + 0 -NM_022417_Itm2c chr1 87780787 87838221 + 0 -NM_022563_Ddr2 chr1 171907607 172040752 - 0 -NM_022721_Fzd5 chr1 64777130 64826549 - 0 -NM_022881_Rgs18 chr1 146599793 146755382 - 0 -NM_022988_Nif3l1 chr1 58501750 58538650 + 0 -NM_023041_Pex19 chr1 174056859 174067189 + 0 -NM_023141_Tor3a chr1 158583760 158604477 - 0 -NM_023173_Dusp12 chr1 172803629 172815650 - 0 -NM_023200_Ppp1r7 chr1 95239431 95266345 + 0 -NM_023284_Nuf2 chr1 171386224 171461676 - 0 -NM_023314_Eif4e2 chr1 89110486 89145136 + 0 -NM_023341_Cabc1 chr1 182095369 182129713 - 0 -NM_023343_Ilkap chr1 93270445 93290447 - 0 -NM_023434_Tox4 chr1 16757104 16760219 - 0 -NM_023514_Mrps9 chr1 42760822 42962528 + 0 -NM_023523_Pecr chr1 72281105 72330878 - 0 -NM_023617_Aox3 chr1 58169980 58259027 + 0 -NM_023631_Aox4 chr1 58267261 58325441 + 0 -NM_023645_Kdelc1 chr1 44143458 44177102 - 0 -NM_023727_Rd3 chr1 193784705 193812153 + 0 -NM_023732_Abcb6 chr1 75168223 75177000 - 0 -NM_023755_Tcfcp2l1 chr1 120524515 120655075 + 0 -NM_023884_Ralgps2 chr1 158734300 158969600 - 0 -NM_024197_Ndufa10 chr1 94121208 94393553 - 0 -NM_024264_Cyp27a1 chr1 74759770 74786412 + 0 -NM_024282_Pppde1 chr1 180117558 180197483 + 0 -NM_024283_1500015O10Rik chr1 43787414 43799399 + 0 -NM_025283_Mobkl3 chr1 55187734 55211736 + 0 -NM_025300_Mrpl15 chr1 4763290 4798011 - 0 -NM_025303_Stau2 chr1 16218775 16510193 - 0 -NM_025321_Sdhc chr1 173057297 173080736 - 0 -NM_025386_Fbxo36 chr1 84835492 84897059 + 0 -NM_025388_Ufc1 chr1 173218698 173225135 - 0 -NM_025424_Nenf chr1 193130454 193141997 - 0 -NM_025439_Tmem9 chr1 137879942 137931919 + 0 -NM_025453_Tm4sf20 chr1 82749860 82765031 - 0 -NM_025454_Ing5 chr1 95700534 95719794 + 0 -NM_025470_1810030J14Rik chr1 176260650 176349219 + 0 -NM_025474_Mrps14 chr1 162082365 162131317 + 0 -NM_025505_Blzf1 chr1 166219931 166237615 - 0 -NM_025557_Pcp4l1 chr1 173103394 173126370 - 0 -NM_025569_Mgst3 chr1 169302037 169323952 - 0 -NM_025596_Prelid1 chr1 63410974 63469460 - 0 -NM_025597_Ndufb3 chr1 58631453 58653239 + 0 -NM_025677_Tsen15 chr1 154217920 154233812 - 0 -NM_025683_Rpe chr1 66747223 66839854 + 0 -NM_025746_4933415F23Rik chr1 23107346 23263222 - 0 -NM_025773_Ube2w chr1 16530881 16609419 - 0 -NM_025784_Bcs1l chr1 74634010 74639375 + 0 -NM_025819_1200016B10Rik chr1 153214763 153304502 - 0 -NM_025864_Tmem206 chr1 193149566 193176819 + 0 -NM_025867_Serpinb11 chr1 109246610 109277052 + 0 -NM_025920_Thap4 chr1 95602021 95651542 - 0 -NM_025964_Fam119a chr1 64653048 64670990 - 0 -NM_026024_Ube2t chr1 136857731 136870739 + 0 -NM_026041_Rrp15 chr1 188544857 188573732 - 0 -NM_026078_Pigc chr1 163860747 163957217 + 0 -NM_026123_Unc50 chr1 37486671 37504876 + 0 -NM_026171_Nvl chr1 183008557 183074318 - 0 -NM_026187_Ankzf1 chr1 75188977 75192143 + 0 -NM_026187_Ankzf1 chr1 75192524 75195962 + 0 -NM_026195_Atic chr1 71584010 71626205 + 0 -NM_026234_Pigm chr1 174306609 174314210 + 0 -NM_026241_Ankrd39 chr1 36594353 36604077 - 0 -NM_026250_Zh2c2 chr1 99658035 99706130 + 0 -NM_026321_Fam174a chr1 97174825 97346168 + 0 -NM_026367_Gpatch2 chr1 189010707 189180483 + 0 -NM_026369_Arpc5 chr1 154613024 154638792 + 0 -NM_026375_Ahctf1 chr1 181675025 181733948 - 0 -NM_026380_Rgs8 chr1 155468581 155563679 + 0 -NM_026390_Ubxn4 chr1 130140557 130175951 + 0 -NM_026430_Uxs1 chr1 43804890 43884625 - 0 -NM_026454_Ube2f chr1 93146888 93187187 + 0 -NM_026456_Tceb1 chr1 16603307 16655630 - 0 -NM_026472_Mki67ip chr1 120218436 120230401 + 0 -NM_026493_Cspp1 chr1 10028093 10126849 + 0 -NM_026500_Ddx59 chr1 138242798 138336799 + 0 -NM_026503_1110058L19Rik chr1 24002785 24017210 - 0 -NM_026626_Efcab2 chr1 180335927 180414624 + 0 -NM_026680_Golt1a chr1 135206322 135226478 + 0 -NM_026713_Mogat1 chr1 78496730 78564215 + 0 -NM_026719_Lmbrd1 chr1 24593456 24847969 + 0 -NM_026719_Lmbrd1 chr1 24820582 24823143 + 0 -NM_026725_Dusp23 chr1 174560902 174563119 - 0 -NM_026796_Smyd2 chr1 191704373 191746222 - 0 -NM_026823_Arl8a chr1 137043216 137053347 + 0 -NM_026846_Zfand2b chr1 75165237 75168196 + 0 -NM_026850_Pdcl3 chr1 39044622 39054081 + 0 -NM_026913_Mitd1 chr1 37931656 37947242 - 0 -NM_026977_1810031K17Rik chr1 75131500 75139270 - 0 -NM_027098_Mrpl30 chr1 37947313 37959167 + 0 -NM_027154_Tmbim1 chr1 74334823 74352176 - 0 -NM_027159_Ccdc115 chr1 34491854 34496517 - 0 -NM_027188_Smyd3 chr1 180885172 181448168 - 0 -NM_027300_Spata3 chr1 87913403 87926533 + 0 -NM_027351_Ppil3 chr1 58486110 58502330 - 0 -NM_027357_Psmd1 chr1 87958636 88174849 + 0 -NM_027407_Ica1l chr1 60039354 60099956 - 0 -NM_027415_Tmem70 chr1 16610621 16668358 + 0 -NM_027430_Brp44 chr1 167390752 167411345 + 0 -NM_027534_Kdsr chr1 108617007 108656357 - 0 -NM_027548_Serpinb7 chr1 109296172 109349266 + 0 -NM_027551_Klhl30 chr1 93244259 93259068 + 0 -NM_027637_4931428L18Rik chr1 31197921 31279501 - 0 -NM_027661_Hsfy2 chr1 56668158 56822175 - 0 -NM_027677_Gpr39 chr1 127573518 127795359 + 0 -NM_027678_Zranb3 chr1 129846941 130025531 - 0 -NM_027725_Wdr69 chr1 83156310 83207145 + 0 -NM_027884_Tns1 chr1 73956820 74144891 - 0 -NM_027886_Stk11ip chr1 75518100 75533910 + 0 -NM_027893_Pvrl4 chr1 173292993 173318729 + 0 -NM_027921_Slc16a14 chr1 84902046 84931841 - 0 -NM_027971_Serpinb12 chr1 108831026 108853655 + 0 -NM_027979_Chit1 chr1 136007829 136048117 + 0 -NM_028057_Cyb5r1 chr1 136302358 136308302 + 0 -NM_028091_Osgepl1 chr1 53370488 53383184 + 0 -NM_028135_Tmem163 chr1 129382910 129574703 - 0 -NM_028173_Tram1 chr1 13554779 13579965 - 0 -NM_028250_Acbd6 chr1 157358146 157536633 + 0 -NM_028320_Adipor1 chr1 136311830 136329944 + 0 -NM_028333_Angptl1 chr1 158769061 158791209 + 0 -NM_028399_Ccnt2 chr1 129670253 129704638 + 0 -NM_028408_Cnih3 chr1 183282759 183419790 + 0 -NM_028450_Gulp1 chr1 44608366 44896390 + 0 -NM_028534_Smap1 chr1 23833022 23929292 - 0 -NM_028696_Obfc2a chr1 51417024 51550602 - 0 -NM_028713_Rftn2 chr1 55227030 55283748 - 0 -NM_028717_Als2 chr1 59219131 59294111 - 0 -NM_028749_Npl chr1 155350145 155424001 - 0 -NM_028776_Scyl3 chr1 165859251 165885242 + 0 -NM_028776_Scyl3 chr1 165876143 165924907 - 0 -NM_028778_Nuak2 chr1 134212715 134241254 + 0 -NM_028787_Slc35f5 chr1 127332249 127554856 + 0 -NM_028817_Acsl3 chr1 78654388 78743434 + 0 -NM_028829_Paqr8 chr1 20811519 20929711 + 0 -NM_028848_Spata17 chr1 188868366 189039831 - 0 -NM_028889_Efhd1 chr1 89160561 89207413 + 0 -NM_028942_Slco6c1 chr1 98899133 99024880 - 0 -NM_029025_Tmem81 chr1 134402623 134405216 + 0 -NM_029084_Slamf8 chr1 174510275 174520700 - 0 -NM_029115_4930455F23Rik chr1 166205721 166217973 + 0 -NM_029160_Spag16 chr1 69873526 70771706 + 0 -NM_029269_Spp2 chr1 90303568 90373213 + 0 -NM_029398_Tmem14a chr1 21143538 21220248 + 0 -NM_029409_Mff chr1 82721393 82748958 + 0 -NM_029612_Slamf9 chr1 174392516 174408706 + 0 -NM_029696_Mdh1b chr1 63745401 63776894 - 0 -NM_029756_Sdccag8 chr1 178743478 178953256 + 0 -NM_029766_Dtl chr1 193272523 193399423 - 0 -NM_029846_Atg16l1 chr1 89652465 89697344 + 0 -NM_029888_Zfp142 chr1 74612492 74634794 - 0 -NM_030013_Cyp20a1 chr1 60400175 60444904 + 0 -NM_030025_Ccdc150 chr1 54251865 54451794 + 0 -NM_030060_Batf3 chr1 192921746 192944913 + 0 -NM_030131_Cnih4 chr1 183074401 183099213 + 0 -NM_030211_Kctd18 chr1 58007830 58075790 - 0 -NM_030245_Tada1l chr1 168309248 168323752 + 0 -NM_030266_Inpp4a chr1 37356703 37476203 + 0 -NM_030556_Slc19a3 chr1 83001155 83083196 - 0 -NM_030676_Nr5a2 chr1 138739149 138950879 - 0 -NM_030710_Slamf6 chr1 173847613 173932462 + 0 -NM_030724_Uck2 chr1 169106790 169215431 - 0 -NM_031164_F13b chr1 141398326 141420329 + 0 -NM_031179_Sf3b1 chr1 55042016 55084369 - 0 -NM_031189_Myog chr1 136186558 136189125 + 0 -NM_031192_Ren1 chr1 135246578 135256895 + 0 -NM_031402_Crispld1 chr1 17717123 17756425 + 0 -NM_032005_Tbx19 chr1 167056323 167090894 - 0 -NM_033077_D1Pas1 chr1 188791295 188934742 + 0 -NM_033509_Vangl2 chr1 173931096 173977129 - 0 -NM_033563_Klf7 chr1 64049920 64169179 - 0 -NM_033570_Cnnm4 chr1 36528452 36565609 + 0 -NM_033608_Igsf9 chr1 174411686 174429005 + 0 -NM_033652_Lmx1a chr1 169579767 169778872 + 0 -NM_053015_Mlph chr1 92811657 92847814 + 0 -NM_053095_Il24 chr1 132778072 132784021 - 0 -NM_053106_Lmod1 chr1 137221395 137264642 + 0 -NM_053107_Gpr45 chr1 43009719 43092301 + 0 -NM_053191_Pi15 chr1 17591992 17621000 + 0 -NM_053199_Cadm3 chr1 175264723 175362523 - 0 -NM_053257_Rpl31 chr1 39421000 39429094 + 0 -NM_053270_Rims1 chr1 22275987 22813178 - 0 -NM_054076_Optc chr1 135787973 135805299 - 0 -NM_054077_Prelp chr1 135806855 135865173 - 0 -NM_054087_Slc19a2 chr1 166178694 166196022 + 0 -NM_054102_Ivns1abp chr1 153196503 153212127 + 0 -NM_080419_Igsf8 chr1 174191772 174249967 + 0 -NM_080844_Serpinc1 chr1 162908738 162946004 + 0 -NM_080850_Pask chr1 95205357 95240039 - 0 -NM_130456_Nphs2 chr1 158233397 158258162 + 0 -NM_130890_Capn8 chr1 184489366 184629001 + 0 -NM_133193_Il1rl2 chr1 40381454 40447345 + 0 -NM_133220_Sgk3 chr1 9787936 9890911 + 0 -NM_133225_Acbd3 chr1 182654006 182684317 + 0 -NM_133235_Khdrbs2 chr1 32113056 32771277 + 0 -NM_133239_Crb1 chr1 141093643 141296750 - 0 -NM_133252_Tram2 chr1 20984161 21069306 - 0 -NM_133358_Zfp617 chr1 87909957 87912999 - 0 -NM_133664_Lad1 chr1 137715163 137730085 + 0 -NM_133684_Mosc2 chr1 186636947 186687141 - 0 -NM_133705_Pycr2 chr1 182834431 182850616 + 0 -NM_133728_Asnsd1 chr1 53382361 53409576 - 0 -NM_133748_Insig2 chr1 123200933 123229157 - 0 -NM_133780_Tpr chr1 152239968 152298193 + 0 -NM_133781_Cab39 chr1 87687678 87748148 + 0 -NM_133805_Cops8 chr1 92499556 92564446 + 0 -NM_133806_Uap1 chr1 172007106 172105098 - 0 -NM_133808_Hdlbp chr1 95302520 95375513 - 0 -NM_133809_Kmo chr1 177550532 177592237 + 0 -NM_133810_Stk17b chr1 53812356 53857070 - 0 -NM_133815_Lbr chr1 183737722 183773157 - 0 -NM_133816_Sh3bp4 chr1 90966984 91051778 + 0 -NM_133817_Zfp451 chr1 33817052 33871530 - 0 -NM_133819_Ppp1r15b chr1 135027595 135036355 + 0 -NM_133826_Atp6v1h chr1 5060109 5173662 + 0 -NM_133828_Creb1 chr1 64579391 64645546 + 0 -NM_133828_Creb1 chr1 64646684 64649524 + 0 -NM_133829_Mfsd6 chr1 52702101 52784383 - 0 -NM_133832_Rdh10 chr1 16095419 16123815 + 0 -NM_133975_Trip12 chr1 84717781 84836834 - 0 -NM_134252_Trpm8 chr1 90181363 90285482 + 0 -NM_134438_Gpr37l1 chr1 137054243 137069087 - 0 -NM_134448_Dst chr1 33965107 34411632 + 0 -NM_138314_Nme7 chr1 166237503 166369483 + 0 -NM_138741_Sdpr chr1 51345970 51359791 + 0 -NM_139146_Satb2 chr1 56850830 57044309 - 0 -NM_139150_Carf chr1 60155057 60208366 + 0 -NM_139152_Asb18 chr1 91849253 91911152 - 0 -NM_139270_Pth2r chr1 65328648 65436194 + 0 -NM_144530_Zc3h11a chr1 135516445 135557956 - 0 -NM_144539_Slamf7 chr1 173562534 173583396 - 0 -NM_144558_Bivm chr1 44175822 44201615 + 0 -NM_144559_Fcgr4 chr1 172925278 172974678 + 0 -NM_144761_Crygb chr1 65126809 65127141 - 0 -NM_144791_Tor1aip1 chr1 157851734 157889804 - 0 -NM_144794_Tmem63a chr1 182872430 182919700 + 0 -NM_144796_Susd4 chr1 184694011 184850523 + 0 -NM_144810_Klhdc8a chr1 134182914 134204342 + 0 -NM_144814_Rcor3 chr1 193910981 193962565 - 0 -NM_144817_Camk1g chr1 195172540 195216632 - 0 -NM_144875_Rab7l1 chr1 133763813 133782396 + 0 -NM_144877_Mettl13 chr1 164462268 164478659 - 0 -NM_144878_Fmo4 chr1 164675648 164744002 - 0 -NM_144879_Vash2 chr1 192771545 192803413 - 0 -NM_144880_Ppp2r5a chr1 193175865 193290728 - 0 -NM_144881_Hhat chr1 194320603 194649833 - 0 -NM_144882_2810022L02Rik chr1 57831026 58005952 + 0 -NM_144953_1700019D03Rik chr1 52981207 53077002 - 0 -NM_144960_Fcamr chr1 132697479 132711317 + 0 -NM_145100_Lypd1 chr1 127768620 127809650 - 0 -NM_145128_Mgat5 chr1 129101583 129384133 + 0 -NM_145141_Fcrla chr1 172847725 172857714 - 0 -NM_145142_Chst10 chr1 38920721 38955057 - 0 -NM_145143_Mpp4 chr1 59177791 59218762 - 0 -NM_145222_B3gnt7 chr1 88199427 88203870 + 0 -NM_145381_Lactb2 chr1 13604244 13650616 - 0 -NM_145392_Bag2 chr1 33802345 33814648 - 0 -NM_145413_Fam20b chr1 158608676 158649180 - 0 -NM_145415_AA408296 chr1 194918802 194956446 - 0 -NM_145417_Rnpep chr1 137159304 137180985 - 0 -NM_145506_Epb4.1l5 chr1 121437741 121545557 - 0 -NM_145508_Dyrk3 chr1 133018921 133034897 - 0 -NM_145509_5430435G22Rik chr1 133585272 133610099 + 0 -NM_145510_Rabif chr1 136391105 136405512 + 0 -NM_145511_BC003331 chr1 152183263 152240229 - 0 -NM_145512_Sft2d2 chr1 167104119 167124549 - 0 -NM_145513_Tiprl chr1 167133855 167183116 - 0 -NM_145514_Wdr26 chr1 183100306 183150525 - 0 -NM_145515_Mark1 chr1 186720345 186823408 - 0 -NM_145516_Plekhb2 chr1 34906787 34936422 + 0 -NM_145517_Ormdl1 chr1 53353438 53367153 + 0 -NM_145518_Ndufs1 chr1 63190187 63223454 - 0 -NM_145519_Farp2 chr1 95408676 95518914 + 0 -NM_145624_Zfp709 chr1 87911157 87911749 - 0 -NM_145692_Lrrc67 chr1 9943781 9999420 - 0 -NM_145856_Il17f chr1 20767237 20776566 - 0 -NM_145977_Slc45a3 chr1 133859512 133879541 + 0 -NM_145991_Cdc73 chr1 145274292 145549936 - 0 -NM_145996_Arid5a chr1 36359349 36380874 + 0 -NM_146103_Tmem185b chr1 121396063 121425550 + 0 -NM_146106_Lyplal1 chr1 187911630 187941208 - 0 -NM_146107_Actr1b chr1 36754975 36766847 - 0 -NM_146108_Hibch chr1 52899113 52977830 + 0 -NM_146110_Aamp chr1 74326421 74331613 - 0 -NM_146112_Gigyf2 chr1 89223593 89347370 + 0 -NM_146250_Gpr1 chr1 63229165 63309823 - 0 -NM_146277_Olfr1412 chr1 94484843 94486082 + 0 -NM_146305_Olfr420 chr1 176088784 176089871 + 0 -NM_146490_Olfr1411 chr1 94493008 94494065 + 0 -NM_146491_Olfr1410 chr1 94504416 94505384 + 0 -NM_146715_Olfr419 chr1 176180115 176200418 - 0 -NM_146716_Olfr432 chr1 175977437 175981444 + 0 -NM_146717_Olfr433 chr1 175971174 175973629 + 0 -NM_146718_Olfr430 chr1 175999350 176000384 + 0 -NM_146720_Olfr421 chr1 176072364 176082596 + 0 -NM_146721_Olfr424 chr1 176057388 176067824 + 0 -NM_146722_Olfr429 chr1 176019173 176020111 + 0 -NM_146761_Olfr414 chr1 176360513 176361670 + 0 -NM_146764_Olfr1408 chr1 175060414 175083388 - 0 -NM_146881_Olfr1404 chr1 175145784 175146725 + 0 -NM_147037_Olfr1413 chr1 94469750 94470721 + 0 -NM_148937_Plcd4 chr1 74589462 74614368 + 0 -NM_152895_Kdm5b chr1 136455975 136529487 + 0 -NM_152915_Dner chr1 84366415 84706993 - 0 -NM_153064_Ndufs2 chr1 173164989 173180188 - 0 -NM_153088_Ctdsp1 chr1 74438065 74443852 + 0 -NM_153111_Fev chr1 74915158 74932371 - 0 -NM_153114_Otos chr1 94540797 94553072 - 0 -NM_153137_Traf3ip3 chr1 195001656 195027877 - 0 -NM_153154_Tcfap2d chr1 19027377 19157044 + 0 -NM_153171_Rgs13 chr1 145985803 146024550 - 0 -NM_153179_Pkhd1 chr1 20040166 20661582 - 0 -NM_153408_Neurl3 chr1 36321504 36355139 - 0 -NM_153502_Ankrd23 chr1 36587038 36593708 - 0 -NM_153530_Dis3l2 chr1 88570607 88946671 + 0 -NM_153539_Fam5c chr1 148341910 148749599 + 0 -NM_153555_Wdr42a chr1 174078166 174127554 + 0 -NM_153556_Pms1 chr1 53245508 53353841 - 0 -NM_153601_Lgsn chr1 31221394 31261688 + 0 -NM_153744_Prkag3 chr1 74785516 74825109 - 0 -NM_153774_Ipo9 chr1 137278207 137330146 - 0 -NM_170597_Creg2 chr1 39677083 39708307 - 0 -NM_170755_Fam134a chr1 75137484 75144869 + 0 -NM_172054_Txndc9 chr1 38041434 38054101 - 0 -NM_172124_B3gat2 chr1 23755411 23855977 + 0 -NM_172294_Sulf1 chr1 12708560 12851249 + 0 -NM_172406_Trak2 chr1 58955979 59031177 - 0 -NM_172422_Fastkd2 chr1 63777134 63803028 + 0 -NM_172430_Sphkap chr1 83207585 83404745 - 0 -NM_172463_Sned1 chr1 95132418 95197642 + 0 -NM_172484_E030049G20Rik chr1 127810213 128389504 - 0 -NM_172485_Thsd7b chr1 131169889 132172070 + 0 -NM_172499_Mfsd9 chr1 40828883 40921070 - 0 -NM_172510_Mfsd4 chr1 133919383 133964629 - 0 -NM_172513_Fam126b chr1 58575029 58643157 - 0 -NM_172516_Dstyk chr1 134314046 134363525 + 0 -NM_172517_Rbbp5 chr1 134368568 134402423 + 0 -NM_172643_Zbtb41 chr1 141318960 141349577 + 0 -NM_172644_Dars2 chr1 162970732 163001279 - 0 -NM_172647_F11r chr1 173365700 173394971 + 0 -NM_172648_Ifi205 chr1 175664572 175958593 - 0 -NM_172650_Kctd3 chr1 190794974 190831710 - 0 -NM_172652_4632411B12Rik chr1 36381585 36426026 - 0 -NM_172653_Slc39a10 chr1 46863572 46949677 - 0 -NM_172656_Stradb chr1 59012025 59052817 + 0 -NM_172841_Slco5a1 chr1 12857471 12982812 - 0 -NM_172843_Tor1aip2 chr1 157906541 157915942 + 0 -NM_172844_Fmo9 chr1 168589849 168611976 - 0 -NM_172845_Adamts4 chr1 173178880 173192383 + 0 -NM_172846_Dnahc14 chr1 183669052 183694102 + 0 -NM_172850_Ankmy1 chr1 94757771 94799473 - 0 -NM_172851_Cntnap5b chr1 101934704 102382815 + 0 -NM_172852_Serpinb13 chr1 108877561 108897772 + 0 -NM_172853_Cdh7 chr1 111718165 112036714 + 0 -NM_172974_Cops7b chr1 88478926 88503950 + 0 -NM_173029_Adcy10 chr1 167415324 167506904 + 0 -NM_173187_2310035C23Rik chr1 107560448 107651751 + 0 -NM_173378_Trp53bp2 chr1 184333536 184392728 + 0 -NM_173395_Fam132b chr1 93263007 93270794 + 0 -NM_173424_Zbtb37 chr1 162938038 162965197 - 0 -NM_173425_Fam124b chr1 80156958 80214611 - 0 -NM_173437_Nav1 chr1 137332309 137482282 - 0 -NM_173437_Nav1 chr1 137481360 137496527 + 0 -NM_173443_Vcpip1 chr1 9709587 9764569 - 0 -NM_173760_Hisppd1 chr1 99592475 99667685 - 0 -NM_173771_4933406M09Rik chr1 136282517 136287560 + 0 -NM_173772_Neu4 chr1 95917070 95928707 + 0 -NM_173865_Slc41a1 chr1 133724090 133745438 + 0 -NM_173868_St18 chr1 6477297 6885001 + 0 -NM_173870_Mgat4a chr1 37496234 37609425 - 0 -NM_174874_Atg4b chr1 95648097 95687167 + 0 -NM_174985_Gpbar1 chr1 74321873 74326272 + 0 -NM_175031_Stk36 chr1 74648039 74683468 + 0 -NM_175106_Tmem177 chr1 121793019 121809709 - 0 -NM_175118_Dusp28 chr1 94803563 94805012 + 0 -NM_175127_Fbxo28 chr1 184242976 184303818 - 0 -NM_175170_Pogk chr1 168314763 168391350 - 0 -NM_175200_Als2cr11 chr1 59053967 59151744 - 0 -NM_175210_Abca12 chr1 71207671 71501632 - 0 -NM_175236_Adhfe1 chr1 9538049 9570746 + 0 -NM_175259_Shisa4 chr1 137267654 137274885 - 0 -NM_175293_D630023F18Rik chr1 65151863 65176420 - 0 -NM_175294_Nucks1 chr1 133807079 133832888 + 0 -NM_175296_Mael chr1 168115771 168178081 - 0 -NM_175370_Als2cr12 chr1 58714975 58752801 - 0 -NM_175382_2700049P18Rik chr1 133344141 133436449 + 0 -NM_175439_Mars2 chr1 55294084 55297625 + 0 -NM_175443_Etnk2 chr1 135260167 135276893 + 0 -NM_175460_Nmnat2 chr1 154802128 154966391 + 0 -NM_175461_Fam78b chr1 168898096 169021408 + 0 -NM_175564_Tmem169 chr1 72330953 72349677 + 0 -NM_175642_Bai3 chr1 25084207 25887514 - 0 -NM_175686_Prrx1 chr1 165175252 165245859 - 0 -NM_176916_Pld5 chr1 177892457 178205403 - 0 -NM_176972_Usp37 chr1 74482084 74590860 - 0 -NM_176980_Ankar chr1 72689581 72747143 - 0 -NM_177068_Olfml2b chr1 172569075 172612915 + 0 -NM_177084_Slc9a4 chr1 40636956 40687551 + 0 -NM_177129_Cntn2 chr1 134406005 134442705 - 0 -NM_177164_A830006F12Rik chr1 70772309 70929065 + 0 -NM_177173_A830018L16Rik chr1 11404178 11994163 + 0 -NM_177235_Bend6 chr1 33903283 33964764 - 0 -NM_177243_Slc26a9 chr1 133640599 133668075 + 0 -NM_177305_Arl4c chr1 90569702 90617572 - 0 -NM_177397_Atp6v1g3 chr1 140120875 140186039 + 0 -NM_177445_Dars chr1 130260284 130314013 - 0 -NM_177587_Aqp12 chr1 94886487 94908846 + 0 -NM_177604_AA986860 chr1 132628563 132644539 + 0 -NM_177643_Zfp281 chr1 138487073 138526617 + 0 -NM_177646_Dgkd chr1 89749836 89841946 + 0 -NM_177722_6030422M02Rik chr1 9898713 9932156 + 0 -NM_177723_Vsig8 chr1 174486069 174513273 + 0 -NM_177724_D230039L06Rik chr1 180426979 180686112 + 0 -NM_177756_Glt25d2 chr1 154223175 154357825 + 0 -NM_177757_Kif26b chr1 180720593 180862983 + 0 -NM_177781_Trpa1 chr1 14861962 14909072 - 0 -NM_177834_Cpa6 chr1 10314801 10710026 - 0 -NM_177838_Fam163a chr1 157923096 158135544 - 0 -NM_177839_Tnn chr1 161966935 162084477 - 0 -NM_178051_Mterfd2 chr1 95195779 95202630 - 0 -NM_178055_Dnajb2 chr1 75233016 75242264 + 0 -NM_178119_Agap1 chr1 91351421 91791845 + 0 -NM_178241_Il8ra chr1 74238380 74241205 - 0 -NM_178243_5830403L16Rik chr1 155697272 155747352 - 0 -NM_178244_Teddm1 chr1 155724147 155740188 + 0 -NM_178399_3110035E14Rik chr1 9591248 9617222 + 0 -NM_178405_Atp1a2 chr1 174201852 174233438 - 0 -NM_178593_Rcsd1 chr1 167572007 167639868 - 0 -NM_178598_Tagln2 chr1 174430123 174475991 + 0 -NM_178601_Imp4 chr1 34496377 34511555 + 0 -NM_178632_Ints7 chr1 193399085 193447550 + 0 -NM_178653_Sccpdh chr1 181598088 181617593 + 0 -NM_178690_Rab3gap1 chr1 129765355 129840723 + 0 -NM_178691_Yod1 chr1 132612680 132618643 + 0 -NM_178692_C130074G19Rik chr1 186695805 186707077 - 0 -NM_178775_Rps6kc1 chr1 192524091 192736016 - 0 -NM_178779_Rnf152 chr1 107176426 107253513 - 0 -NM_178874_Tmcc2 chr1 134252895 134288369 - 0 -NM_178883_Gorab chr1 165315039 165340946 - 0 -NM_178884_Obsl1 chr1 75482401 75503218 - 0 -NM_181405_Rnpepl1 chr1 94807467 94817954 + 0 -NM_181546_Syt14 chr1 194713536 194861959 - 0 -NM_181750_R3hdm1 chr1 129999892 130134312 + 0 -NM_181796_Gstp2 chr1 193897651 193905509 - 0 -NM_182716_Nfasc chr1 134445291 134638354 - 0 -NM_182930_Plekha6 chr1 135077806 135200008 + 0 -NM_183019_Arhgef4 chr1 34788954 34873560 + 0 -NM_183022_Accn4 chr1 75447063 75470207 + 0 -NM_183027_Ap1s3 chr1 79591820 79668545 - 0 -NM_183028_Pcmtd1 chr1 7079053 7163709 + 0 -NM_183124_Defb41 chr1 18241071 18350659 - 0 -NM_183355_Pbx1 chr1 170049495 170512777 - 0 -NM_183391_Tnfsf18 chr1 163373523 163524094 + 0 -NM_194333_Slc23a3 chr1 75120731 75130464 - 0 -NM_198006_6330578E17Rik chr1 37473934 37474944 - 0 -NM_198006_6330578E17Rik chr1 37477057 37486928 - 0 -NM_198028_Serpinb10 chr1 109425580 109445838 + 0 -NM_198127_Abi2 chr1 60466022 60537998 + 0 -NM_198247_Sertad4 chr1 194670313 194693726 - 0 -NM_198303_Eif5b chr1 38054627 38112414 + 0 -NM_198652_6430706D22Rik chr1 90158880 90174174 - 0 -NM_198653_Iars2 chr1 187109458 187153280 - 0 -NM_198654_Nsl1 chr1 192886918 192919389 + 0 -NM_198680_Serpinb3b chr1 109033488 109059720 - 0 -NM_198899_Ugcgl1 chr1 36196873 36301555 - 0 -NM_198934_Pou2f1 chr1 167804181 167932753 - 0 -NM_199007_Sgol2 chr1 58026657 58085164 + 0 -NM_199021_Dpp10 chr1 125044486 126749525 - 0 -NM_201363_Serpinb3c chr1 109088051 109198931 - 0 -NM_201376_Serpinb3d chr1 108974770 108980057 - 0 -NM_201641_Ugt1a10 chr1 89922380 90115570 + 0 -NM_206896_Olfr12 chr1 94516341 94538591 + 0 -NM_207031_Ano7 chr1 95270385 95302271 + 0 -NM_207137_Olfr417 chr1 176299050 176299979 + 0 -NM_207137_Olfr417 chr1 176321202 176322113 + 0 -NM_207158_Olfr427 chr1 176028781 176030538 + 0 -NM_207225_Hdac4 chr1 93755950 94103099 - 0 -NM_207228_Tsga10 chr1 37783457 37922148 - 0 -NM_207233_C1ql2 chr1 122196386 122239751 + 0 -NM_207281_4832428D23Rik chr1 44260915 44515719 - 0 -NM_207583_Fam5b chr1 160175402 160286644 - 0 -NM_207653_Cflar chr1 58768296 58813658 + 0 -NM_207653_Cflar chr1 58813703 58815725 + 0 -NM_213616_Atp2b4 chr1 135602265 135697538 - 0 -NR_002840_Gas5 chr1 162964758 162968663 + 0 -NR_002858_EG241041 chr1 21268965 21306401 - 0 -NR_002870_Dnm3os chr1 164119785 164155671 + 0 -NR_003623_EG277333 chr1 182251970 182262902 - 0 -NR_026896_4931440L10Rik chr1 136437533 136449760 - 0
--- a/make_test_data/mm9_canonical_genes.tsv Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,10 +0,0 @@ -mm9.kgXref.geneSymbol #mm9.knownCanonical.chrom mm9.knownCanonical.chromStart mm9.knownCanonical.chromEnd mm9.knownGene.strand mm9.knownCanonical.transcript mm9.kgXref.refseq -Xkr4 chr1 3204562 3661579 - uc007aeu.1 NM_001011874 -AK149000 chr1 3638391 3648985 - uc007aev.1 -Rp1 chr1 4333587 4350395 - uc007aex.2 NM_011283 -Sox17 chr1 4481008 4486494 - uc007aez.1 NM_011441 -Mrpl15 chr1 4763278 4775807 - uc007aff.2 NM_001177658 -Lypla1 chr1 4797973 4836816 + uc007afh.1 NM_008866 -Tcea1 chr1 4847774 4887990 + uc007afi.2 NM_011541 -Rgs20 chr1 4899656 5060366 - uc007afl.2 NM_001177795 -Atp6v1h chr1 5073253 5152630 + uc007afn.1 NM_133826
--- a/make_test_data/mm9_peaks.txt Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,500 +0,0 @@ -chr1 3213477 3213513 -chr1 3542857 3542893 -chr1 3560979 3561015 -chr1 3621547 3621583 -chr1 4630453 4630489 -chr1 5261737 5261773 -chr1 5562257 5562293 -chr1 6926999 6927035 -chr1 7262846 7262882 -chr1 7322487 7322523 -chr1 7666187 7666223 -chr1 7744070 7744106 -chr1 7969291 7969327 -chr1 8421057 8421093 -chr1 8679021 8679057 -chr1 9359611 9359647 -chr1 9415439 9415475 -chr1 9608130 9608166 -chr1 9616803 9616839 -chr1 9897397 9897433 -chr1 10251725 10251761 -chr1 10254195 10254231 -chr1 10305254 10305290 -chr1 10451286 10451322 -chr1 11340573 11340609 -chr1 11610483 11610519 -chr1 11960381 11960417 -chr1 11987310 11987346 -chr1 12441678 12441714 -chr1 12704380 12704416 -chr1 12871650 12871686 -chr1 13179280 13179316 -chr1 13934524 13934560 -chr1 14479277 14479313 -chr1 14755996 14756032 -chr1 14848637 14848673 -chr1 14967919 14967955 -chr1 15097029 15097065 -chr1 17128114 17128150 -chr1 17160496 17160532 -chr1 17334281 17334317 -chr1 17605285 17605321 -chr1 17922903 17922939 -chr1 18681561 18681597 -chr1 19213304 19213340 -chr1 20317581 20317617 -chr1 21466434 21466470 -chr1 22074908 22074944 -chr1 22696516 22696552 -chr1 23655828 23655864 -chr1 24583893 24583929 -chr1 24738828 24738864 -chr1 24743796 24743832 -chr1 25009857 25009893 -chr1 25313509 25313545 -chr1 26503310 26503346 -chr1 27025916 27025952 -chr1 27385857 27385893 -chr1 27598627 27598663 -chr1 27636264 27636300 -chr1 27687524 27687560 -chr1 28357424 28357460 -chr1 29135026 29135062 -chr1 29633575 29633611 -chr1 29825940 29825976 -chr1 30137793 30137829 -chr1 30142141 30142177 -chr1 30465754 30465790 -chr1 30785908 30785944 -chr1 31077695 31077731 -chr1 31123645 31123681 -chr1 31158742 31158778 -chr1 31883682 31883718 -chr1 31990075 31990111 -chr1 33079863 33079899 -chr1 33288587 33288623 -chr1 33856089 33856125 -chr1 34588477 34588513 -chr1 34633149 34633185 -chr1 34749000 34749036 -chr1 34764419 34764455 -chr1 35032286 35032322 -chr1 35047073 35047109 -chr1 35933401 35933437 -chr1 36135485 36135521 -chr1 36742521 36742557 -chr1 36859752 36859788 -chr1 37388614 37388650 -chr1 37763263 37763299 -chr1 37824535 37824571 -chr1 37974386 37974422 -chr1 37994576 37994612 -chr1 38460553 38460589 -chr1 38502464 38502500 -chr1 38761349 38761385 -chr1 38832604 38832640 -chr1 39388554 39388590 -chr1 39439044 39439080 -chr1 39593773 39593809 -chr1 39693273 39693309 -chr1 39924300 39924336 -chr1 40132160 40132196 -chr1 40243823 40243859 -chr1 40426457 40426493 -chr1 40773529 40773565 -chr1 40785687 40785723 -chr1 40953366 40953402 -chr1 41021129 41021165 -chr1 41080072 41080108 -chr1 41138125 41138161 -chr1 41154639 41154675 -chr1 42299563 42299599 -chr1 42463569 42463605 -chr1 42518766 42518802 -chr1 43783219 43783255 -chr1 44575305 44575341 -chr1 44600563 44600599 -chr1 44982842 44982878 -chr1 45305515 45305551 -chr1 45339758 45339794 -chr1 45422086 45422122 -chr1 45824016 45824052 -chr1 46360753 46360789 -chr1 46527798 46527834 -chr1 47047692 47047728 -chr1 48153542 48153578 -chr1 48306038 48306074 -chr1 48454759 48454795 -chr1 49437523 49437559 -chr1 49709489 49709525 -chr1 50863175 50863211 -chr1 50927909 50927945 -chr1 51137708 51137744 -chr1 51204752 51204788 -chr1 51769267 51769303 -chr1 52110888 52110924 -chr1 52123042 52123078 -chr1 52272863 52272899 -chr1 52840700 52840736 -chr1 52890780 52890816 -chr1 53450997 53451033 -chr1 53599262 53599298 -chr1 53784753 53784789 -chr1 53990993 53991029 -chr1 54016877 54016913 -chr1 54073194 54073230 -chr1 54258499 54258535 -chr1 54429617 54429653 -chr1 54526981 54527017 -chr1 54655149 54655185 -chr1 55664918 55664954 -chr1 55720320 55720356 -chr1 55720320 55720356 -chr1 56585857 56585893 -chr1 56639054 56639090 -chr1 56791957 56791993 -chr1 57250654 57250690 -chr1 57825391 57825427 -chr1 58106272 58106308 -chr1 58642339 58642375 -chr1 58778630 58778666 -chr1 59053239 59053275 -chr1 59066499 59066535 -chr1 59162431 59162467 -chr1 59271155 59271191 -chr1 59457887 59457923 -chr1 59699258 59699294 -chr1 59898050 59898086 -chr1 60028370 60028406 -chr1 60369879 60369915 -chr1 60744666 60744702 -chr1 61132096 61132132 -chr1 61388934 61388970 -chr1 62049483 62049519 -chr1 62591289 62591325 -chr1 62787008 62787044 -chr1 62849190 62849226 -chr1 63330804 63330840 -chr1 63589255 63589291 -chr1 63668100 63668136 -chr1 63717943 63717979 -chr1 64203406 64203442 -chr1 65589476 65589512 -chr1 66584321 66584357 -chr1 66650744 66650780 -chr1 66765432 66765468 -chr1 66788077 66788113 -chr1 68081964 68082000 -chr1 68240850 68240886 -chr1 68261167 68261203 -chr1 68449665 68449701 -chr1 68860261 68860297 -chr1 69018088 69018124 -chr1 69039525 69039561 -chr1 69161322 69161358 -chr1 69672941 69672977 -chr1 69981290 69981326 -chr1 70212174 70212210 -chr1 70438453 70438489 -chr1 71145915 71145951 -chr1 71240778 71240814 -chr1 72471214 72471250 -chr1 72645850 72645886 -chr1 72692566 72692602 -chr1 73777980 73778016 -chr1 73785621 73785657 -chr1 73888393 73888429 -chr1 74405639 74405675 -chr1 74847215 74847251 -chr1 75153395 75153431 -chr1 75851063 75851099 -chr1 76061520 76061556 -chr1 76206645 76206681 -chr1 76479779 76479815 -chr1 76831245 76831281 -chr1 76909640 76909676 -chr1 76974470 76974506 -chr1 76982172 76982208 -chr1 77062655 77062691 -chr1 77544118 77544154 -chr1 77659070 77659106 -chr1 78599048 78599084 -chr1 78675935 78675971 -chr1 78996093 78996129 -chr1 79237126 79237162 -chr1 79266617 79266653 -chr1 79628362 79628398 -chr1 80005541 80005577 -chr1 80025898 80025934 -chr1 80028050 80028086 -chr1 80852217 80852253 -chr1 80913955 80913991 -chr1 81161437 81161473 -chr1 81263506 81263542 -chr1 81379046 81379082 -chr1 81819254 81819290 -chr1 81947775 81947811 -chr1 82250362 82250398 -chr1 82413188 82413224 -chr1 83247390 83247426 -chr1 84040616 84040652 -chr1 84092931 84092967 -chr1 84344563 84344599 -chr1 84408932 84408968 -chr1 85094874 85094910 -chr1 85528842 85528878 -chr1 85826904 85826940 -chr1 85964560 85964596 -chr1 86054265 86054301 -chr1 86056284 86056320 -chr1 86224644 86224680 -chr1 87208129 87208165 -chr1 87444219 87444255 -chr1 87668513 87668549 -chr1 88031697 88031733 -chr1 88349216 88349252 -chr1 88726246 88726282 -chr1 88906288 88906324 -chr1 89124499 89124535 -chr1 89314873 89314909 -chr1 89518437 89518473 -chr1 89592486 89592522 -chr1 89794182 89794218 -chr1 90334569 90334605 -chr1 90336926 90336962 -chr1 92478057 92478093 -chr1 92675608 92675644 -chr1 92954933 92954969 -chr1 93201581 93201617 -chr1 93270331 93270367 -chr1 93777476 93777512 -chr1 94397193 94397229 -chr1 94579866 94579902 -chr1 94844232 94844268 -chr1 95086554 95086590 -chr1 95862340 95862376 -chr1 96049515 96049551 -chr1 97113889 97113925 -chr1 97282222 97282258 -chr1 97328039 97328075 -chr1 97463124 97463160 -chr1 98120197 98120233 -chr1 98196449 98196485 -chr1 98292255 98292291 -chr1 98601476 98601512 -chr1 99285499 99285535 -chr1 99733007 99733043 -chr1 100072537 100072573 -chr1 100467147 100467183 -chr1 100579796 100579832 -chr1 100774096 100774132 -chr1 100858400 100858436 -chr1 100867231 100867267 -chr1 100901957 100901993 -chr1 100984978 100985014 -chr1 101092578 101092614 -chr1 101333258 101333294 -chr1 101534314 101534350 -chr1 101634036 101634072 -chr1 101810843 101810879 -chr1 102278981 102279017 -chr1 102948274 102948310 -chr1 103030355 103030391 -chr1 103317576 103317612 -chr1 103365957 103365993 -chr1 103876850 103876886 -chr1 104567287 104567323 -chr1 105328975 105329011 -chr1 105425643 105425679 -chr1 105466279 105466315 -chr1 105466954 105466990 -chr1 105622547 105622583 -chr1 105737319 105737355 -chr1 105848647 105848683 -chr1 106462232 106462268 -chr1 106946512 106946548 -chr1 107689889 107689925 -chr1 108450749 108450785 -chr1 108577325 108577361 -chr1 108825391 108825427 -chr1 108975480 108975516 -chr1 109014805 109014841 -chr1 109756119 109756155 -chr1 110142400 110142436 -chr1 110400829 110400865 -chr1 110843948 110843984 -chr1 110896336 110896372 -chr1 110926419 110926455 -chr1 111467637 111467673 -chr1 111528830 111528866 -chr1 111952975 111953011 -chr1 112015854 112015890 -chr1 112221526 112221562 -chr1 112393742 112393778 -chr1 112688739 112688775 -chr1 112754960 112754996 -chr1 114014178 114014214 -chr1 114129449 114129485 -chr1 114279757 114279793 -chr1 114489355 114489391 -chr1 114947413 114947449 -chr1 115559737 115559773 -chr1 115788413 115788449 -chr1 116265932 116265968 -chr1 116349373 116349409 -chr1 116496527 116496563 -chr1 116732364 116732400 -chr1 116788050 116788086 -chr1 117105699 117105735 -chr1 117651574 117651610 -chr1 117666069 117666105 -chr1 118378031 118378067 -chr1 119053534 119053570 -chr1 119113385 119113421 -chr1 119174525 119174561 -chr1 119503762 119503798 -chr1 119527726 119527762 -chr1 119948214 119948250 -chr1 120267925 120267961 -chr1 120380981 120381017 -chr1 120465310 120465346 -chr1 120797706 120797742 -chr1 121041195 121041231 -chr1 121094948 121094984 -chr1 121167893 121167929 -chr1 121340746 121340782 -chr1 121587267 121587303 -chr1 121681260 121681296 -chr1 121816202 121816238 -chr1 123026661 123026697 -chr1 123170986 123171022 -chr1 123685384 123685420 -chr1 123835178 123835214 -chr1 123920817 123920853 -chr1 123949970 123950006 -chr1 124461424 124461460 -chr1 125400371 125400407 -chr1 126171930 126171966 -chr1 126179030 126179066 -chr1 126687579 126687615 -chr1 126712327 126712363 -chr1 126783497 126783533 -chr1 126787012 126787048 -chr1 126963082 126963118 -chr1 127190153 127190189 -chr1 127228396 127228432 -chr1 127507342 127507378 -chr1 127703188 127703224 -chr1 127735504 127735540 -chr1 128049231 128049267 -chr1 128388917 128388953 -chr1 128791747 128791783 -chr1 129571914 129571950 -chr1 129582844 129582880 -chr1 130923911 130923947 -chr1 131245002 131245038 -chr1 131624212 131624248 -chr1 131653028 131653064 -chr1 131673494 131673530 -chr1 131762457 131762493 -chr1 132812150 132812186 -chr1 133122490 133122526 -chr1 133337646 133337682 -chr1 134107973 134108009 -chr1 134516117 134516153 -chr1 134650852 134650888 -chr1 135304596 135304632 -chr1 135346221 135346257 -chr1 135595351 135595387 -chr1 135645557 135645593 -chr1 135794196 135794232 -chr1 135833373 135833409 -chr1 136109219 136109255 -chr1 136151385 136151421 -chr1 136219228 136219264 -chr1 136276302 136276338 -chr1 136409892 136409928 -chr1 136846450 136846486 -chr1 137021089 137021125 -chr1 137057829 137057865 -chr1 137256872 137256908 -chr1 137292997 137293033 -chr1 137340715 137340751 -chr1 137563013 137563049 -chr1 138237818 138237854 -chr1 138288739 138288775 -chr1 138701415 138701451 -chr1 138883160 138883196 -chr1 139093105 139093141 -chr1 139286502 139286538 -chr1 139448680 139448716 -chr1 139944056 139944092 -chr1 140207040 140207076 -chr1 141517452 141517488 -chr1 142087663 142087699 -chr1 142561476 142561512 -chr1 142732555 142732591 -chr1 142765329 142765365 -chr1 142811575 142811611 -chr1 142823331 142823367 -chr1 142985887 142985923 -chr1 143071919 143071955 -chr1 143137676 143137712 -chr1 143684082 143684118 -chr1 143803869 143803905 -chr1 143866547 143866583 -chr1 144585588 144585624 -chr1 145018626 145018662 -chr1 145169340 145169376 -chr1 145286043 145286079 -chr1 145743816 145743852 -chr1 145793073 145793109 -chr1 145943835 145943871 -chr1 145973347 145973383 -chr1 146233793 146233829 -chr1 146349912 146349948 -chr1 146992848 146992884 -chr1 147015972 147016008 -chr1 147919367 147919403 -chr1 148073000 148073036 -chr1 148184896 148184932 -chr1 148571263 148571299 -chr1 148727077 148727113 -chr1 148900032 148900068 -chr1 148988309 148988345 -chr1 149151516 149151552 -chr1 149373423 149373459 -chr1 149547172 149547208 -chr1 149930099 149930135 -chr1 150523771 150523807 -chr1 151852781 151852817 -chr1 151941991 151942027 -chr1 152055844 152055880 -chr1 152768992 152769028 -chr1 153117376 153117412 -chr1 153562593 153562629 -chr1 153617551 153617587 -chr1 154259255 154259291 -chr1 154305193 154305229 -chr1 154793310 154793346 -chr1 154959021 154959057 -chr1 155608292 155608328 -chr1 155676641 155676677 -chr1 155882149 155882185 -chr1 156957961 156957997 -chr1 157054389 157054425 -chr1 157229460 157229496 -chr1 157232537 157232573 -chr1 157353367 157353403 -chr1 157530064 157530100 -chr1 157616665 157616701 -chr1 157708175 157708211 -chr1 157854160 157854196 -chr1 157916567 157916603 -chr1 157960555 157960591 -chr1 158166030 158166066 -chr1 158365460 158365496 -chr1 158890212 158890248 -chr1 159139993 159140029 -chr1 159875548 159875584
--- a/make_test_data/mm9_summits.txt Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,500 +0,0 @@ -chr1 3213477 3213478 -chr1 3542857 3542858 -chr1 3560979 3560980 -chr1 3621547 3621548 -chr1 4630453 4630454 -chr1 5261737 5261738 -chr1 5562257 5562258 -chr1 6926999 6927000 -chr1 7262846 7262847 -chr1 7322487 7322488 -chr1 7666187 7666188 -chr1 7744070 7744071 -chr1 7969291 7969292 -chr1 8421057 8421058 -chr1 8679021 8679022 -chr1 9359611 9359612 -chr1 9415439 9415440 -chr1 9608130 9608131 -chr1 9616803 9616804 -chr1 9897397 9897398 -chr1 10251725 10251726 -chr1 10254195 10254196 -chr1 10305254 10305255 -chr1 10451286 10451287 -chr1 11340573 11340574 -chr1 11610483 11610484 -chr1 11960381 11960382 -chr1 11987310 11987311 -chr1 12441678 12441679 -chr1 12704380 12704381 -chr1 12871650 12871651 -chr1 13179280 13179281 -chr1 13934524 13934525 -chr1 14479277 14479278 -chr1 14755996 14755997 -chr1 14848637 14848638 -chr1 14967919 14967920 -chr1 15097029 15097030 -chr1 17128114 17128115 -chr1 17160496 17160497 -chr1 17334281 17334282 -chr1 17605285 17605286 -chr1 17922903 17922904 -chr1 18681561 18681562 -chr1 19213304 19213305 -chr1 20317581 20317582 -chr1 21466434 21466435 -chr1 22074908 22074909 -chr1 22696516 22696517 -chr1 23655828 23655829 -chr1 24583893 24583894 -chr1 24738828 24738829 -chr1 24743796 24743797 -chr1 25009857 25009858 -chr1 25313509 25313510 -chr1 26503310 26503311 -chr1 27025916 27025917 -chr1 27385857 27385858 -chr1 27598627 27598628 -chr1 27636264 27636265 -chr1 27687524 27687525 -chr1 28357424 28357425 -chr1 29135026 29135027 -chr1 29633575 29633576 -chr1 29825940 29825941 -chr1 30137793 30137794 -chr1 30142141 30142142 -chr1 30465754 30465755 -chr1 30785908 30785909 -chr1 31077695 31077696 -chr1 31123645 31123646 -chr1 31158742 31158743 -chr1 31883682 31883683 -chr1 31990075 31990076 -chr1 33079863 33079864 -chr1 33288587 33288588 -chr1 33856089 33856090 -chr1 34588477 34588478 -chr1 34633149 34633150 -chr1 34749000 34749001 -chr1 34764419 34764420 -chr1 35032286 35032287 -chr1 35047073 35047074 -chr1 35933401 35933402 -chr1 36135485 36135486 -chr1 36742521 36742522 -chr1 36859752 36859753 -chr1 37388614 37388615 -chr1 37763263 37763264 -chr1 37824535 37824536 -chr1 37974386 37974387 -chr1 37994576 37994577 -chr1 38460553 38460554 -chr1 38502464 38502465 -chr1 38761349 38761350 -chr1 38832604 38832605 -chr1 39388554 39388555 -chr1 39439044 39439045 -chr1 39593773 39593774 -chr1 39693273 39693274 -chr1 39924300 39924301 -chr1 40132160 40132161 -chr1 40243823 40243824 -chr1 40426457 40426458 -chr1 40773529 40773530 -chr1 40785687 40785688 -chr1 40953366 40953367 -chr1 41021129 41021130 -chr1 41080072 41080073 -chr1 41138125 41138126 -chr1 41154639 41154640 -chr1 42299563 42299564 -chr1 42463569 42463570 -chr1 42518766 42518767 -chr1 43783219 43783220 -chr1 44575305 44575306 -chr1 44600563 44600564 -chr1 44982842 44982843 -chr1 45305515 45305516 -chr1 45339758 45339759 -chr1 45422086 45422087 -chr1 45824016 45824017 -chr1 46360753 46360754 -chr1 46527798 46527799 -chr1 47047692 47047693 -chr1 48153542 48153543 -chr1 48306038 48306039 -chr1 48454759 48454760 -chr1 49437523 49437524 -chr1 49709489 49709490 -chr1 50863175 50863176 -chr1 50927909 50927910 -chr1 51137708 51137709 -chr1 51204752 51204753 -chr1 51769267 51769268 -chr1 52110888 52110889 -chr1 52123042 52123043 -chr1 52272863 52272864 -chr1 52840700 52840701 -chr1 52890780 52890781 -chr1 53450997 53450998 -chr1 53599262 53599263 -chr1 53784753 53784754 -chr1 53990993 53990994 -chr1 54016877 54016878 -chr1 54073194 54073195 -chr1 54258499 54258500 -chr1 54429617 54429618 -chr1 54526981 54526982 -chr1 54655149 54655150 -chr1 55664918 55664919 -chr1 55720320 55720321 -chr1 55720320 55720321 -chr1 56585857 56585858 -chr1 56639054 56639055 -chr1 56791957 56791958 -chr1 57250654 57250655 -chr1 57825391 57825392 -chr1 58106272 58106273 -chr1 58642339 58642340 -chr1 58778630 58778631 -chr1 59053239 59053240 -chr1 59066499 59066500 -chr1 59162431 59162432 -chr1 59271155 59271156 -chr1 59457887 59457888 -chr1 59699258 59699259 -chr1 59898050 59898051 -chr1 60028370 60028371 -chr1 60369879 60369880 -chr1 60744666 60744667 -chr1 61132096 61132097 -chr1 61388934 61388935 -chr1 62049483 62049484 -chr1 62591289 62591290 -chr1 62787008 62787009 -chr1 62849190 62849191 -chr1 63330804 63330805 -chr1 63589255 63589256 -chr1 63668100 63668101 -chr1 63717943 63717944 -chr1 64203406 64203407 -chr1 65589476 65589477 -chr1 66584321 66584322 -chr1 66650744 66650745 -chr1 66765432 66765433 -chr1 66788077 66788078 -chr1 68081964 68081965 -chr1 68240850 68240851 -chr1 68261167 68261168 -chr1 68449665 68449666 -chr1 68860261 68860262 -chr1 69018088 69018089 -chr1 69039525 69039526 -chr1 69161322 69161323 -chr1 69672941 69672942 -chr1 69981290 69981291 -chr1 70212174 70212175 -chr1 70438453 70438454 -chr1 71145915 71145916 -chr1 71240778 71240779 -chr1 72471214 72471215 -chr1 72645850 72645851 -chr1 72692566 72692567 -chr1 73777980 73777981 -chr1 73785621 73785622 -chr1 73888393 73888394 -chr1 74405639 74405640 -chr1 74847215 74847216 -chr1 75153395 75153396 -chr1 75851063 75851064 -chr1 76061520 76061521 -chr1 76206645 76206646 -chr1 76479779 76479780 -chr1 76831245 76831246 -chr1 76909640 76909641 -chr1 76974470 76974471 -chr1 76982172 76982173 -chr1 77062655 77062656 -chr1 77544118 77544119 -chr1 77659070 77659071 -chr1 78599048 78599049 -chr1 78675935 78675936 -chr1 78996093 78996094 -chr1 79237126 79237127 -chr1 79266617 79266618 -chr1 79628362 79628363 -chr1 80005541 80005542 -chr1 80025898 80025899 -chr1 80028050 80028051 -chr1 80852217 80852218 -chr1 80913955 80913956 -chr1 81161437 81161438 -chr1 81263506 81263507 -chr1 81379046 81379047 -chr1 81819254 81819255 -chr1 81947775 81947776 -chr1 82250362 82250363 -chr1 82413188 82413189 -chr1 83247390 83247391 -chr1 84040616 84040617 -chr1 84092931 84092932 -chr1 84344563 84344564 -chr1 84408932 84408933 -chr1 85094874 85094875 -chr1 85528842 85528843 -chr1 85826904 85826905 -chr1 85964560 85964561 -chr1 86054265 86054266 -chr1 86056284 86056285 -chr1 86224644 86224645 -chr1 87208129 87208130 -chr1 87444219 87444220 -chr1 87668513 87668514 -chr1 88031697 88031698 -chr1 88349216 88349217 -chr1 88726246 88726247 -chr1 88906288 88906289 -chr1 89124499 89124500 -chr1 89314873 89314874 -chr1 89518437 89518438 -chr1 89592486 89592487 -chr1 89794182 89794183 -chr1 90334569 90334570 -chr1 90336926 90336927 -chr1 92478057 92478058 -chr1 92675608 92675609 -chr1 92954933 92954934 -chr1 93201581 93201582 -chr1 93270331 93270332 -chr1 93777476 93777477 -chr1 94397193 94397194 -chr1 94579866 94579867 -chr1 94844232 94844233 -chr1 95086554 95086555 -chr1 95862340 95862341 -chr1 96049515 96049516 -chr1 97113889 97113890 -chr1 97282222 97282223 -chr1 97328039 97328040 -chr1 97463124 97463125 -chr1 98120197 98120198 -chr1 98196449 98196450 -chr1 98292255 98292256 -chr1 98601476 98601477 -chr1 99285499 99285500 -chr1 99733007 99733008 -chr1 100072537 100072538 -chr1 100467147 100467148 -chr1 100579796 100579797 -chr1 100774096 100774097 -chr1 100858400 100858401 -chr1 100867231 100867232 -chr1 100901957 100901958 -chr1 100984978 100984979 -chr1 101092578 101092579 -chr1 101333258 101333259 -chr1 101534314 101534315 -chr1 101634036 101634037 -chr1 101810843 101810844 -chr1 102278981 102278982 -chr1 102948274 102948275 -chr1 103030355 103030356 -chr1 103317576 103317577 -chr1 103365957 103365958 -chr1 103876850 103876851 -chr1 104567287 104567288 -chr1 105328975 105328976 -chr1 105425643 105425644 -chr1 105466279 105466280 -chr1 105466954 105466955 -chr1 105622547 105622548 -chr1 105737319 105737320 -chr1 105848647 105848648 -chr1 106462232 106462233 -chr1 106946512 106946513 -chr1 107689889 107689890 -chr1 108450749 108450750 -chr1 108577325 108577326 -chr1 108825391 108825392 -chr1 108975480 108975481 -chr1 109014805 109014806 -chr1 109756119 109756120 -chr1 110142400 110142401 -chr1 110400829 110400830 -chr1 110843948 110843949 -chr1 110896336 110896337 -chr1 110926419 110926420 -chr1 111467637 111467638 -chr1 111528830 111528831 -chr1 111952975 111952976 -chr1 112015854 112015855 -chr1 112221526 112221527 -chr1 112393742 112393743 -chr1 112688739 112688740 -chr1 112754960 112754961 -chr1 114014178 114014179 -chr1 114129449 114129450 -chr1 114279757 114279758 -chr1 114489355 114489356 -chr1 114947413 114947414 -chr1 115559737 115559738 -chr1 115788413 115788414 -chr1 116265932 116265933 -chr1 116349373 116349374 -chr1 116496527 116496528 -chr1 116732364 116732365 -chr1 116788050 116788051 -chr1 117105699 117105700 -chr1 117651574 117651575 -chr1 117666069 117666070 -chr1 118378031 118378032 -chr1 119053534 119053535 -chr1 119113385 119113386 -chr1 119174525 119174526 -chr1 119503762 119503763 -chr1 119527726 119527727 -chr1 119948214 119948215 -chr1 120267925 120267926 -chr1 120380981 120380982 -chr1 120465310 120465311 -chr1 120797706 120797707 -chr1 121041195 121041196 -chr1 121094948 121094949 -chr1 121167893 121167894 -chr1 121340746 121340747 -chr1 121587267 121587268 -chr1 121681260 121681261 -chr1 121816202 121816203 -chr1 123026661 123026662 -chr1 123170986 123170987 -chr1 123685384 123685385 -chr1 123835178 123835179 -chr1 123920817 123920818 -chr1 123949970 123949971 -chr1 124461424 124461425 -chr1 125400371 125400372 -chr1 126171930 126171931 -chr1 126179030 126179031 -chr1 126687579 126687580 -chr1 126712327 126712328 -chr1 126783497 126783498 -chr1 126787012 126787013 -chr1 126963082 126963083 -chr1 127190153 127190154 -chr1 127228396 127228397 -chr1 127507342 127507343 -chr1 127703188 127703189 -chr1 127735504 127735505 -chr1 128049231 128049232 -chr1 128388917 128388918 -chr1 128791747 128791748 -chr1 129571914 129571915 -chr1 129582844 129582845 -chr1 130923911 130923912 -chr1 131245002 131245003 -chr1 131624212 131624213 -chr1 131653028 131653029 -chr1 131673494 131673495 -chr1 131762457 131762458 -chr1 132812150 132812151 -chr1 133122490 133122491 -chr1 133337646 133337647 -chr1 134107973 134107974 -chr1 134516117 134516118 -chr1 134650852 134650853 -chr1 135304596 135304597 -chr1 135346221 135346222 -chr1 135595351 135595352 -chr1 135645557 135645558 -chr1 135794196 135794197 -chr1 135833373 135833374 -chr1 136109219 136109220 -chr1 136151385 136151386 -chr1 136219228 136219229 -chr1 136276302 136276303 -chr1 136409892 136409893 -chr1 136846450 136846451 -chr1 137021089 137021090 -chr1 137057829 137057830 -chr1 137256872 137256873 -chr1 137292997 137292998 -chr1 137340715 137340716 -chr1 137563013 137563014 -chr1 138237818 138237819 -chr1 138288739 138288740 -chr1 138701415 138701416 -chr1 138883160 138883161 -chr1 139093105 139093106 -chr1 139286502 139286503 -chr1 139448680 139448681 -chr1 139944056 139944057 -chr1 140207040 140207041 -chr1 141517452 141517453 -chr1 142087663 142087664 -chr1 142561476 142561477 -chr1 142732555 142732556 -chr1 142765329 142765330 -chr1 142811575 142811576 -chr1 142823331 142823332 -chr1 142985887 142985888 -chr1 143071919 143071920 -chr1 143137676 143137677 -chr1 143684082 143684083 -chr1 143803869 143803870 -chr1 143866547 143866548 -chr1 144585588 144585589 -chr1 145018626 145018627 -chr1 145169340 145169341 -chr1 145286043 145286044 -chr1 145743816 145743817 -chr1 145793073 145793074 -chr1 145943835 145943836 -chr1 145973347 145973348 -chr1 146233793 146233794 -chr1 146349912 146349913 -chr1 146992848 146992849 -chr1 147015972 147015973 -chr1 147919367 147919368 -chr1 148073000 148073001 -chr1 148184896 148184897 -chr1 148571263 148571264 -chr1 148727077 148727078 -chr1 148900032 148900033 -chr1 148988309 148988310 -chr1 149151516 149151517 -chr1 149373423 149373424 -chr1 149547172 149547173 -chr1 149930099 149930100 -chr1 150523771 150523772 -chr1 151852781 151852782 -chr1 151941991 151941992 -chr1 152055844 152055845 -chr1 152768992 152768993 -chr1 153117376 153117377 -chr1 153562593 153562594 -chr1 153617551 153617552 -chr1 154259255 154259256 -chr1 154305193 154305194 -chr1 154793310 154793311 -chr1 154959021 154959022 -chr1 155608292 155608293 -chr1 155676641 155676642 -chr1 155882149 155882150 -chr1 156957961 156957962 -chr1 157054389 157054390 -chr1 157229460 157229461 -chr1 157232537 157232538 -chr1 157353367 157353368 -chr1 157530064 157530065 -chr1 157616665 157616666 -chr1 157708175 157708176 -chr1 157854160 157854161 -chr1 157916567 157916568 -chr1 157960555 157960556 -chr1 158166030 158166031 -chr1 158365460 158365461 -chr1 158890212 158890213 -chr1 159139993 159139994 -chr1 159875548 159875549
--- a/make_test_data/peaks.txt Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,70 +0,0 @@ -#peak s e -chr1 10617233 10617437 -chr1 108747519 108747791 -chr1 120760212 120760461 -chr1 132950929 132951247 -chr1 133114860 133115015 -chr1 135582677 135582828 -chr1 135851853 135852218 -chr1 136956468 136956598 -chr1 13829227 13829564 -chr1 138437726 138437860 -chr1 140381656 140381785 -chr1 145591041 145591176 -chr1 154971572 154971673 -chr1 155123313 155123435 -chr1 158510523 158510813 -chr1 158537267 158537411 -chr1 158580638 158580759 -chr1 158835251 158835391 -chr1 159240736 159240866 -chr1 163827897 163828062 -chr1 164215623 164215935 -chr1 167222964 167223261 -chr1 167906284 167906554 -chr1 170255081 170255260 -chr1 17030405 17030545 -chr1 172620779 172620912 -chr1 172620917 172621080 -chr1 174376470 174376659 -chr1 181061299 181061446 -chr1 182479646 182479905 -chr1 185854947 185855105 -chr1 194258648 194259032 -chr1 194645118 194645475 -chr1 194957396 194957723 -chr1 195324443 195324741 -chr1 195330701 195330930 -chr1 195338316 195338616 -chr1 195342728 195342985 -chr1 195384767 195385195 -chr1 197057796 197057843 -chr1 24609562 24609623 -chr1 24609923 24609992 -chr1 24730996 24731077 -chr1 26734195 26734485 -chr1 34206924 34207100 -chr1 36106813 36107058 -chr1 39492140 39492513 -chr1 40325917 40326123 -chr1 44195449 44195639 -chr1 52625416 52625560 -chr1 54631692 54631815 -chr1 55283572 55283675 -chr1 63664888 63665018 -chr1 72769824 72770056 -chr1 72770058 72770226 -chr1 72815517 72815742 -chr1 75481920 75482054 -chr1 77457642 77457791 -chr1 78630893 78631160 -chr1 88408969 88409267 -chr1 89989553 89989714 -chr1 90412932 90413132 -chr1 90592499 90592629 -chr1 91496003 91496145 -chr1 91496155 91496319 -chr1 92070253 92070431 -chr1 95186508 95186637 -chr1 9619046 9619167 -chr1 9619175 9619382
--- a/make_test_data/summits.txt Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,654 +0,0 @@ -#peak mid plus1 -chr10 106033584 106033585 -chr10 106033751 106033752 -chr10 107429926 107429927 -chr10 114752719 114752720 -chr10 114994096 114994097 -chr10 127058840 127058841 -chr10 127184557 127184558 -chr10 13089536 13089537 -chr10 13408622 13408623 -chr10 17725474 17725475 -chr10 21862583 21862584 -chr10 21862774 21862775 -chr10 31587625 31587626 -chr10 41613298 41613299 -chr10 43640892 43640893 -chr10 43740181 43740182 -chr10 45093322 45093323 -chr10 57702300 57702301 -chr10 59362596 59362597 -chr10 59693654 59693655 -chr10 60613588 60613589 -chr10 60696228 60696229 -chr10 67567003 67567004 -chr10 76664902 76664903 -chr10 7707698 7707699 -chr10 79808095 79808096 -chr10 80126390 80126391 -chr10 81033719 81033720 -chr10 82306942 82306943 -chr10 82517145 82517146 -chr10 84922053 84922054 -chr10 88433836 88433837 -chr10 89195191 89195192 -chr10 93642365 93642366 -chr10 94183365 94183366 -chr10 94306306 94306307 -chr1 10627335 10627336 -chr1 108757655 108757656 -chr11 100148455 100148456 -chr11 100964551 100964552 -chr11 102973374 102973375 -chr11 103196320 103196321 -chr11 107278688 107278689 -chr11 110241161 110241162 -chr11 114563829 114563830 -chr11 115639021 115639022 -chr11 115836265 115836266 -chr11 119827740 119827741 -chr11 120952392 120952393 -chr11 121341339 121341340 -chr11 16560450 16560451 -chr11 18798190 18798191 -chr11 19003164 19003165 -chr11 20247624 20247625 -chr1 120770337 120770338 -chr11 21483462 21483463 -chr11 29514477 29514478 -chr11 3000481 3000482 -chr11 3266659 3266660 -chr1 132961088 132961089 -chr1 133124938 133124939 -chr11 34495361 34495362 -chr1 135592753 135592754 -chr1 135862036 135862037 -chr1 136966533 136966534 -chr1 13839396 13839397 -chr1 138447793 138447794 -chr1 140391721 140391722 -chr11 4116866 4116867 -chr1 145601109 145601110 -chr11 50300699 50300700 -chr11 5481053 5481054 -chr1 154981623 154981624 -chr1 155133374 155133375 -chr1 158520668 158520669 -chr1 158547339 158547340 -chr1 158590699 158590700 -chr1 158845321 158845322 -chr1 159250801 159250802 -chr11 59272503 59272504 -chr11 6069204 6069205 -chr1 163837980 163837981 -chr1 164225779 164225780 -chr1 167233113 167233114 -chr1 167916419 167916420 -chr11 69572437 69572438 -chr1 170265171 170265172 -chr11 70397406 70397407 -chr1 17040475 17040476 -chr1 172630846 172630847 -chr1 172630999 172631000 -chr1 174386565 174386566 -chr11 76126479 76126480 -chr1 181071373 181071374 -chr1 182489776 182489777 -chr11 83860977 83860978 -chr11 84381942 84381943 -chr11 8483612 8483613 -chr11 8541945 8541946 -chr1 185865026 185865027 -chr11 87257043 87257044 -chr11 87967409 87967410 -chr11 87967599 87967600 -chr11 93986729 93986730 -chr1 194268840 194268841 -chr1 194655297 194655298 -chr1 194967560 194967561 -chr1 195334592 195334593 -chr1 195340816 195340817 -chr1 195348466 195348467 -chr1 195352857 195352858 -chr1 195394981 195394982 -chr1 197067820 197067821 -chr11 97171690 97171691 -chr11 97233548 97233549 -chr11 97297212 97297213 -chr12 104299157 104299158 -chr12 106237696 106237697 -chr12 106674392 106674393 -chr12 112330425 112330426 -chr12 112477144 112477145 -chr12 112975712 112975713 -chr12 113981451 113981452 -chr12 114119343 114119344 -chr12 117853390 117853391 -chr12 25562241 25562242 -chr12 25648378 25648379 -chr12 37211753 37211754 -chr1 24619593 24619594 -chr1 24619958 24619959 -chr1 24741037 24741038 -chr12 57923295 57923296 -chr12 58725309 58725310 -chr1 26744340 26744341 -chr12 70755181 70755182 -chr12 72971895 72971896 -chr12 80608252 80608253 -chr12 86926811 86926812 -chr12 92932316 92932317 -chr12 92984595 92984596 -chr13 10082361 10082362 -chr13 102618599 102618600 -chr13 103679464 103679465 -chr13 104768206 104768207 -chr13 110051416 110051417 -chr13 113548696 113548697 -chr13 120276594 120276595 -chr13 12578010 12578011 -chr13 23610160 23610161 -chr13 33170306 33170307 -chr13 38172741 38172742 -chr13 38254769 38254770 -chr13 40820500 40820501 -chr1 34217012 34217013 -chr13 47047075 47047076 -chr13 47062921 47062922 -chr13 56003795 56003796 -chr13 57960273 57960274 -chr1 36116936 36116937 -chr13 63189880 63189881 -chr13 63381834 63381835 -chr13 73643112 73643113 -chr13 91318240 91318241 -chr13 91510502 91510503 -chr1 39502327 39502328 -chr13 96258876 96258877 -chr13 97344282 97344283 -chr13 98808966 98808967 -chr1 40336020 40336021 -chr14 11823985 11823986 -chr14 120603083 120603084 -chr14 120721569 120721570 -chr14 21906019 21906020 -chr14 26296311 26296312 -chr14 33150022 33150023 -chr14 41762023 41762024 -chr1 44205544 44205545 -chr14 48866037 48866038 -chr14 51711605 51711606 -chr14 52550650 52550651 -chr14 55194787 55194788 -chr14 57316903 57316904 -chr14 58540770 58540771 -chr14 61693994 61693995 -chr14 61973511 61973512 -chr14 63456124 63456125 -chr14 65935630 65935631 -chr14 69265002 69265003 -chr14 69273108 69273109 -chr14 70724643 70724644 -chr14 73637753 73637754 -chr14 73655550 73655551 -chr14 73713362 73713363 -chr14 73770668 73770669 -chr14 75184388 75184389 -chr14 75346569 75346570 -chr14 76292024 76292025 -chr14 79927582 79927583 -chr14 9521198 9521199 -chr15 100992242 100992243 -chr15 101063407 101063408 -chr15 101563471 101563472 -chr15 102066010 102066011 -chr1 52635488 52635489 -chr15 32250651 32250652 -chr15 35249192 35249193 -chr15 35631086 35631087 -chr15 37127869 37127870 -chr1 54641754 54641755 -chr1 55293624 55293625 -chr15 53027764 53027765 -chr15 53130961 53130962 -chr15 54185561 54185562 -chr15 55202036 55202037 -chr15 57480129 57480130 -chr15 74917152 74917153 -chr15 74917383 74917384 -chr15 75989308 75989309 -chr15 77629316 77629317 -chr15 77661605 77661606 -chr15 80038823 80038824 -chr15 80533396 80533397 -chr15 80691860 80691861 -chr15 82973449 82973450 -chr15 84022595 84022596 -chr15 85064373 85064374 -chr15 97706407 97706408 -chr15 99628562 99628563 -chr16 16866444 16866445 -chr16 16912317 16912318 -chr16 17866100 17866101 -chr16 17949763 17949764 -chr16 24948588 24948589 -chr16 25385707 25385708 -chr16 25836029 25836030 -chr16 25843933 25843934 -chr16 31290592 31290593 -chr16 33883661 33883662 -chr16 34430325 34430326 -chr16 35981824 35981825 -chr1 63674953 63674954 -chr16 43508591 43508592 -chr16 43574371 43574372 -chr16 44101459 44101460 -chr16 57391635 57391636 -chr16 57391748 57391749 -chr16 62799541 62799542 -chr16 6295331 6295332 -chr16 70314810 70314811 -chr16 72688706 72688707 -chr16 78632436 78632437 -chr16 90095387 90095388 -chr16 90151215 90151216 -chr16 90468446 90468447 -chr16 91875996 91875997 -chr16 92744754 92744755 -chr16 94024219 94024220 -chr16 94427408 94427409 -chr16 95881212 95881213 -chr16 96224521 96224522 -chr17 17959961 17959962 -chr17 23681171 23681172 -chr1 72779940 72779941 -chr1 72780142 72780143 -chr1 72825630 72825631 -chr17 28478172 28478173 -chr17 28834572 28834573 -chr17 31823497 31823498 -chr17 31979297 31979298 -chr17 33920556 33920557 -chr17 36368235 36368236 -chr17 39981683 39981684 -chr17 39985109 39985110 -chr17 43064430 43064431 -chr17 45715395 45715396 -chr17 46403243 46403244 -chr17 46403380 46403381 -chr17 47404360 47404361 -chr1 75491987 75491988 -chr17 56447632 56447633 -chr17 71508749 71508750 -chr1 77467717 77467718 -chr17 78655126 78655127 -chr17 79794315 79794316 -chr17 84737002 84737003 -chr1 78641027 78641028 -chr18 11755885 11755886 -chr18 12671183 12671184 -chr18 34147214 34147215 -chr18 35061192 35061193 -chr18 39723442 39723443 -chr18 40467892 40467893 -chr18 42207995 42207996 -chr18 42930957 42930958 -chr18 43135643 43135644 -chr18 43419069 43419070 -chr18 43419219 43419220 -chr18 44675226 44675227 -chr18 47529528 47529529 -chr18 5016849 5016850 -chr18 50224778 50224779 -chr18 57946142 57946143 -chr18 61428548 61428549 -chr18 61934208 61934209 -chr18 65457025 65457026 -chr1 88419118 88419119 -chr18 9428997 9428998 -chr1 89999634 89999635 -chr1 90423032 90423033 -chr1 90602564 90602565 -chr19 10798384 10798385 -chr1 91506074 91506075 -chr1 91506237 91506238 -chr1 92080342 92080343 -chr19 26820923 26820924 -chr19 47782532 47782533 -chr1 95196573 95196574 -chr19 53969373 53969374 -chr19 5846865 5846866 -chr19 61275648 61275649 -chr1 9629107 9629108 -chr1 9629279 9629280 -chr19 9018714 9018715 -chr19 9062346 9062347 -chr19 9144947 9144948 -chr2 102274223 102274224 -chr2 102288220 102288221 -chr2 104540072 104540073 -chr2 109810219 109810220 -chr2 110568326 110568327 -chr2 112043286 112043287 -chr2 122171434 122171435 -chr2 126962808 126962809 -chr2 127332233 127332234 -chr2 129432150 129432151 -chr2 130201294 130201295 -chr2 131923486 131923487 -chr2 132577421 132577422 -chr2 136745391 136745392 -chr2 13696935 13696936 -chr2 140652077 140652078 -chr2 146397541 146397542 -chr2 148295584 148295585 -chr2 148343818 148343819 -chr2 148558303 148558304 -chr2 157260393 157260394 -chr2 160572977 160572978 -chr2 164682813 164682814 -chr2 165427405 165427406 -chr2 165720222 165720223 -chr2 168745748 168745749 -chr2 172759694 172759695 -chr2 172763360 172763361 -chr2 173901730 173901731 -chr2 25988548 25988549 -chr2 27585569 27585570 -chr2 28282918 28282919 -chr2 30663471 30663472 -chr2 31019531 31019532 -chr2 31119743 31119744 -chr2 35346371 35346372 -chr2 35518012 35518013 -chr2 35524862 35524863 -chr2 38355143 38355144 -chr2 38843815 38843816 -chr2 38843972 38843973 -chr2 52035090 52035091 -chr2 5300381 5300382 -chr2 59285910 59285911 -chr2 60283369 60283370 -chr2 65385479 65385480 -chr2 68763818 68763819 -chr2 76386556 76386557 -chr3 100835953 100835954 -chr3 101743281 101743282 -chr3 10277579 10277580 -chr3 108226998 108226999 -chr3 109489624 109489625 -chr3 109687117 109687118 -chr3 115822204 115822205 -chr3 116529685 116529686 -chr3 121601368 121601369 -chr3 122624125 122624126 -chr3 131236567 131236568 -chr3 133263978 133263979 -chr3 133271907 133271908 -chr3 148641587 148641588 -chr3 148641735 148641736 -chr3 151026490 151026491 -chr3 151774393 151774394 -chr3 159510847 159510848 -chr3 27907564 27907565 -chr3 29852588 29852589 -chr3 30992357 30992358 -chr3 37395368 37395369 -chr3 52130683 52130684 -chr3 52912682 52912683 -chr3 53475904 53475905 -chr3 59001668 59001669 -chr3 60421600 60421601 -chr3 60421744 60421745 -chr3 67769446 67769447 -chr3 69758259 69758260 -chr3 7487953 7487954 -chr3 79711488 79711489 -chr3 80988962 80988963 -chr3 83579412 83579413 -chr3 83791586 83791587 -chr3 83863238 83863239 -chr3 85735976 85735977 -chr3 87369620 87369621 -chr3 88458239 88458240 -chr3 90049693 90049694 -chr3 92698059 92698060 -chr3 96066220 96066221 -chr4 100623172 100623173 -chr4 105979770 105979771 -chr4 116862731 116862732 -chr4 117295856 117295857 -chr4 118220858 118220859 -chr4 122723762 122723763 -chr4 123266401 123266402 -chr4 126168413 126168414 -chr4 129093950 129093951 -chr4 129413697 129413698 -chr4 132011663 132011664 -chr4 133155902 133155903 -chr4 133160955 133160956 -chr4 135129138 135129139 -chr4 136010879 136010880 -chr4 136838756 136838757 -chr4 137004194 137004195 -chr4 140731847 140731848 -chr4 141160758 141160759 -chr4 141297891 141297892 -chr4 144482189 144482190 -chr4 150245511 150245512 -chr4 151779151 151779152 -chr4 151779297 151779298 -chr4 153446235 153446236 -chr4 155148830 155148831 -chr4 155164911 155164912 -chr4 35037416 35037417 -chr4 40845966 40845967 -chr4 41654489 41654490 -chr4 45434915 45434916 -chr4 53231170 53231171 -chr4 53453177 53453178 -chr4 57351174 57351175 -chr4 58163335 58163336 -chr4 62324439 62324440 -chr4 63117595 63117596 -chr4 63120747 63120748 -chr4 65265851 65265852 -chr4 65266046 65266047 -chr4 70039222 70039223 -chr4 80978722 80978723 -chr4 83963547 83963548 -chr4 84031308 84031309 -chr4 95598334 95598335 -chr4 97441884 97441885 -chr4 98327543 98327544 -chr5 102171703 102171704 -chr5 102846906 102846907 -chr5 103816943 103816944 -chr5 103824902 103824903 -chr5 104025747 104025748 -chr5 111739454 111739455 -chr5 114623119 114623120 -chr5 115329525 115329526 -chr5 115521850 115521851 -chr5 115997785 115997786 -chr5 124428096 124428097 -chr5 124616438 124616439 -chr5 12506043 12506044 -chr5 125870085 125870086 -chr5 135053576 135053577 -chr5 136097865 136097866 -chr5 136723239 136723240 -chr5 141131567 141131568 -chr5 143585307 143585308 -chr5 147072751 147072752 -chr5 147072865 147072866 -chr5 147910495 147910496 -chr5 15052325 15052326 -chr5 15112758 15112759 -chr5 21697850 21697851 -chr5 23158397 23158398 -chr5 23977791 23977792 -chr5 32423622 32423623 -chr5 35245832 35245833 -chr5 35342159 35342160 -chr5 50430918 50430919 -chr5 51959859 51959860 -chr5 58431600 58431601 -chr5 64634166 64634167 -chr5 65807245 65807246 -chr5 66472573 66472574 -chr5 72564131 72564132 -chr5 73646186 73646187 -chr5 87159785 87159786 -chr5 90818821 90818822 -chr5 99781594 99781595 -chr6 100518848 100518849 -chr6 103599133 103599134 -chr6 113116711 113116712 -chr6 121080230 121080231 -chr6 127325975 127325976 -chr6 127381753 127381754 -chr6 127425244 127425245 -chr6 128054836 128054837 -chr6 128289233 128289234 -chr6 128326644 128326645 -chr6 128547343 128547344 -chr6 134445175 134445176 -chr6 134445312 134445313 -chr6 143811364 143811365 -chr6 146887669 146887670 -chr6 147297840 147297841 -chr6 17267124 17267125 -chr6 33926636 33926637 -chr6 37242315 37242316 -chr6 47601314 47601315 -chr6 49172166 49172167 -chr6 51351355 51351356 -chr6 56806957 56806958 -chr6 67253361 67253362 -chr6 76927942 76927943 -chr6 83071812 83071813 -chr6 83093011 83093012 -chr6 86130730 86130731 -chr6 87137073 87137074 -chr6 87222111 87222112 -chr6 94625281 94625282 -chr7 104849801 104849802 -chr7 117975070 117975071 -chr7 119647132 119647133 -chr7 119813749 119813750 -chr7 120393123 120393124 -chr7 120874367 120874368 -chr7 123336714 123336715 -chr7 125720143 125720144 -chr7 126039427 126039428 -chr7 127004913 127004914 -chr7 128854935 128854936 -chr7 128984541 128984542 -chr7 134819118 134819119 -chr7 135696903 135696904 -chr7 137484210 137484211 -chr7 137768001 137768002 -chr7 138009297 138009298 -chr7 138123566 138123567 -chr7 138123699 138123700 -chr7 139426142 139426143 -chr7 146041529 146041530 -chr7 147156352 147156353 -chr7 148379180 148379181 -chr7 148379362 148379363 -chr7 148629281 148629282 -chr7 150571560 150571561 -chr7 152450338 152450339 -chr7 152450519 152450520 -chr7 16562058 16562059 -chr7 16894872 16894873 -chr7 17429367 17429368 -chr7 20044401 20044402 -chr7 26061110 26061111 -chr7 26574315 26574316 -chr7 28010205 28010206 -chr7 30227710 30227711 -chr7 30256558 30256559 -chr7 35861923 35861924 -chr7 56809068 56809069 -chr7 87336398 87336399 -chr7 88092779 88092780 -chr7 89920499 89920500 -chr8 10576464 10576465 -chr8 107426996 107426997 -chr8 109087961 109087962 -chr8 109275046 109275047 -chr8 109334564 109334565 -chr8 113806188 113806189 -chr8 119851483 119851484 -chr8 121354388 121354389 -chr8 129127362 129127363 -chr8 129549456 129549457 -chr8 13548998 13548999 -chr8 13668465 13668466 -chr8 14306960 14306961 -chr8 17594804 17594805 -chr8 19919526 19919527 -chr8 19924810 19924811 -chr8 22870138 22870139 -chr8 23921280 23921281 -chr8 24206095 24206096 -chr8 34068894 34068895 -chr8 37107644 37107645 -chr8 4586605 4586606 -chr8 70850825 70850826 -chr8 71717281 71717282 -chr8 73173598 73173599 -chr8 73183558 73183559 -chr8 73297497 73297498 -chr8 81256455 81256456 -chr8 86143616 86143617 -chr8 87180694 87180695 -chr8 88126748 88126749 -chr8 93828640 93828641 -chr8 97699878 97699879 -chr9 100543647 100543648 -chr9 103988283 103988284 -chr9 106273656 106273657 -chr9 107478162 107478163 -chr9 108851463 108851464 -chr9 110183808 110183809 -chr9 111053664 111053665 -chr9 116828689 116828690 -chr9 118884586 118884587 -chr9 120883928 120883929 -chr9 123371104 123371105 -chr9 13408238 13408239 -chr9 14466849 14466850 -chr9 14480293 14480294 -chr9 24346538 24346539 -chr9 3258857 3258858 -chr9 42777363 42777364 -chr9 43528251 43528252 -chr9 43585984 43585985 -chr9 44215148 44215149 -chr9 44307103 44307104 -chr9 54460731 54460732 -chr9 66728918 66728919 -chr9 66794084 66794085 -chr9 67556540 67556541 -chr9 70477636 70477637 -chr9 72497695 72497696 -chr9 72916030 72916031 -chr9 74815214 74815215 -chr9 75371664 75371665 -chr9 8033087 8033088 -chr9 8055015 8055016 -chr9 83462792 83462793 -chr9 86714892 86714893 -chrX 109484691 109484692 -chrX 137172820 137172821 -chrX 139917606 139917607 -chrX 140401017 140401018 -chrX 163589625 163589626 -chrX 166360754 166360755 -chrX 166427362 166427363 -chrX 166432950 166432951 -chrX 84483714 84483715 -chrX 98516735 98516736
--- a/package_rnachipintegrator_wrapper.sh Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -#!/bin/sh -# -# Package RnaChipIntegrator files into tgz file for upload to -# Galaxy toolshed -# -VERSION=$(grep "@VERSION@" rnachipintegrator_macros.xml | cut -d'>' -f2 | cut -d'<' -f1) -TGZ=rnachipintegrator-${VERSION}.tgz -if [ -f $TGZ ] ; then - echo $TGZ: already exists, please remove >&2 - exit 1 -fi -tar cvzf $TGZ \ - README.rst \ - rnachipintegrator_macros.xml \ - rnachipintegrator_wrapper.xml \ - rnachipintegrator_canonical_genes.xml \ - rnachipintegrator_wrapper.sh \ - tool_dependencies.xml \ - data_manager \ - data_manager_conf.xml \ - tool-data \ - tool_data_table_conf.xml.sample \ - test-data \ - --exclude=*~ -if [ -f $TGZ ] ; then - echo Created $TGZ -else - echo Failed to created $TGZ >&2 - exit 1 -fi -## -#
--- a/run_planemo_tests.sh Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,43 +0,0 @@ -#!/bin/bash -# -# Install dependencies and set up environment for -# rnachipintegrator tool, then run tests using planemo -# -# Note that any arguments supplied to the script are -# passed directly to the "planemo test..." invocation -# -# e.g. --install_galaxy (to get planemo to create a -# Galaxy instance to run tests) -# -# --galaxy_root DIR (to run tests using existing -# Galaxy instance) -# -# List of dependencies -TOOL_DEPENDENCIES="rnachipintegrator/1.0.0 - xlsxwriter/0.8.4" -# Where to find them -TOOL_DEPENDENCIES_DIR=$(pwd)/test.tool_dependencies.rnachipintegrator -if [ ! -d $TOOL_DEPENDENCIES_DIR ] ; then - echo WARNING $TOOL_DEPENDENCIES_DIR not found >&2 - echo Creating tool dependencies dir - mkdir -p $TOOL_DEPENDENCIES_DIR - echo Installing tool dependencies - $(dirname $0)/install_tool_deps.sh $TOOL_DEPENDENCIES_DIR -fi -# Load dependencies -for dep in $TOOL_DEPENDENCIES ; do - env_file=$TOOL_DEPENDENCIES_DIR/$dep/env.sh - if [ -e $env_file ] ; then - . $env_file - else - echo ERROR no env.sh file found for $dep >&2 - exit 1 - fi -done -# Run the planemo tests -planemo test $@ \ - $(dirname $0)/rnachipintegrator_wrapper.xml \ - $(dirname $0)/rnachipintegrator_canonical_genes.xml \ - $(dirname $0)/data_manager/data_manager_rnachipintegrator_fetch_canonical_genes.xml -## -#
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/RnaChipIntegrator/ChangeLog Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,250 +0,0 @@ -2016-02-24 Peter Briggs <peter.briggs@manchester.ac.uk> - - * Version 1.0.0 - - Complete reimplementation of RnaChipIntegrator to unify internal - algorithms, simplify usage and substantially update the - documentation. - - Installs using 'pip'; can be obtained directly from PyPI using - 'pip install RnaChipIntegrator'. - - Executable now installs as 'RnaChipIntegrator' (i.e. no '.py' - extension) - - Documentation now available via ReadTheDocs: - http://rnachipintegrator.readthedocs.org/en/latest/ - - No distinction is now made between 'summits' and 'peaks'; the - same algorithm is applied in each case. - - The program always finds the nearest genes to each peak, and - vice versa. The same distance cutoff and maximum number of hits - are applied to both and can be specified using the --cutoff and - --number options. - - By default all pairs within the cut-off distance are reported - unless the user explicitly restricts this to a subset by - specifying the --number option (i.e. --number now turned off - by default). - - By default nearest distances between peaks and gene are - calculated from the TSS of the feature to whichever of the peak - edges are closer; alternatively distances can be calculated - between the nearest pair of peak/gene edges by specifying the - --edge=both option. - - Any differential expression flags in the input genes file - are ignored unless the --only-DE option is specified, in which - case only the differentially expressed genes are considered - in the analyses. - - By default each peak/gene pair is reported on a separate - line; the --compact option reports all nearest gene/peaks - on a single line of output. - - New 'direction' field in output indicates whether hits are - up- or downstream from reference. - - Specify arbitrary columns from input peaks file using new - --peak_cols options to set chromosome, start and end. - - Output file names now end with 'gene-centric' and 'peak-centric'. - - Excel output is only produced if the --xlsx option is specified; - spreadsheets are now output in XLSX format (instead of XLS). - - Summary output is only produced if --summary is specified. - - The 'rearrange_columns.py' utility has been dropped. - -2016-02-18 Peter Briggs <peter.briggs@manchester.ac.uk> - - * Version 0.5.0-alpha.8 - - Fix typo in XLSX 'notes' sheet. - -2016-02-03 Peter Briggs <peter.briggs@manchester.ac.uk> - - * Version 0.5.0-alpha.7 - - Update --xls option to --xlsx and generate XLSX files - (instead of XLS); as XLSX has much greater limits on - the number of rows and columns allowed in a worksheet - this should address previous problems with having data - split over multiple sheets. - - Correct headers and placeholders now output when using - --compact option when --number is not specified. - - Pre-existing output files are explicitly removed before - analysis is run (rather than relying on overwrite). - -2016-01-29 Peter Briggs <peter.briggs@manchester.ac.uk> - - * Version 0.5.0-alpha.6 - - Fix broken --xls option (crashed program if specified). - -2016-01-29 Peter Briggs <peter.briggs@manchester.ac.uk> - - * Version 0.5.0-alpha.5 - - Rename 'feature' to 'gene' in program output, documentation etc - NB this doesn't affect the program function. - - By default all pairs within the cut-off distance are reported - unless the user explicitly restricts this to a subset by - specifying the --number option (i.e. --number now turned off - by default). - - Output file names changed to 'feature-centric' and 'peak-centric'. - - Options are grouped into subsets when displayed by -h/--help. - - Parameter defaults are also given in the documentation. - - Peaks in the input have 'start' and 'end' positions which - aren't at least 1bp apart cause the program to raise an error. - -2015-12-01 Peter Briggs <peter.briggs@manchester.ac.uk> - - * Version 0.5.0-alpha.4 - - Fix the broken --promoter_region option which was being ignored. - -2015-12-20 Peter Briggs <peter.briggs@manchester.ac.uk> - - * Version 0.5.0-alpha.3 - - --compact now only changes the output format from "multi-line" - (i.e. one hit pair per line) to "single-line" (i.e. all hits on - the same line). The same fields are reported in both modes. - - The explanatory text for the dist_closest field has been updated - to make it clearer what this means. - -2015-10-28 Peter Briggs <peter.briggs@manchester.ac.uk> - - * Version 0.5.0-alpha.2 - - Executable now installs as 'RnaChipIntegrator' (i.e. no '.py' - extension) - - Specify feature type (e.g. 'gene', 'transcript' etc) to be used - in output using --feature option. - - New 'direction' field in output indicates whether hits are - up- or downstream from reference. - - Specify arbitrary columns from input peaks file using new - --peak_cols options to set chromosome, start and end. - - --pad option is automatically implied by the --compact option - (i.e. single line output is always padded). - -2015-09-01 Peter Briggs <peter.briggs@manchester.ac.uk> - - * Version 0.5.0-alpha.1 - - Complete reimplementation of RnaChipIntegrator to unify internal - algorithms, simplify usage and substantially update the - documentation. - - No distinction is now made between 'summits' and 'peaks'; the - same algorithm is applied in each case. - - The program always finds the nearest features to each peak, and - vice versa. The same distance cutoff and maximum number of hits - are applied to both and can be specified using the --cutoff and - --number options. - - By default nearest distances between peaks and features are - calculated from the TSS of the feature to whichever of the peak - edges are closer; alternatively distances can be calculated - between the nearest pair of peak/feature edges by specifying the - --edge=both option. - - Any differential expression flags in the input features file - are ignored unless the --only-DE option is specified, in which - case only the differentially expressed features are considered - in the analyses. - - By default each peak/feature pair is reported on a separate - line; the --compact option reports all nearest features/peaks - on a single line of output. - - Excel output is only produced if the --xls option is specified; - summary output is only produced if --summary is specified. - - The 'rearrange_columns.py' utility has been dropped. - -2015-06-10 Peter Briggs <peter.briggs@manchester.ac.uk> - - * Version 0.4.4 - - Use /usr/bin/env rather than /bin/env to invoke Python interpreter - in RnaChipIntegrator.py (was broken for e.g. Ubuntu linux). - -2014-05-08 Peter Briggs <peter.briggs@manchester.ac.uk> - - * Version 0.4.3 - - Update --pad output so that requested number of lines appears for - peaks even when there are no hits, and "empty" lines contain the - chromosome, start and end positions for the peak in question. - -2014-05-02 Peter Briggs <peter.briggs@manchester.ac.uk> - - * Version 0.4.2 - - Truncate worksheet titles if they exceed maximum length as defined by - the spreadsheet writing libraries. - -2014-01-20 Peter Briggs <peter.briggs@manchester.ac.uk> - - * Version 0.4.1 - - Add '--pad' option: for 'NearestTranscriptsToPeakEdge' and - 'NearestTSSToPeakEdge' analyses, where necessary adds blank lines to - output files and spreadsheet so that each reported peak has the same - number of lines associated regardless of the number of hits. - - * Version 0.4.0 - - Fixed bug in overlap determination, which manifested when a gene was on - the negative strand *and* was also wider than the peak. In those cases - the start and end of the gene were being assigned incorrectly way around. - - (The bug didn't affect results for other genes on the negative strand - which were narrower than the peak.) - - Note that this bug would have a similar effect on determining whether a - peak was within the promoter region of a gene on the negative strand. - However the lists of nearest genes/peaks were not affected and the results - should otherwise have been correct. - -2012-02-16 Peter Briggs <peter.briggs@manchester.ac.uk> - - * Version 0.3.3 - - Added explanatory text to the "notes" page of the output XLS spreadsheet - and standardised naming of output files to match XLS page titles. - - Minor updates to READMEs/documentation. - -2012-01-27 Peter Briggs <peter.briggs@manchester.ac.uk> - - * Version 0.3.2 - - Output files now use "<Rna-Seq-file>_vs_<ChIP-Seq-file>" as the default - basename (unless overridden by the --project option). - - Added example data files in new "examples" directory. - -2012-01-20 Peter Briggs <peter.briggs@manchester.ac.uk> - - * Version 0.3.1 - - Added setup.py into an installable Python package. - - Updated documentation. - -2012-01-05 Peter Briggs <peter.briggs@manchester.ac.uk> - - * Version 0.3.0 - - Rename "ID" column to "geneID" (using "ID" has the potential to clash with - other programs where this is a reserved word). - - Various improvements to some of the column descriptions on the "notes" page - of the output XLS file. - - In all analyses, now only use those genes flagged as differentially expressed - (use all if no flag was specified on the input gene data). - -2011-12-19 Peter Briggs <peter.briggs@manchester.ac.uk> - - * Version 0.2.0 - - Only performs analyses which are appropriate for the supplied ChIP peak - data i.e. ignore "region"-based analyses if ChIP data are summits, or - summit-based analyses if data are regions. - -2011-12-08 Peter Briggs <peter.briggs@manchester.man.ac.uk> - - * Version 0.1.4 - - Program will stop if it encounters any 'bad' lines in the RNA-seq/transcipt - input data, with the exception of the first line (which is treated as a - header and skipped if it contains bad data). - - New option --no-xls: suppresses output of XLS spreadsheet. - -2011-12-07 Peter Briggs <peter.briggs@manchester.man.ac.uk> - - * Version 0.1.3 - - Skip input transcripts where 'start' position is higher than 'end'. - - In output spreadsheet, splits the lists of "transcripts inbetween" across - multiple columns in the "TSSToSummits" sheet if they exceed 250 - characters, and creates multiple sheets for result sets that exceed 65536 - rows. - -2011-12-05 Peter Briggs <peter.briggs@manchester.man.ac.uk> - - * Version 0.1.2 - - Fixed failure when using with Python 2.4 (optparse.OptionParser "epilog" - argument is unsupported) - -2011-11-24 Peter Briggs <peter.briggs@manchester.ac.uk> - - * Version 0.1.1 - - Updated to use optparse library to process command line arguments, and - substantially expanded help text (available using -h or --help option). - -2011-11-21 Peter Briggs <peter.briggs@manchester.ac.uk> - - * Version 0.1.0 - - Baseline version of RnaChIPIntegrator.py. - -
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/RnaChipIntegrator/INSTALL Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -Installing RnaChipIntegrator -============================ - -Installing the latest version -***************************** - -The recommended method is to install the latest version of the program -directly from the Python Package Index (PyPI) using:: - - pip install RnaChipIntegrator - -You may need to have root privileges to install to the system -directories, in which case preface this command with ``sudo`` i.e.:: - - sudo pip install RnaChipIntegrator - -Alternatively you can use Python's ``virtualenv`` mechanism to install -a non-root version (this example creates one under ``.venv``):: - - virtualenv .venv; . .venv/bin/activate - pip install RnaChipIntegrator - -Installing older versions -************************* - -All versions of the program can be found via: - - * https://github.com/fls-bioinformatics-core/RnaChipIntegrator/releases - -To install a specific version of the program download the ``.tar.gz`` or -``.zip`` file from the above site and install using one of the ``pip`` -recipes above, for example:: - - pip install RnaChipIntegrator-0.4.4.tar.gz - -Installing directly from GitHub (advanced users/developers) -*********************************************************** - -``pip`` can be used to install directly from GitHub:: - - pip install git+https://github.com/fls-bioinformatics-core/RnaChipIntegrator - -To install a specific version (e.g. ``v0.5.0``):: - - pip install git+https://github.com/fls-bioinformatics-core/RnaChipIntegrator@v0.5.0 - -To install the ``devel`` branch:: - - pip install git+https://github.com/fls-bioinformatics-core/RnaChipIntegrator@devel - -Uninstalling RnaChipIntegrator -============================== - -To remove the program do:: - - pip uninstall RnaChipIntegrator -
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/RnaChipIntegrator/LICENSE Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,201 +0,0 @@ - The Artistic License 2.0 - - Copyright (c) 2000-2006, The Perl Foundation. - - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -Preamble - -This license establishes the terms under which a given free software -Package may be copied, modified, distributed, and/or redistributed. -The intent is that the Copyright Holder maintains some artistic -control over the development of that Package while still keeping the -Package available as open source and free software. - -You are always permitted to make arrangements wholly outside of this -license directly with the Copyright Holder of a given Package. If the -terms of this license do not permit the full use that you propose to -make of the Package, you should contact the Copyright Holder and seek -a different licensing arrangement. - -Definitions - - "Copyright Holder" means the individual(s) or organization(s) - named in the copyright notice for the entire Package. - - "Contributor" means any party that has contributed code or other - material to the Package, in accordance with the Copyright Holder's - procedures. - - "You" and "your" means any person who would like to copy, - distribute, or modify the Package. - - "Package" means the collection of files distributed by the - Copyright Holder, and derivatives of that collection and/or of - those files. A given Package may consist of either the Standard - Version, or a Modified Version. - - "Distribute" means providing a copy of the Package or making it - accessible to anyone else, or in the case of a company or - organization, to others outside of your company or organization. - - "Distributor Fee" means any fee that you charge for Distributing - this Package or providing support for this Package to another - party. It does not mean licensing fees. - - "Standard Version" refers to the Package if it has not been - modified, or has been modified only in ways explicitly requested - by the Copyright Holder. - - "Modified Version" means the Package, if it has been changed, and - such changes were not explicitly requested by the Copyright - Holder. - - "Original License" means this Artistic License as Distributed with - the Standard Version of the Package, in its current version or as - it may be modified by The Perl Foundation in the future. - - "Source" form means the source code, documentation source, and - configuration files for the Package. - - "Compiled" form means the compiled bytecode, object code, binary, - or any other form resulting from mechanical transformation or - translation of the Source form. - - -Permission for Use and Modification Without Distribution - -(1) You are permitted to use the Standard Version and create and use -Modified Versions for any purpose without restriction, provided that -you do not Distribute the Modified Version. - - -Permissions for Redistribution of the Standard Version - -(2) You may Distribute verbatim copies of the Source form of the -Standard Version of this Package in any medium without restriction, -either gratis or for a Distributor Fee, provided that you duplicate -all of the original copyright notices and associated disclaimers. At -your discretion, such verbatim copies may or may not include a -Compiled form of the Package. - -(3) You may apply any bug fixes, portability changes, and other -modifications made available from the Copyright Holder. The resulting -Package will still be considered the Standard Version, and as such -will be subject to the Original License. - - -Distribution of Modified Versions of the Package as Source - -(4) You may Distribute your Modified Version as Source (either gratis -or for a Distributor Fee, and with or without a Compiled form of the -Modified Version) provided that you clearly document how it differs -from the Standard Version, including, but not limited to, documenting -any non-standard features, executables, or modules, and provided that -you do at least ONE of the following: - - (a) make the Modified Version available to the Copyright Holder - of the Standard Version, under the Original License, so that the - Copyright Holder may include your modifications in the Standard - Version. - - (b) ensure that installation of your Modified Version does not - prevent the user installing or running the Standard Version. In - addition, the Modified Version must bear a name that is different - from the name of the Standard Version. - - (c) allow anyone who receives a copy of the Modified Version to - make the Source form of the Modified Version available to others - under - - (i) the Original License or - - (ii) a license that permits the licensee to freely copy, - modify and redistribute the Modified Version using the same - licensing terms that apply to the copy that the licensee - received, and requires that the Source form of the Modified - Version, and of any works derived from it, be made freely - available in that license fees are prohibited but Distributor - Fees are allowed. - - -Distribution of Compiled Forms of the Standard Version -or Modified Versions without the Source - -(5) You may Distribute Compiled forms of the Standard Version without -the Source, provided that you include complete instructions on how to -get the Source of the Standard Version. Such instructions must be -valid at the time of your distribution. If these instructions, at any -time while you are carrying out such distribution, become invalid, you -must provide new instructions on demand or cease further distribution. -If you provide valid instructions or cease distribution within thirty -days after you become aware that the instructions are invalid, then -you do not forfeit any of your rights under this license. - -(6) You may Distribute a Modified Version in Compiled form without -the Source, provided that you comply with Section 4 with respect to -the Source of the Modified Version. - - -Aggregating or Linking the Package - -(7) You may aggregate the Package (either the Standard Version or -Modified Version) with other packages and Distribute the resulting -aggregation provided that you do not charge a licensing fee for the -Package. Distributor Fees are permitted, and licensing fees for other -components in the aggregation are permitted. The terms of this license -apply to the use and Distribution of the Standard or Modified Versions -as included in the aggregation. - -(8) You are permitted to link Modified and Standard Versions with -other works, to embed the Package in a larger work of your own, or to -build stand-alone binary or bytecode versions of applications that -include the Package, and Distribute the result without restriction, -provided the result does not expose a direct interface to the Package. - - -Items That are Not Considered Part of a Modified Version - -(9) Works (including, but not limited to, modules and scripts) that -merely extend or make use of the Package, do not, by themselves, cause -the Package to be a Modified Version. In addition, such works are not -considered parts of the Package itself, and are not subject to the -terms of this license. - - -General Provisions - -(10) Any use, modification, and distribution of the Standard or -Modified Versions is governed by this Artistic License. By using, -modifying or distributing the Package, you accept this license. Do not -use, modify, or distribute the Package, if you do not accept this -license. - -(11) If your Modified Version has been derived from a Modified -Version made by someone other than you, you are nevertheless required -to ensure that your Modified Version complies with the requirements of -this license. - -(12) This license does not grant you the right to use any trademark, -service mark, tradename, or logo of the Copyright Holder. - -(13) This license includes the non-exclusive, worldwide, -free-of-charge patent license to make, have made, use, offer to sell, -sell, import and otherwise transfer the Package with respect to any -patent claims licensable by the Copyright Holder that are necessarily -infringed by the Package. If you institute patent litigation -(including a cross-claim or counterclaim) against any party alleging -that the Package constitutes direct or contributory patent -infringement, then this Artistic License to you shall terminate on the -date that such litigation is filed. - -(14) Disclaimer of Warranty: -THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS -IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED -WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR -NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL -LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL -BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL -DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF -ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/RnaChipIntegrator/README.rst Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,93 +0,0 @@ -RnaChipIntegrator: analysis of genes with peak data -=================================================== - -.. image:: https://readthedocs.org/projects/rnachipintegrator/badge/?version=latest - :target: https://rnachipintegrator.readthedocs.org - -.. image:: https://travis-ci.org/fls-bioinformatics-core/RnaChipIntegrator.png?branch=master - :target: https://travis-ci.org/fls-bioinformatics-core/RnaChipIntegrator - -``RnaChipIntegrator`` is a utility that performs integrated analyses -of 'gene' data (a set of genes or other genomic features) with 'peak' -data (a set of regions, for example ChIP peaks) to identify the genes -nearest to each peak, and vice versa. - -The program was originally written specifically for ChIP-Seq and RNA-Seq -data but works equally well for ChIP-chip and microarray expression data, -and can also be used to integrate any set of genomic features (e.g. -canonical genes, CpG islands) with peak data. - -Quick Start -*********** - -Install the latest version of the program from the Python Package Index -(PyPI):: - - pip install RnaChipIntegrator - -The simplest use of the program is:: - - RnaChipIntegrator GENES PEAKS - -where ``GENES`` and ``PEAKS`` are tab-delimited files containing the -'gene' and 'peak' data respectively. - -This will output two files with the nearest genes for each peak -("peak-centric" analysis), and the nearest peaks for each gene -("gene-centric" analysis). - -Full documentation can be found at ReadTheDocs: - - * http://rnachipintegrator.readthedocs.org/en/latest/ - -See the ``INSTALL`` file for complete installation instructions. - -Developers -********** - -The source code for the development version of the program is hosted -on GitHub in the ``devel`` branch: - - * https://github.com/fls-bioinformatics-core/RnaChipIntegrator/tree/devel - -and can be installed directly from GitHub using ``pip``:: - - pip install git+https://github.com/fls-bioinformatics-core/RnaChipIntegrator.git@devel - -The program depends on the Python ``xlwt``, ``xlrd`` and ``xlutils`` -libraries, which should be installed automatically if using ``pip``. - -Documentation based on ``sphinx`` is available under the ``docs`` directory. - -To build do either:: - - python setup.py sphinx_build - -or:: - - cd docs - make html - -both of which create the documentation in the ``docs/_build`` subdirectory. - -Running Tests -************* - -The Python unit tests can be run using:: - - python setup.py test - -Note that this requires the ``nose`` package. - -Examples -******** - -Example data files can be found in the ``examples`` subdirectory, which -can be used as input to the program for test or demonstration purposes; see -the ``README`` file in the same directory for more information. - -Licensing -********* - -This software is licensed under the Artistic License 2.0; see the ``LICENSE`` -document.
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/bin/RnaChipIntegrator Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,10 +0,0 @@ -#!/home/pjb/virtual-envs/planemo/bin/python -# EASY-INSTALL-ENTRY-SCRIPT: 'RnaChipIntegrator==1.0.0','console_scripts','RnaChipIntegrator' -__requires__ = 'RnaChipIntegrator==1.0.0' -import sys -from pkg_resources import load_entry_point - -if __name__ == '__main__': - sys.exit( - load_entry_point('RnaChipIntegrator==1.0.0', 'console_scripts', 'RnaChipIntegrator')() - )
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/bin/vba_extract.py Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,68 +0,0 @@ -#!/home/pjb/virtual-envs/planemo/bin/python - -############################################################################## -# -# vba_extract - A simple utility to extract a vbaProject.bin binary from an -# Excel 2007+ xlsm file for insertion into an XlsxWriter file. -# -# Copyright 2013-2016, John McNamara, jmcnamara@cpan.org -# -import sys -import shutil -from zipfile import ZipFile -from zipfile import BadZipfile - -# The VBA project file we want to extract. -vba_filename = 'vbaProject.bin' - -# Get the xlsm file name from the commandline. -if len(sys.argv) > 1: - xlsm_file = sys.argv[1] -else: - print("\nUtility to extract a vbaProject.bin binary from an Excel 2007+ " - "xlsm macro file for insertion into an XlsxWriter file." - "\n" - "See: http://xlsxwriter.readthedocs.org/working_with_macros.html\n" - "\n" - "Usage: vba_extract file.xlsm\n") - exit() - -try: - # Open the Excel xlsm file as a zip file. - xlsm_zip = ZipFile(xlsm_file, 'r') - - # Read the xl/vbaProject.bin file. - vba_data = xlsm_zip.read('xl/' + vba_filename) - - # Write the vba data to a local file. - vba_file = open(vba_filename, "wb") - vba_file.write(vba_data) - vba_file.close() - -except IOError: - # Use exc_info() for Python 2.5+ compatibility. - e = sys.exc_info()[1] - print("File error: %s" % str(e)) - exit() - -except KeyError: - # Usually when there isn't a xl/vbaProject.bin member in the file. - e = sys.exc_info()[1] - print("File error: %s" % str(e)) - print("File may not be an Excel xlsm macro file: '%s'" % xlsm_file) - exit() - -except BadZipfile: - # Usually if the file is an xls file and not an xlsm file. - e = sys.exc_info()[1] - print("File error: %s: '%s'" % (str(e), xlsm_file)) - print("File may not be an Excel xlsm macro file.") - exit() - -except: - # Catch any other exceptions. - e = sys.exc_info()[1] - print("File error: %s" % str(e)) - exit() - -print("Extracted: %s" % vba_filename)
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/env.sh Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,6 +0,0 @@ -#!/bin/sh -# Source this to setup rnachipintegrator/1.0.0 -echo Setting up RnaChipIntegrator 1.0.0 -export PATH=/home/pjb/projects/galaxy-tools-update-rnachipintegrator/rnachipintegrator/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/bin:$PATH -export PYTHONPATH=/home/pjb/projects/galaxy-tools-update-rnachipintegrator/rnachipintegrator/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages:$PYTHONPATH -#
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/RnaChipIntegrator-1.0.0-py2.7.egg-info/PKG-INFO Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,22 +0,0 @@ -Metadata-Version: 1.1 -Name: RnaChipIntegrator -Version: 1.0.0 -Summary: Analyse genes against peak data, and vice versa -Home-page: https://github.com/fls-bioinformatics-core/RnaChipIntegrator -Author: Peter Briggs -Author-email: peter.briggs@manchester.ac.uk -License: Artistic License -Download-URL: https://github.com/fls-bioinformatics-core/RnaChipIntegrator/archive/v1.0.0.tar.gz -Description: UNKNOWN -Keywords: RnaChipIntegrator -Platform: UNKNOWN -Classifier: Development Status :: 3 - Alpha -Classifier: Intended Audience :: Science/Research -Classifier: Environment :: Console -Classifier: License :: OSI Approved :: Artistic License -Classifier: Operating System :: POSIX -Classifier: Topic :: Scientific/Engineering :: Bio-Informatics -Classifier: Natural Language :: English -Classifier: Programming Language :: Python :: 2 -Classifier: Programming Language :: Python :: 2.6 -Classifier: Programming Language :: Python :: 2.7
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/RnaChipIntegrator-1.0.0-py2.7.egg-info/SOURCES.txt Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,28 +0,0 @@ -ChangeLog -INSTALL -LICENSE -MANIFEST.in -README.rst -setup.cfg -setup.py -RnaChipIntegrator.egg-info/PKG-INFO -RnaChipIntegrator.egg-info/SOURCES.txt -RnaChipIntegrator.egg-info/dependency_links.txt -RnaChipIntegrator.egg-info/entry_points.txt -RnaChipIntegrator.egg-info/not-zip-safe -RnaChipIntegrator.egg-info/requires.txt -RnaChipIntegrator.egg-info/top_level.txt -rnachipintegrator/Features.py -rnachipintegrator/Peaks.py -rnachipintegrator/__init__.py -rnachipintegrator/analysis.py -rnachipintegrator/cli.py -rnachipintegrator/distances.py -rnachipintegrator/output.py -rnachipintegrator/utils.py -rnachipintegrator/xls_output.py -test/test_Features.py -test/test_Peaks.py -test/test_analysis.py -test/test_distances.py -test/test_output.py \ No newline at end of file
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/RnaChipIntegrator-1.0.0-py2.7.egg-info/dependency_links.txt Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/RnaChipIntegrator-1.0.0-py2.7.egg-info/entry_points.txt Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3 +0,0 @@ -[console_scripts] -RnaChipIntegrator = rnachipintegrator.cli:main -
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/RnaChipIntegrator-1.0.0-py2.7.egg-info/installed-files.txt Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -../rnachipintegrator/Peaks.py -../rnachipintegrator/xls_output.py -../rnachipintegrator/distances.py -../rnachipintegrator/cli.py -../rnachipintegrator/output.py -../rnachipintegrator/utils.py -../rnachipintegrator/analysis.py -../rnachipintegrator/Features.py -../rnachipintegrator/__init__.py -../rnachipintegrator/Peaks.pyc -../rnachipintegrator/xls_output.pyc -../rnachipintegrator/distances.pyc -../rnachipintegrator/cli.pyc -../rnachipintegrator/output.pyc -../rnachipintegrator/utils.pyc -../rnachipintegrator/analysis.pyc -../rnachipintegrator/Features.pyc -../rnachipintegrator/__init__.pyc -../../../../RnaChipIntegrator/README.rst -../../../../RnaChipIntegrator/LICENSE -../../../../RnaChipIntegrator/INSTALL -../../../../RnaChipIntegrator/ChangeLog -./ -entry_points.txt -requires.txt -dependency_links.txt -PKG-INFO -top_level.txt -SOURCES.txt -not-zip-safe -../../../../bin/RnaChipIntegrator
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/RnaChipIntegrator-1.0.0-py2.7.egg-info/not-zip-safe Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/RnaChipIntegrator-1.0.0-py2.7.egg-info/requires.txt Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -xlsxwriter >= 0.8.4
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/RnaChipIntegrator-1.0.0-py2.7.egg-info/top_level.txt Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -rnachipintegrator
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/XlsxWriter-0.8.4-py2.7.egg-info/PKG-INFO Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,87 +0,0 @@ -Metadata-Version: 1.1 -Name: XlsxWriter -Version: 0.8.4 -Summary: A Python module for creating Excel XLSX files. -Home-page: https://github.com/jmcnamara/XlsxWriter -Author: John McNamara -Author-email: jmcnamara@cpan.org -License: BSD -Description: XlsxWriter - ========== - - **XlsxWriter** is a Python module for writing files in the Excel 2007+ XLSX - file format. - - XlsxWriter can be used to write text, numbers, formulas and hyperlinks to - multiple worksheets and it supports features such as formatting and many more, - including: - - * 100% compatible Excel XLSX files. - * Full formatting. - * Merged cells. - * Defined names. - * Charts. - * Autofilters. - * Data validation and drop down lists. - * Conditional formatting. - * Worksheet PNG/JPEG images. - * Rich multi-format strings. - * Cell comments. - * Integration with Pandas. - * Textboxes. - * Memory optimization mode for writing large files. - - It supports Python 2.5, 2.6, 2.7, 3.1, 3.2, 3.3, 3.4, 3.5, Jython and PyPy and - uses standard libraries only. - - Here is a simple example: - - .. code-block:: python - - import xlsxwriter - - - # Create an new Excel file and add a worksheet. - workbook = xlsxwriter.Workbook('demo.xlsx') - worksheet = workbook.add_worksheet() - - # Widen the first column to make the text clearer. - worksheet.set_column('A:A', 20) - - # Add a bold format to use to highlight cells. - bold = workbook.add_format({'bold': True}) - - # Write some simple text. - worksheet.write('A1', 'Hello') - - # Text with formatting. - worksheet.write('A2', 'World', bold) - - # Write some numbers, with row/column notation. - worksheet.write(2, 0, 123) - worksheet.write(3, 0, 123.456) - - # Insert an image. - worksheet.insert_image('B5', 'logo.png') - - workbook.close() - - .. image:: https://raw.github.com/jmcnamara/XlsxWriter/master/dev/docs/source/_images/demo.png - - See the full documentation at: http://xlsxwriter.readthedocs.org - - Release notes: http://xlsxwriter.readthedocs.org/changes.html - - -Platform: UNKNOWN -Classifier: Development Status :: 5 - Production/Stable -Classifier: License :: OSI Approved :: BSD License -Classifier: Programming Language :: Python -Classifier: Programming Language :: Python :: 2.5 -Classifier: Programming Language :: Python :: 2.6 -Classifier: Programming Language :: Python :: 2.7 -Classifier: Programming Language :: Python :: 3.1 -Classifier: Programming Language :: Python :: 3.2 -Classifier: Programming Language :: Python :: 3.3 -Classifier: Programming Language :: Python :: 3.4 -Classifier: Programming Language :: Python :: 3.5
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/XlsxWriter-0.8.4-py2.7.egg-info/SOURCES.txt Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,126 +0,0 @@ -Changes -LICENSE.txt -MANIFEST.in -README.rst -setup.cfg -setup.py -XlsxWriter.egg-info/PKG-INFO -XlsxWriter.egg-info/SOURCES.txt -XlsxWriter.egg-info/dependency_links.txt -XlsxWriter.egg-info/top_level.txt -docs/readme.html -docs/_static/basic.css -docs/_static/default.css -docs/_static/hello01.png -docs/_static/logo.png -docs/_static/pygments.css -examples/array_formula.py -examples/autofilter.py -examples/autofilter_data.txt -examples/cell_indentation.py -examples/chart.py -examples/chart_area.py -examples/chart_bar.py -examples/chart_clustered.py -examples/chart_column.py -examples/chart_combined.py -examples/chart_data_table.py -examples/chart_data_tools.py -examples/chart_date_axis.py -examples/chart_doughnut.py -examples/chart_gradient.py -examples/chart_line.py -examples/chart_pareto.py -examples/chart_pattern.py -examples/chart_pie.py -examples/chart_radar.py -examples/chart_scatter.py -examples/chart_secondary_axis.py -examples/chart_stock.py -examples/chart_styles.py -examples/chartsheet.py -examples/comments1.py -examples/comments2.py -examples/conditional_format.py -examples/context_manager.py -examples/data_validate.py -examples/datetimes.py -examples/defined_name.py -examples/demo.py -examples/diagonal_border.py -examples/doc_properties.py -examples/headers_footers.py -examples/hello_world.py -examples/hide_row_col.py -examples/hide_sheet.py -examples/http_server_py2.py -examples/http_server_py3.py -examples/hyperlink.py -examples/images.py -examples/images_bytesio.py -examples/macros.py -examples/merge1.py -examples/merge_rich_string.py -examples/outline.py -examples/outline_collapsed.py -examples/pandas_chart.py -examples/pandas_chart_columns.py -examples/pandas_chart_line.py -examples/pandas_chart_stock.py -examples/pandas_column_formats.py -examples/pandas_conditional_format.py -examples/pandas_datetime.py -examples/pandas_simple.py -examples/panes.py -examples/rich_strings.py -examples/right_to_left.py -examples/sparklines1.py -examples/sparklines2.py -examples/tab_colors.py -examples/tables.py -examples/text_indent.py -examples/textbox.py -examples/tutorial1.py -examples/tutorial2.py -examples/tutorial3.py -examples/unicode_polish_utf8.py -examples/unicode_polish_utf8.txt -examples/unicode_python2.py -examples/unicode_python3.py -examples/unicode_shift_jis.py -examples/unicode_shift_jis.txt -examples/vbaProject.bin -examples/vba_extract.py -examples/worksheet_protection.py -xlsxwriter/__init__.py -xlsxwriter/app.py -xlsxwriter/chart.py -xlsxwriter/chart_area.py -xlsxwriter/chart_bar.py -xlsxwriter/chart_column.py -xlsxwriter/chart_doughnut.py -xlsxwriter/chart_line.py -xlsxwriter/chart_pie.py -xlsxwriter/chart_radar.py -xlsxwriter/chart_scatter.py -xlsxwriter/chart_stock.py -xlsxwriter/chartsheet.py -xlsxwriter/comments.py -xlsxwriter/compat_collections.py -xlsxwriter/compatibility.py -xlsxwriter/contenttypes.py -xlsxwriter/core.py -xlsxwriter/drawing.py -xlsxwriter/format.py -xlsxwriter/packager.py -xlsxwriter/relationships.py -xlsxwriter/shape.py -xlsxwriter/sharedstrings.py -xlsxwriter/styles.py -xlsxwriter/table.py -xlsxwriter/theme.py -xlsxwriter/utility.py -xlsxwriter/vml.py -xlsxwriter/workbook.py -xlsxwriter/worksheet.py -xlsxwriter/xmlwriter.py \ No newline at end of file
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/XlsxWriter-0.8.4-py2.7.egg-info/dependency_links.txt Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/XlsxWriter-0.8.4-py2.7.egg-info/installed-files.txt Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,70 +0,0 @@ -../xlsxwriter/__init__.py -../xlsxwriter/styles.py -../xlsxwriter/vml.py -../xlsxwriter/worksheet.py -../xlsxwriter/chart_bar.py -../xlsxwriter/format.py -../xlsxwriter/compatibility.py -../xlsxwriter/app.py -../xlsxwriter/packager.py -../xlsxwriter/chart.py -../xlsxwriter/chartsheet.py -../xlsxwriter/compat_collections.py -../xlsxwriter/relationships.py -../xlsxwriter/chart_area.py -../xlsxwriter/chart_scatter.py -../xlsxwriter/contenttypes.py -../xlsxwriter/utility.py -../xlsxwriter/chart_pie.py -../xlsxwriter/table.py -../xlsxwriter/sharedstrings.py -../xlsxwriter/workbook.py -../xlsxwriter/chart_stock.py -../xlsxwriter/chart_doughnut.py -../xlsxwriter/theme.py -../xlsxwriter/xmlwriter.py -../xlsxwriter/shape.py -../xlsxwriter/chart_column.py -../xlsxwriter/drawing.py -../xlsxwriter/chart_line.py -../xlsxwriter/core.py -../xlsxwriter/chart_radar.py -../xlsxwriter/comments.py -../xlsxwriter/__init__.pyc -../xlsxwriter/styles.pyc -../xlsxwriter/vml.pyc -../xlsxwriter/worksheet.pyc -../xlsxwriter/chart_bar.pyc -../xlsxwriter/format.pyc -../xlsxwriter/compatibility.pyc -../xlsxwriter/app.pyc -../xlsxwriter/packager.pyc -../xlsxwriter/chart.pyc -../xlsxwriter/chartsheet.pyc -../xlsxwriter/compat_collections.pyc -../xlsxwriter/relationships.pyc -../xlsxwriter/chart_area.pyc -../xlsxwriter/chart_scatter.pyc -../xlsxwriter/contenttypes.pyc -../xlsxwriter/utility.pyc -../xlsxwriter/chart_pie.pyc -../xlsxwriter/table.pyc -../xlsxwriter/sharedstrings.pyc -../xlsxwriter/workbook.pyc -../xlsxwriter/chart_stock.pyc -../xlsxwriter/chart_doughnut.pyc -../xlsxwriter/theme.pyc -../xlsxwriter/xmlwriter.pyc -../xlsxwriter/shape.pyc -../xlsxwriter/chart_column.pyc -../xlsxwriter/drawing.pyc -../xlsxwriter/chart_line.pyc -../xlsxwriter/core.pyc -../xlsxwriter/chart_radar.pyc -../xlsxwriter/comments.pyc -./ -dependency_links.txt -PKG-INFO -SOURCES.txt -top_level.txt -../../../../bin/vba_extract.py
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/XlsxWriter-0.8.4-py2.7.egg-info/top_level.txt Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -xlsxwriter
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/rnachipintegrator/Features.py Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,492 +0,0 @@ -#!/bin/env python -# -# Features.py: classes for handling feature data -# Copyright (C) University of Manchester 2011-15 Peter Briggs, Leo Zeef -# & Ian Donaldson -# -""" -Features.py - -Classes for handling feature data. - -""" - -import logging -from distances import closestDistanceToRegion -from utils import make_errline - -class FeatureSet: - """Class for storing a set of features - - RNA-seq features consists of genes/transcripts/isomers, which - are stored individually in Feature objects. This class is a - container for a collection of Feature objects and provides - methods to operate on the collection, by creating subsets by - filtering, and sorting the features based on various criteria. - - """ - def __init__(self,features_file=None,features_list=None): - """Create a new FeatureSet instance - - Raises an exception if there are errors in the input file data - (non-numeric fields for start/end positions, end positions - occurring before start positions, or illegal strand values). - - Arguments: - features_file (str): (optional) the name of an input - file to read the feature data from - features_list (list): (optional) list of Feature objects - to populate the FeatureSet with - - """ - self.features = [] - if features_file: - self.loadFeaturesFromFile(features_file) - elif features_list: - for feature in features_list: - self.addFeature(feature) - - def loadFeaturesFromFile(self,features_file): - """Read features from a file and populate the object - - Arguments: - features_file: the name of the input file to read features from. - - """ - # Local flags etc - line_index = 0 - critical_error = False - # Read in data from file - fp = open(features_file,'rU') - for line in fp: - # Increment index - line_index += 1 - # Skip lines starting with # - if line.startswith('#'): - logging.debug("Feature file: skipped line: %s" % line.strip()) - continue - # Lines are tab-delimited and have at least 5 columns: - # ID chr start end strand - items = line.strip().split('\t') - if len(items) < 5: - logging.warning("Feature file: skipped line: %s" % line.strip()) - logging.warning("Insufficient number of fields (%d)" % \ - len(items)) - continue - # Check line is valid i.e. start and stop should be - # numbers, strand should be + or - - problem_fields = [] - if not items[2].isdigit(): problem_fields.append(2) - if not items[3].isdigit(): problem_fields.append(3) - if not (items[4] == '+' or items[4] == '-'): problem_fields.append(4) - if problem_fields: - # If this is the first line then assume it's a header and ignore - if line_index == 1: - logging.warning("%s: first line ignored as header: %s" % - (features_file,line.strip())) - else: - # Indicate problem field(s) - logging.error("%s: critical error line %d: bad values:" % - (features_file,line_index)) - logging.error("%s" % line.strip()) - logging.error("%s" % make_errline(line.strip(),problem_fields)) - # This is a critical error: update flag - critical_error = True - # Continue to next line - continue - elif int(items[2]) >= int(items[3]): - # Start position is same or higher than end - logging.error("%s: critical error line %d: 'end' comes before 'start':" % - (features_file,line_index)) - logging.error("%s" % line.strip()) - logging.error("%s" % make_errline(line.strip(),(2,3))) - # This is a critical error: update flag but continue reading - critical_error = True - continue - # Store in a new Feature object - feature = Feature(items[0], - items[1], - items[2], - items[3], - items[4]) - # Additional flag - if len(items) >= 6: - # Is column 6 a flag? - try: - flag_value = int(items[5]) - if flag_value != 0 and flag_value != 1: - flag_value = None - except ValueError: - flag_value = None - # Store value - feature.flag = flag_value - - # Store data - self.features.append(feature) - fp.close() - # Deal with postponed critical errors - if critical_error: - raise Exception, "critical error(s) in '%s'" % features_file - # Return a reference to this object - return self - - def addFeature(self,feature): - """Append a feature to the FeatureSet object - - Arguments: - feature: a Feature instance. - - """ - self.features.append(feature) - - def filterByChr(self,matchChr): - """Return a subset of features filtered by specified chromosome name - - Returns a new FeatureSet object containing only the data from - the current object which matches the specified criteria. - - """ - # Make a new (empty) FeatureSet object - feature_subset = FeatureSet() - # Populate with only the matching features - for feature in self.features: - if feature.chrom == matchChr: - feature_subset.addFeature(feature) - return feature_subset - - def filterByStrand(self,matchStrand): - """Return a subset of features filtered by specified strand - - Returns a new FeatureSet object containing only the data from - the current object which matches the specified criteria. - - """ - # Make a new (empty) FeatureSet object - feature_subset = FeatureSet() - # Populate with only the matching features - for feature in self.features: - if feature.strand == matchStrand: - feature_subset.addFeature(feature) - return feature_subset - - def filterByFlag(self,matchFlag): - """Return a subset of features filtered by flag value - - Returns a new FeatureSet object containing only the features from - the current object which matches the specified criteria. - - Note that if there is no flag (the "isFlagged()" function returns - False) then an empty set will be returned. - - """ - # Make a new (empty) RNASeqData object - feature_subset = FeatureSet() - # Populate with only the matching features - for feature in self.features: - if feature.flag == matchFlag: - feature_subset.addFeature(feature) - return feature_subset - - def filterByTSS(self,limit1,limit2,exclude_limits=False): - """Return a subset of features filtered by TSS position - - Returns a new FeatureSet object containing only the features - from the current object where the TSS positions fall within a - region defined by upper and lower limits. - - limits can be supplied in either order (i.e. highest/lowest - or lowest/highest). - - If exclude_limits is False (the default) then TSS positions - that fall exactly on one of the boundaries are counted as - being within the region; if it is True then these TSS - positions will not be considered to lie inside the region. - - """ - # Sort out upper and lower limits - if limit1 > limit2: - upper,lower = limit1,limit2 - else: - upper,lower = limit2,limit1 - # Make a new (empty) FeatureSet object - feature_subset = FeatureSet() - # Populate with only the matching features - for feature in self.features: - TSS = feature.getTSS() - if exclude_limits: - if lower < TSS and TSS < upper: - feature_subset.addFeature(feature) - else: - if lower <= TSS and TSS <= upper: - feature_subset.addFeature(feature) - return feature_subset - - def sortByDistanceFrom(self,position): - """Sort the features into order based on distance from a position - - Sorts the features into order of absolute distance of - their TSS to the specified position (closest first). - - Note that this operates on the current object. - - """ - self.features = sorted(self.features, - key=lambda record: - abs(record.getTSS()-position)) - return self - - def sortByClosestEdgeTo(self,position1,position2=None): - """Sort the features into order based on closest edge (TSS or TES) - - Sorts the features into order of smallest absolute distance - to the specified position (closest first), considering both TSS - and TES, using the getClosestEdgeDistanceTo method of the - Feature class. - - Note that this operates on the current object. - - """ - self.features = sorted(self.features, - key=lambda record: - record.getClosestEdgeDistanceTo(position1, - position2)) - return self - - def sortByClosestTSSTo(self,position1,position2=None): - """Sort the features into order based on closest edge to TSS - - Sorts the features into order of smallest absolute distance - to the specified position (closest first) to the TSS position, - using the getClosestTSSDistanceTo method of the Feature class. - - Note that this operates on the current object. - - """ - self.features = sorted(self.features, - key=lambda record: - record.getClosestTSSDistanceTo(position1, - position2)) - return self - - def isFlagged(self): - """Check whether feature data includes flags - - Checks whether all the Feature records also have a valid flag - associated with them - if yes then returns True (indicating the - dataset as a whole is flagged), otherwise returns False. - - """ - # Check all data and look for any None flags - for feature in self.features: - if feature.flag is None: - return False - # All flags valid - return True - - def __iter__(self): - return iter(self.features) - - def __getitem__(self,key): - try: - start = key.start - stop = key.stop - step = key.step - slice_ = FeatureSet() - for feature in self.features[start:stop:step]: - slice_.addFeature(feature) - return slice_ - except AttributeError: - return self.features[key] - - def __len__(self): - return len(self.features) - - def __eq__(self,other): - if len(self) != len(other): - return False - for f1,f2 in zip(self,other): - if f1 != f2: - return False - return True - - def __ne__(self,other): - if len(self) != len(other): - return True - for f1,f2 in zip(self,other): - if f1 != f2: - return True - return False - -class Feature: - """Class for storing an 'feature' (gene/transcript/isomer) - - Access the data for the feature using the object's properties: - - id - chrom - start - end - strand - tss - tes - - There are also convenience methods (getTSS, getTES, getPromoterRegion) - and methods for calculating various distances. - - """ - def __init__(self,feature_id,chrom,start,end,strand): - self.id = feature_id - self.chrom = chrom - self.start = int(start) - self.end = int(end) - self.strand = strand - self.flag = None - # Set the TSS and TES - if self.strand == '+': - self.tss = self.start - self.tes = self.end - elif self.strand == '-': - self.tss = self.end - self.tes = self.start - else: - raise Exception("Bad strand: '%s'" % self.strand) - - def __repr__(self): - items = [self.id, - self.chrom, - str(self.start), - str(self.end), - self.strand] - if self.flag != None: - items.append(str(self.flag)) - return '\t'.join(items) - - def __eq__(self,other): - return \ - (self.id == other.id) and \ - (self.strand == other.strand) and \ - (self.start == other.start) and \ - (self.end == other.end) - - def __ne__(self,other): - return \ - (self.id != other.id) or \ - (self.strand != other.strand) or \ - (self.start != other.start) or \ - (self.end != other.end) - - def getTSS(self): - """Return the TSS coordinate - - TTS (transcription start site) is the start position for a +ve - strand, or end for a -ve strand. - - This is a wrapper for accessing the 'tss' property. - - """ - return self.tss - - def getTES(self): - """Return the TES coordinate - - TES (transcription end site) is the start position for a +ve - strand, or end for a -ve strand. - - This is a wrapper for accessing the 'tes' property. - - """ - return self.tes - - def containsPosition(self,coordinate): - """Check whether a coordinate is within the gene coordinates - - Returns True if coordinate lies within start and end, False - otherwise. - - """ - return (self.start <= coordinate and coordinate <= self.end) - - def getClosestTSSDistanceTo(self,position1,position2=None, - zero_inside_region=False): - """Return distance from TSS to a coordinate or region - - For a single specified position, return the absolute distance - between the position and the TSS. - - If a second position is given (specifying a region) then return - smallest absolute distance of (TSS,position1) and (TSS,position2). - - By default there is no special treatment when the TSS lies inside - the region specified by two positions; to return zero distance in - these cases, set the 'zero_inside_region' argument to True. - - """ - return closestDistanceToRegion(self.getTSS(), - position1,position2, - zero_inside_region) - - def getClosestTESDistanceTo(self,position1,position2=None, - zero_inside_region=False): - """Return distance from TES to a coordinate or region - - For a single specified position, return the absolute distance - between the position and the TES. - - If a second position is given (specifying a region) then return - smallest absolute distance of (TES,position1) and (TES,position2). - - By default there is no special treatment when the TES lies inside - the region specified by two positions; to return zero distance in - these cases, set the 'zero_inside_region' argument to True. - - """ - return closestDistanceToRegion(self.getTES(), - position1,position2, - zero_inside_region) - - def getClosestEdgeDistanceTo(self,position1,position2=None, - zero_inside_region=False): - """Return closest edge distance to a coordinate or region - - For a single specified position, the closest edge is whichever - of the TSS or TES is nearest (smallest absolute distance) from - that position i.e. the smallest distance of (TSS,position) and - (TES,position). - - If a second position is given (specifying a region) then - the closest edge is whichever of the TSS/TES is closest to - either position1 or position2 i.e. the smallest distance of - (TSS,position1), (TES,position1), (TSS,position2) and - (TES,position2). - - By default there is no special treatment when either the TSS - or TES lie inside the region specified by two positions; to - set this to zero, set the 'zero_inside_region' argument to - True. - - """ - return min(self.getClosestTSSDistanceTo(position1, - position2, - zero_inside_region), - self.getClosestTESDistanceTo(position1, - position2, - zero_inside_region)) - - def getPromoterRegion(self,to_TSS,from_TSS): - """Return the coordinates of the promoter region - - The promoter region is a region of coordinates around the - TSS of a gene, defined by the supplied distances 'to_TSS' - (the distance downstream from the TSS) and 'from_TSS' (the - distance upstream from the TSS). - - Returns a tuple containing the start and end coordinates - defining the promoter region. - - """ - if self.strand == '+': - return (self.getTSS() - to_TSS, - self.getTSS() + from_TSS) - else: - return (self.getTSS() + to_TSS, - self.getTSS() - from_TSS)
Binary file test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/rnachipintegrator/Features.pyc has changed
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/rnachipintegrator/Peaks.py Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,303 +0,0 @@ -#!/bin/env python -# -# Peaks.py: classes for handling peak data -# Copyright (C) University of Manchester 2011-16 Peter Briggs, Leo Zeef -# & Ian Donaldson -# -""" -Peaks.py - -Classes for handling peak data - -""" - -import logging -from utils import make_errline - -class PeakSet: - """Class for storing a set of peaks - - ChIP-seq data consists of ChIP peak information, each of which are - stored individually in Peak objects. This class is a container for - a collection of Peak objects and provides methods to operate on the - collection, by creating subsets by filtering, and sorting the data - based on various criteria. - - """ - def __init__(self,peaks_file=None,peaks_list=None, - columns=None): - """Create a new PeakSet instance - - Arguments: - peaks_file (str): (optional) the name of an input file - to read the peak data from - peaks_list (list): (optional) list of Peak objects to - populate the PeakSet with - columns (tuple): (optional) tuple with 3 integers - indicating which columns to use from the input - ``peaks_file`` for the chromosome, start and end - columns (if not the first three columns). The - columns should be numbered from 1. - - """ - self.peaks = [] - if peaks_file: - self.loadPeaksFromFile(peaks_file,columns=columns) - elif peaks_list: - for peak in peaks_list: - self.addPeak(peak) - - def loadPeaksFromFile(self,peaks_file,columns=None): - """Read peaks data from a file and populate the object - - Arguments: - peaks_file (str): the name of the input file to read peaks - data from. - columns (tuple): (optional) tuple with 3 integers - indicating which columns to use from the input - ``peaks_file`` for the chromosome, start and end - columns (if not the first three columns). The - columns should be numbered from 1. - - """ - # Handle columns - if columns is None: - columns = (1,2,3) - chrom = columns[0] - 1 - start = columns[1] - 1 - end = columns[2] - 1 - ncols = max(chrom,start,end) + 1 - # Read in from file - fp = open(peaks_file,'rU') - for line in fp: - # Skip lines that start with a # symbol - if line.startswith('#'): - logging.debug("Peaks file: skipped line: %s" % line.strip()) - continue - # Lines are tab-delimited - items = line.strip().split('\t') - if len(items) < ncols: - logging.warning("Peaks file: skipped line: %s" % line.strip()) - logging.warning("Insufficient number of fields (%d): need at " - "least %d" % (len(items),ncols)) - continue - # Check that items in 'start' and 'end' columns are digits - if not items[start].isdigit() or not items[end].isdigit(): - logging.warning("Peaks file: skipped line: %s" % line.strip()) - # Indicate problem field(s) - bad_fields = [] - for i in (start,end): - if not items[i].isdigit(): - bad_fields.append(i) - logging.warning(" %s" % \ - make_errline(line,bad_fields)) - logging.warning("Expected integer at indicated positions") - continue - # Store in a new Peak object - try: - peak = Peak(items[chrom], - items[start], - items[end]) - except PeakRangeError,ex: - logging.error("Peaks file: bad line: %s" % line.strip()) - logging.error(" %s" % - make_errline(line,(start,end))) - logging.error("%s" % ex) - raise ex - self.peaks.append(peak) - fp.close() - # Return a reference to this object - return self - - def addPeak(self,peak): - """Append a Peak to the PeakSet object - - Arguments: - peak: a Peak instance. - - """ - self.peaks.append(peak) - - def isSummit(self): - """Check whether peak set consists of summits only - - Checks the difference between start and end positions for - stored Peak objects - if all differences are equal to 1 then - returns True, indicating that the peaks are described as - summits; otherwise returns False. - - """ - for peak in self.peaks: - if (peak.end - peak.start) > 1: - return False - return True - - def filterByChr(self,matchChr): - """Return a subset of data filtered by specified chromosome name - - Returns a new PeakSet object containing only the data from - the current object which matches the specified criteria. - - """ - # Make a new (empty) PeakSet object - peaks_subset = PeakSet() - # Populate with only the matching data lines - for peak in self.peaks: - if peak.chrom == matchChr: - peaks_subset.addPeak(peak) - return peaks_subset - - def filterByPosition(self,limit1,limit2,exclude_limits=False): - """Return a subset of peaks filtered by position - - Returns a new PeakSet object containing only the data from - the current object where the start positions fall within a - region defined by upper and lower limits. - - limits can be supplied in either order (i.e. highest/lowest - or lowest/highest). - - If exclude_limits is False (the default) then start positions - that fall exactly on one of the boundaries are counted as - being within the region; if it is True then these start - positions will not be considered to lie inside the region. - - """ - # Sort out upper and lower limits - if limit1 > limit2: - upper,lower = limit1,limit2 - else: - upper,lower = limit2,limit1 - # Make a new (empty) PeakSet object - peaks_subset = PeakSet() - # Populate with only the matching data lines - for peak in self.peaks: - position = peak.start - if exclude_limits: - if lower < position and position < upper: - peaks_subset.addPeak(peak) - else: - if lower <= position and position <= upper: - peaks_subset.addPeak(peak) - return peaks_subset - - def sortByDistanceFrom(self,position): - """Sort the peaks into order based on distance from a position - - Sorts the Peak objects into order of absolute distance of - their start to the specified position (closest first). - - Note that this operates on the current object. - - """ - self.peaks = sorted(self.peaks, - key=lambda record: min(abs(record.start - position), - abs(record.end - position))) - return self - - def __iter__(self): - return iter(self.peaks) - - def __getitem__(self,key): - try: - start = key.start - stop = key.stop - step = key.step - slice_ = PeakSet() - for peak in self.peaks[start:stop:step]: - slice_.addPeak(peak) - return slice_ - except AttributeError: - return self.peaks[key] - - def __len__(self): - return len(self.peaks) - - def __eq__(self,other): - if len(self) != len(other): - return False - for p1,p2 in zip(self,other): - if p1 != p2: - return False - return True - - def __ne__(self,other): - if len(self) != len(other): - return True - for p1,p2 in zip(self,other): - if p1 != p2: - return True - return False - -class Peak: - """Class for storing a peak - - Access the data from the line using the object's properties: - - chrom - start - end - - There are also convenience methods (e.g. insideRegion). - - Raises a PeakRangeError exception if the peak start and end - positions don't differ by at least 1bp. - - """ - def __init__(self,chrom,start,end): - self.chrom = chrom.strip('"\'') - self.start = int(start) - self.end = int(end) - if self.start == self.end: - raise PeakRangeError("'start' and 'end' positions should " - "differ by at least 1bp") - elif self.end < self.start: - raise PeakRangeError("'end' position must not come before " - "'start'") - - def __repr__(self): - return "%s\t%s\t%s" % (self.chrom, - self.start, - self.end) - - def __eq__(self,other): - return \ - (self.chrom == other.chrom) and \ - (self.start == other.start) and \ - (self.end == other.end) - - def __ne__(self,other): - return \ - (self.chrom != other.chrom) or \ - (self.start != other.start) or \ - (self.end != other.end) - - def insideRegion(self,limit1,limit2,exclude_limits=False): - """Check if the peak is contained within a defined region - - The region is defined by upper and lower limits: if the start - position lies within these limits then return True, otherwise - return false. - - limits can be supplied in either order (i.e. highest/lowest - or lowest/highest). - - By default if the start position lies exactly on one of the - limits then it is also counted as being within the region; - if exclude_limits is set to True then the limits are not - considered part of the region. - - """ - if limit1 > limit2: - upper,lower = limit1,limit2 - else: - upper,lower = limit2,limit1 - if not exclude_limits: - return (lower <= self.start and self.start <= upper) - else: - return (lower < self.start and self.start < upper) - -class PeakRangeError(ValueError): - """ - Class for raising errors with peak start/end ranges - """
Binary file test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/rnachipintegrator/Peaks.pyc has changed
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/rnachipintegrator/__init__.py Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -# Current version of the library -__version__ = '1.0.0' - -def get_version(): - """Returns a string with the current version of the library (e.g., "0.2.0") - - """ - return __version__
Binary file test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/rnachipintegrator/__init__.pyc has changed
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/rnachipintegrator/analysis.py Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,194 +0,0 @@ -#!/bin/env python -# -# analysis.py: analyses of peaks vs features and vice versa -# Copyright (C) University of Manchester 2011-15 Peter Briggs, Leo Zeef -# & Ian Donaldson -# -""" -analysis.py - -Functions for analysing peaks against features, and vice versa: - -- find_nearest_features -- find_nearest_peaks - -""" -import os -import logging -import distances -from Features import FeatureSet -from Peaks import PeakSet - -####################################################################### -# Analysis functions -####################################################################### - -# NB there are a few potential optimisations, e.g.: -# - caching the results of filtering on chromosomes -# - improving the search over distances e.g. by sorting once on -# distances from an arbitrary zero, and then calculating distances -# between things with reference to that? - -def find_nearest_features(peaks,features,distance=None,tss_only=False, - only_differentially_expressed=False): - """ - Locate nearest features for each peak - - Arguments: - features (FeatureList): list of features - peaks (PeakList): list of peaks - distance (int): optional cut-off distance to apply - max_closest (int): optional maximum number of peaks - to find per feature - tss_only (bool): only consider distances from the - feature TSS (default is to consider distances from - both the TSS and TES) - only_differentially_expressed (bool): only consider - features that are flagged as differentially expressed - pad (bool): add extra 'None' items to output - FeatureSet so that it contains max_closest results - - Yields: - tuple: Peak object and a FeatureSet object with the - nearest features, for each peak in the input PeakSet - - """ - # Find nearest features to each peak - for peak in peaks: - # Only consider features on same chromosome - feature_list = features.filterByChr(peak.chrom) - # Differentially-expressed features only? - if only_differentially_expressed: - feature_list = feature_list.filterByFlag(1) - if tss_only: - sort_features_by_tss_distances(peak,feature_list) - else: - sort_features_by_edge_distances(peak,feature_list) - # Apply distance cut-off - if distance is not None: - closest = FeatureSet() - for feature in feature_list: - if tss_only: - if distances.distance_tss(peak,feature) > distance: - break - else: - if distances.distance_closest_edge(peak,feature) > distance: - break - closest.addFeature(feature) - feature_list = closest - # Return at least one (null) result - if not feature_list: - feature_list.addFeature(None) - # Return result - yield (peak,feature_list) - -def find_nearest_peaks(features,peaks,distance=None,tss_only=False, - only_differentially_expressed=False): - """ - Locate nearest peaks for each feature - - Arguments: - features (FeatureList): list of features - peaks (PeakList): list of peaks - distance (int): optional cut-off distance to apply - tss_only (bool): only consider distances from the - feature TSS (default is to consider distances from - both the TSS and TES) - only_differentially_expressed (bool): only consider - features that are flagged as differentially expressed - - Yields: - tuple: Feature object and a PeakSet object with the - nearest peaks, for each feature in the input - FeatureSet - - """ - # Reduce to set of differentially expressed features - if only_differentially_expressed: - features = features.filterByFlag(1) - # Find nearest peaks for each feature - for feature in features: - # Only consider peaks on same chromosome - peak_list = peaks.filterByChr(feature.chrom) - # Sort into distance order - if tss_only: - sort_peaks_by_tss_distances(feature,peak_list) - else: - sort_peaks_by_edge_distances(feature,peak_list) - # Apply distance cut-off - if distance is not None: - closest = PeakSet() - for peak in peak_list: - if distances.distance_tss(peak,feature) > distance: - break - closest.addPeak(peak) - peak_list = closest - # Return at least one (null) result - if not peak_list: - peak_list.addPeak(None) - # Return results - yield (feature,peak_list) - -def sort_features_by_edge_distances(peak,features): - """ - Sort features by edge-to-edge distances to a peak - - Arguments: - peak (Peak): peak instance - features (FeatureSet): set of features that will - be sorted into order according to the smallest - distance of their edges from the edges of the - peak. The sorting is done in place. - - """ - features.features = sorted(features.features, - key = lambda f: - distances.edge_distances(peak,f)) - -def sort_features_by_tss_distances(peak,features): - """ - Sort features by TSS-to-edge distances to a peak - - Arguments: - peak (Peak): peak instance - features (FeatureSet): set of features that will - be sorted into order according to the smallest - distance of their TSS positions to the edges of - the peak. The sorting is done in place. - - """ - features.features = sorted(features.features, - key = lambda f: - distances.tss_distances(peak,f)) - -def sort_peaks_by_edge_distances(feature,peaks): - """ - Sort peaks by edge-to-edge distances to a feature - - Arguments: - feature (Feature): feature instance - peaks (PeakSet): set of peaks that will be - sorted into order according to the smallest - distance of their edges from the edges of the - feature. The sorting is done in place. - - """ - peaks.peaks = sorted(peaks.peaks, - key = lambda p: - distances.edge_distances(p,feature)) - -def sort_peaks_by_tss_distances(feature,peaks): - """ - Sort peaks by edge-to-TSS distances to a feature - - Arguments: - feature (Feature): feature instance - peaks (PeakSet): set of peaks that will be - sorted into order according to the smallest - distance of their edges from the TSS position - of the feature. The sorting is done in place. - - """ - peaks.peaks = sorted(peaks.peaks, - key = lambda p: - distances.tss_distances(p,feature))
Binary file test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/rnachipintegrator/analysis.pyc has changed
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/rnachipintegrator/cli.py Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,410 +0,0 @@ -#!/usr/bin/env python -# -# RnaChipIntegrator.py: analyse genomic features (genes) with peak data -# Copyright (C) University of Manchester 2011-16 Peter Briggs, Leo Zeef -# & Ian Donaldson -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the Artistic License 2.0 (see the file LICENSE -# included with the distribution). -# -######################################################################## -# -# RnaChipIntegrator.py -# -######################################################################### - -""" -RnaChipIntegrator.py - -Analyse genomic features (genes) with peak data. - -""" - -####################################################################### -# Imports -####################################################################### - -import sys -import os -import optparse -import time,datetime -from .Features import FeatureSet -from .Peaks import PeakSet -import analysis -import output -import xls_output -import logging -logging.getLogger().setLevel(logging.WARNING) -logging.basicConfig(format='%(levelname)s: %(message)s') - -from . import get_version -__version__ = get_version() - -DEFAULT_FEATURE_TYPE = 'gene' - -####################################################################### -# Main program -####################################################################### - -def main(args=None): - """ - Implements the 'RnaChipIntegrator' CLI - - """ - - # Command line arguments - if args is None: - args = sys.argv[1:] - - # Defaults - promoter = (1000,100) - max_distance = 1000000 - - # Parse command line - p = optparse.OptionParser(usage="%prog [options] GENES PEAKS", - version="%prog "+__version__, - description= - "Analyse GENES (any set of genes or genomic " - "features) against PEAKS (a set of regions) " - "and report nearest genes to each peak (and " - "vice versa)") - - # Analysis options - analysis_opts = optparse.OptionGroup(p,"Analysis options") - analysis_opts.add_option('--cutoff',action='store',dest='max_distance', - type='int',default=max_distance, - help="Maximum distance allowed between peaks " - "and genes before being omitted from the " - "analyses (default %dbp; set to zero for no " - "cutoff)" % max_distance) - analysis_opts.add_option('--edge',action='store',dest="edge", - type="choice",choices=('tss','both'), - default='tss', - help="Gene edges to consider when calculating " - "distances between genes and peaks, either: " - "'tss' (default: only use gene TSS) or 'both' " - "(use whichever of TSS or TES gives shortest " - "distance)") - analysis_opts.add_option('--only-DE',action='store_true', - dest='only_diff_expressed',default=False, - help="Only use genes flagged as differentially " - "expressed in analyses (input gene data must " - "include DE flags)") - p.add_option_group(analysis_opts) - - # Reporting options - reporting_opts = optparse.OptionGroup(p,"Reporting options") - reporting_opts.add_option('--number',action='store',dest='max_closest', - type='int',default=None, - help="Filter results after applying --cutoff " - "to report only the nearest MAX_CLOSEST number " - "of pairs for each gene/peak from the analyses " - "(default is to report all results)") - reporting_opts.add_option('--promoter_region',action="store", - dest="promoter_region", - default="%d,%d" % promoter, - help="Define promoter region with respect to " - "gene TSS in the form UPSTREAM,DOWNSTREAM " - "(default -%d to %dbp of TSS)" % promoter) - p.add_option_group(reporting_opts) - - # Output options - output_opts = optparse.OptionGroup(p,"Output options") - output_opts.add_option('--name',action='store',dest='name',default=None, - help="Set basename for output files") - output_opts.add_option('--compact',action='store_true',dest='compact', - default=False, - help="Output all hits for each peak or gene on a " - "single line (cannot be used with --summary)") - output_opts.add_option('--summary',action='store_true',dest='summary', - default=False, - help="Output 'summary' for each analysis, " - "consisting of only the top hit for each peak or " - "gene (cannot be used with --compact)") - output_opts.add_option('--pad',action="store_true",dest="pad_output", - help="Where less than MAX_CLOSEST hits are found, " - "pad output with blanks to ensure that MAX_CLOSEST " - "hits are still reported (nb --pad is implied for " - "--compact)") - output_opts.add_option('--xlsx',action="store_true",dest="xlsx_output", - help="Output XLSX spreadsheet with results") - p.add_option_group(output_opts) - - # Advanced options - advanced_opts = optparse.OptionGroup(p,"Advanced options") - advanced_opts.add_option('--feature',action="store",dest="feature_type", - help="rename '%s' to FEATURE_TYPE in output (e.g. " - "'transcript' etc)" % DEFAULT_FEATURE_TYPE) - advanced_opts.add_option('--peak_cols',action="store",dest="peak_cols", - help="list of 3 column indices (e.g. '1,4,5') " - "indicating columns to use for chromosome, " - "start and end from the input peak file (if not " - "first three columns).") - p.add_option_group(advanced_opts) - - # Process command line - options,args = p.parse_args() - - # Input files - if len(args) != 2: - p.error("need to supply 2 files (genes and peaks)") - gene_file,peak_file = args - - # Report version and authors - p.print_version() - print - print "Find nearest peaks to genes (and vice versa)" - print - print "University of Manchester" - print "Faculty of Life Sciences" - print "Bioinformatics Core Facility" - print "Authors: Peter Briggs, Ian Donaldson and Leo Zeef" - print - print "If you use this program in your published work then please cite:" - print - print " Briggs PJ, Donaldson IJ, Zeef LAH. RnaChipIntegrator" - print " (version %s). Available at:" % __version__ - print " https://github.com/fls-bioinformatics-core/RnaChipIntegrator" - print - - # Promoter region - promoter = (abs(int(options.promoter_region.split(',')[0])), - abs(int(options.promoter_region.split(',')[1]))) - - # Reporting options - max_distance = options.max_distance - if max_distance <= 0: - max_distance = None - max_closest = options.max_closest - - # Gene edge to use - if options.edge == 'tss': - tss_only = True - else: - tss_only = False - - # Reporting formats - if options.compact: - mode = output.SINGLE_LINE - peak_fields = ('peak.chr','peak.start','peak.end', - 'list(feature.id,strand,TSS,TES,dist_closest,' - 'dist_TSS,dist_TES,direction,overlap_feature,' - 'overlap_promoter)') - gene_fields = ('feature.id','feature.chr','feature.start', - 'feature.end','feature.strand', - 'list(chr,start,end,dist_closest,dist_TSS,' - 'direction,in_the_feature)') - placeholder = '.' - if options.summary: - options.summary = False - logging.error("--summary option not compatible with --compact") - sys.exit(1) - else: - mode = output.MULTI_LINE - peak_fields = ('peak.chr','peak.start','peak.end', - 'feature.id','strand','TSS','TES', - 'dist_closest','dist_TSS','dist_TES', - 'direction','overlap_feature','overlap_promoter') - gene_fields = ('feature.id','feature.chr','feature.start', - 'feature.end','feature.strand', - 'chr','start','end','dist_closest','dist_TSS', - 'direction','in_the_feature') - placeholder = '---' - - # Feature type - if options.feature_type is None: - feature_type = 'gene' - else: - feature_type = options.feature_type - - # Columns to extract from input peaks file - if options.peak_cols is None: - peak_cols = (1,2,3) - else: - try: - peak_cols = tuple([int(x) - for x in options.peak_cols.split(',')]) - except Exception, ex: - p.error("Bad column assignment for --peak_cols") - - # Report settings - print "Input genes file: %s" % gene_file - print "Input peaks file: %s" % peak_file - print - print "Maximum cutoff distance: %d (bp)" % max_distance - print "Maximum no. of hits : %s" % ('All' if max_closest is None - else "%d" % max_closest) - print "Promoter region : -%d to %d (bp from TSS)" % promoter - print - if tss_only: - print "Distances will be calculated from gene TSS only" - else: - print "Distances will be calculated from nearest of gene TSS or TES" - print - print "Genomic features are '%ss'" % feature_type - print - - # Read in gene data - try: - genes = FeatureSet(gene_file) - except Exception, ex: - logging.critical("Failed to read in gene data: %s" % ex) - print "Please fix errors in input file before running again" - sys.exit(1) - if not len(genes): - logging.error("No gene data read in") - sys.exit(1) - print "%d gene records read in" % len(genes) - - # Differential expression handling - use_differentially_expressed = False - if genes.isFlagged(): - print "\tGene data include differential expression flag" - print "\t%d genes flagged as differentially expressed" % \ - len(genes.filterByFlag(1)) - if options.only_diff_expressed: - print - print "*** Only differentially expressed genes will used ***" - use_differentially_expressed = True - elif options.only_diff_expressed: - logging.error("--only-DE flag needs input genes flagged as " - "differentially expressed") - sys.exit(1) - print - - # Read in peak data - print "Using columns %s from peaks file as chrom, start, end" % \ - (peak_cols,) - try: - peaks = PeakSet(peak_file,columns=peak_cols) - except Exception,ex: - logging.critical("Failed to read peak data (%s)" % ex) - print "Please fix errors in input file before running again" - sys.exit(1) - if not len(peaks): - logging.error("No peak data read in") - sys.exit(1) - print "%d peak records read in" % len(peaks) - if peaks.isSummit(): - print "\tPeak data are summits" - else: - print "\tPeak data are regions" - print - - # Set up output files - if options.name is not None: - basename = options.name - else: - basename = os.path.splitext(os.path.basename(gene_file))[0] - peak_centric_out = basename+"_peak_centric.txt" - gene_centric_out = basename+"_gene_centric.txt" - if options.summary: - peak_centric_summary = basename+"_peak_centric_summary.txt" - gene_centric_summary = basename+"_gene_centric_summary.txt" - else: - peak_centric_summary = None - gene_centric_summary = None - if options.xlsx_output: - xlsx_out = basename+".xlsx" - else: - xlsx_out = None - - # Clean up any pre-existing output files that would otherwise - # be overwritten - print "Checking for pre-existing output files" - for f in (peak_centric_out,peak_centric_summary, - gene_centric_out,gene_centric_summary, - xlsx_out): - if f is not None and os.path.isfile(f): - print "\tRemoving %s" % f - os.remove(f) - print - - # Do the analyses - print "**** Peak-centric analysis: nearest genes to each peak ****" - reporter = output.AnalysisReportWriter(mode,peak_fields, - promoter_region=promoter, - null_placeholder=placeholder, - max_hits=max_closest, - pad=options.pad_output, - outfile=peak_centric_out, - summary=peak_centric_summary, - feature_type=feature_type) - for peak,nearest_genes in analysis.find_nearest_features( - peaks,genes,tss_only=tss_only,distance=max_distance, - only_differentially_expressed=use_differentially_expressed): - reporter.write_nearest_features(peak,nearest_genes) - reporter.close() - print "Results written to %s" % peak_centric_out - if peak_centric_summary: - print "Summary written to %s" % peak_centric_summary - print - - print "**** Gene-centric analysis: nearest peaks to each gene ****" - reporter = output.AnalysisReportWriter(mode,gene_fields, - null_placeholder=placeholder, - max_hits=max_closest, - pad=options.pad_output, - outfile=gene_centric_out, - summary=gene_centric_summary, - feature_type=feature_type) - for gene,nearest_peaks in analysis.find_nearest_peaks( - genes,peaks,tss_only=tss_only,distance=max_distance, - only_differentially_expressed=use_differentially_expressed): - reporter.write_nearest_peaks(gene,nearest_peaks) - reporter.close() - print "Results written to %s" % gene_centric_out - if gene_centric_summary: - print "Summary written to %s" % gene_centric_summary - print - - # Make XLSX file - if options.xlsx_output: - print "**** Writing XLSX file ****" - xlsx = xls_output.XLSX(xlsx_out,p.get_version(),feature_type) - # Write the settings - xlsx.append_to_notes("Input %ss file\t%s" % (feature_type, - gene_file)) - xlsx.append_to_notes("Input peaks file\t%s" % peak_file) - xlsx.append_to_notes("Maximum cutoff distance (bp)\t%d" % max_distance) - xlsx.append_to_notes("Maximum no. of hits to report\t%s" - % ('All' if max_closest is None - else "%d" % max_closest)) - xlsx.append_to_notes("Promoter region (bp from TSS)\t-%d to %d" % - promoter) - if tss_only: - xlsx.append_to_notes("Distances calculated from\tTSS only") - else: - xlsx.append_to_notes("Distances calculated from\tTSS or TES") - xlsx.append_to_notes("Only use differentially expressed %ss\t%s" % - (feature_type, - "Yes" if use_differentially_expressed else "No")) - # Add features to peaks - xlsx.write_peak_centric(peak_fields) - xlsx.add_result_sheet('Peak-centric',peak_centric_out) - if options.summary: - xlsx.append_to_notes("\n'Peak-centric (summary)' lists the 'top' " - "result (i.e. closest peak/%s pair) for each " - "peak" % feature_type) - xlsx.add_result_sheet('Peak-centric (summary)', - peak_centric_summary) - # Add peaks to features - xlsx.write_feature_centric(gene_fields) - xlsx.add_result_sheet('%s-centric' % feature_type.title(), - gene_centric_out) - if options.summary: - xlsx.append_to_notes("\n'%s-centric (summary)' lists the 'top' " - "result (i.e. closest %s/peak pair) for each " - "%s" % (feature_type.title(), - feature_type, - feature_type)) - xlsx.add_result_sheet('%s-centric (summary)' % - feature_type.title(), - gene_centric_summary) - xlsx.write() - print "Wrote %s" % xlsx_out - print - - # Finished - print "Done"
Binary file test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/rnachipintegrator/cli.pyc has changed
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/rnachipintegrator/distances.py Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,347 +0,0 @@ -#!/bin/env python -# -# distances.py: functions for determining distances and overlaps -# Copyright (C) University of Manchester 2011-15 Peter Briggs, Leo Zeef -# & Ian Donaldson -# -""" -distances.py - -Functions for determining distances and overlaps: - -- closestDistanceToRegion: distance from a reference position to a - coordinate or region -- regions_overlap: determine if two regions have any overlap -- GetNearestTranscriptToPeak: compare two transcripts against the same - region -- direction: indicate whether two regions are upstream, - downstream, or overlapping - -Also defines constants: - -- UPSTREAM -- DOWNSTREAM -- OVERLAP - -""" -# Module constants (used for 'direction' function) -UPSTREAM = -1 -DOWNSTREAM = 1 -OVERLAP = 0 - -def closestDistanceToRegion(reference,position1,position2=None, - zero_inside_region=False): - """Return distance from a reference position to a coordinate or region - - For a single specified position, return the absolute distance between - that position and the reference point. - - If a second position is given (specifying a region) then return the - smallest absolute distance of (reference,position1) and - (reference,position2). - - By default there is no special treatment when the reference lies inside - the region specified by two positions; to return zero distance in - these cases, set the 'zero_inside_region' argument to True. - """ - # Only one position given - if position2 is None: - return abs(reference - position1) - # Is point inside specified region? - if zero_inside_region: - if position1 < position2: - upper,lower = position2,position1 - else: - upper,lower = position1,position2 - if (lower < reference and reference < upper): - return 0 - # Outside specified region - return absolute distance - return min(abs(reference - position1),abs(reference - position2)) - -def regions_overlap(region1,region2): - """Determine if two regions have any overlap - - Returns True if any part of the first region overlaps any part of - the second region (including one region being completely inside the - other). - - Arguments: - region1: tuple of numbers representing the limits of the first - region, can be in any order e.g. (0,10) or (10,0) - region2: tuple of numbers representing the limits of the second - region. - - Returns: - True if there is overlap, False otherwise. - """ - # Widest region - if (abs(region1[0] - region1[1]) > abs(region2[0] - region2[1])): - wide,narrow = region1,region2 - else: - wide,narrow = region2,region1 - # Determine upper/lower limits of region #1 - if wide[0] < wide[1]: - lower,upper = wide[0],wide[1] - else: - lower,upper = wide[1],wide[0] - # Regions overlap if either start or end of region #2 lies - # within region #1 (or vice versa) - return ((lower <= narrow[0] and narrow[0] <= upper) or - (lower <= narrow[1] and narrow[1] <= upper)) - -def GetNearestTranscriptToPeak(rna_data1,rna_data2,chip_peak): - """Compare two RNA-seq transcripts against the same ChIP-seq peak. - - Given two RNASeqDataLine objects (one for each of the transcripts) - and a ChIPSeqDataLine object (for the ChIP peak), return the - transcript which lies closest (regardless of direction) to the ChIP - peak. - - Note: if the two transcripts are equidistant from the ChIP peak - then return the first one. - """ - - # Check that one or both are defined - if not rna_data1: - return rna_data2 - elif not rna_data2: - return rna_data1 - - # Get the distances from the peak - distance1 = rna_data1.getTSS() - chip_peak.start - distance2 = rna_data2.getTSS() - chip_peak.start - - # See which is closest - dist_diff = abs(distance2) - abs(distance1) - if dist_diff < 0: - # Transcript 2 is nearest - return rna_data2 - else: - # Transcript 1 is nearest - return rna_data1 - -def edge_distances(peak,feature): - """ - Return distances between peak and feature edges - - Arguments: - peak (Peak): peak instance - feature (Feature): feature instance - - Returns: - tuple: a pair of distances, the first being the - smallest distance between an edge of the peak - region and an edge of the feature region and - the second being the distance from the same peak - edge to the opposite feature edge. - Both distances are zero if the peak is entirely - contained within the feature (or vice versa). - If there is partial overlap then the smallest - distance is returned as zero, the second is - the amount of the peak that lies outside the - feature. - - """ - if ((peak.start >= feature.start and - peak.end <= feature.end) or - (feature.start >= peak.start and - feature.end <= peak.end)): - # Peak entirely contained in feature (or vice versa) - return (0,0) - # All possible distances - ds_fs = abs(peak.start - feature.start) - ds_fe = abs(peak.start - feature.end) - de_fs = abs(peak.end - feature.start) - de_fe = abs(peak.end - feature.end) - if peak.start >= feature.start and peak.start <= feature.end: - # Peak start inside feature: - # - # | PPPPPPP | - # |--------FFFFFFFFF---------| - # - # Return distances from peak end to feature end - return (0,de_fe) - if peak.end >= feature.start and peak.end <= feature.end: - # Peak end inside feature - # - # | PPPPPPP | - # |--------FFFFFFFFF---------| - # - # Return distances from peak start to feature start - return (0,ds_fs) - if ds_fe < de_fs: - # No overlap: peak start to feature end is smallest - # - # | PPPPPPP | - # |----FFFFFFFFF--------------| - # - return (ds_fe,ds_fs) - else: - # No overlap: peak end to feature start is smallest - # - # | PPPPPPP | - # |-------------FFFFFFFFF-----| - # - return (de_fs,de_fe) - -def tss_distances(peak,feature): - """ - Return distances between peak edges and feature TSS - - Arguments: - peak (Peak): peak instance - feature (Feature): feature instance - - Returns: - tuple: a pair of distances, the first being the - smallest distance between an edge of the peak - region to the TSS of the feature region, and - the second being the distance from the other peak - edge to the TSS. - If the TSS position is entirely contained within - the peak then the smallest distance is returned as - zero, the second is the average of the distances - to the two peak edges from the TSS. - - """ - # TSS is considered as a point - if (feature.tss >= peak.start and - feature.tss <= peak.end): - # TSS entirely contained in the peak - # Rank using the average distance of the peak - # edges from the TSS - return (0,(abs(feature.tss - peak.start) + - abs(feature.tss - peak.end))/2) - # Possible distances to TSS - d_tss = [abs(feature.tss - peak.start), - abs(feature.tss - peak.end)] - d_tss.sort() - return tuple(d_tss) - -def distance_closest_edge(peak,feature): - """ - Get distance from a peak to a feature - - Arguments: - peak (Peak): peak - feature (Feature): feature - - Returns: - int: Smallest absolute distance from the peak to - the feature. - - """ - return min(closestDistanceToRegion(peak.start, - feature.tss,feature.tes, - zero_inside_region=True), - closestDistanceToRegion(peak.end, - feature.tss,feature.tes, - zero_inside_region=True)) - -def distance_tss(peak,feature): - """ - Get distance from a peak to a feature TSS - - Arguments: - peak (Peak): peak - feature (Feature): feature - - Returns: - int: Smallest absolute distance from the peak to - the feature TSS. - - """ - return closestDistanceToRegion(feature.tss, - peak.start,peak.end, - zero_inside_region=True) - -def distance_tes(peak,feature): - """ - Get distance from a peak to a feature TES - - Arguments: - peak (Peak): peak - feature (Feature): feature - - Returns: - int: Smallest absolute distance from the peak to - the feature TES. - - """ - return closestDistanceToRegion(feature.tes, - peak.start,peak.end, - zero_inside_region=True) - -def direction(region1,region2,strand=None): - """ - Direction (up- or downstream) of one region relative to another - - Given two regions (either Peak or Feature instances), - determine the direction of the second region relative to - the first. - - For positive strand, 'upstream' means that the test region - occurs "before" the reference (i.e. has smaller coordinate - positions), 'downstream' indicates it occurs after. For the - negative strand the meaning is reversed. - - If region1 partially overlaps region2 then the upstream or - downstream position will still be determined. However if - one region wholly overlaps the other then 'overlap' will - be returned instead. - - Arguments: - region1 (Peak/Feature): reference region - region2 (Peak/Feature): region to get direction of - relative to region1 - strand (str): (optional) explicit strand direction - ('+' or '-'). - - Returns: - int: UPSTREAM, DOWNSTREAM or OVERLAP (module constants) - indicating direction of test region relative to - reference region. - - """ - # Get strandedness info - if strand is None: - try: - strand = region1.strand - except AttributeError: - try: - strand = region2.strand - except AttributeError: - strand = '+' - # Check for overlapping regions - if (region1.start >= region2.start and region1.end <= region2.end) or \ - (region2.start >= region1.start and region2.end <= region1.end): - return OVERLAP - if region2.start >= region1.start and region2.start <= region1.end: - # region2 start inside feature: - # - # | 2222222 | - # |--------111111111---------| - # - # Return distances from peak end to feature end - return (DOWNSTREAM if strand == '+' else UPSTREAM) - if region2.end >= region1.start and region2.end <= region1.end: - # region2 end inside region1 - # - # | 2222222 | - # |--------111111111---------| - # - return (UPSTREAM if strand == '+' else DOWNSTREAM) - if region1.end < region2.start: - # No overlap: peak start to feature end is smallest - # - # | 2222222 | - # |----111111111--------------| - # - return (DOWNSTREAM if strand == '+' else UPSTREAM) - else: - # No overlap: region2 is downstream of region1 - # - # | 2222222 | - # |-------------111111111-----| - # - return (UPSTREAM if strand == '+' else DOWNSTREAM)
Binary file test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/rnachipintegrator/distances.pyc has changed
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/rnachipintegrator/output.py Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,589 +0,0 @@ -#!/bin/env python -# -# output.py: functions for outputting analysis results -# Copyright (C) University of Manchester 2015 Peter Briggs, Leo Zeef -# & Ian Donaldson -# -""" -output.py - -Functions for outputing analysis results - -""" -import distances -from Peaks import Peak -import tempfile - -####################################################################### -# Constants -####################################################################### - -MULTI_LINE=0 -SINGLE_LINE=1 -FIELDS = { - 'chr': "chromosome", - 'start': "peak start position", - 'end': "peak end position", - 'id': "feature ID", - 'strand': "feature strand direction", - 'TSS': "feature TSS position", - 'TES': "feature TES position", - 'peak.chr': "chromosome of the peak", - 'peak.start': "peak start position", - 'peak.end': "peak end position", - 'feature.id': "feature ID", - 'feature.chr': "chromosome of the feature", - 'feature.start': "feature start position", - 'feature.end': "feature end position", - 'feature.TSS': "feature TSS position", - 'feature.TES': "feature TES position", - 'feature.strand': "feature strand direction", - 'dist_closest': "closest distance between peak and feature considering all edges (zero if there is overlap)", - 'dist_TSS': "distance between peak and feature TSS", - 'dist_TES': "distance between peak and feature TES", - 'overlap_feature': "1 if peak overlaps the feature, 0 if not", - 'overlap_promoter': "1 if peak overlaps the promoter region, 0 if not", - 'in_the_feature': "'YES' if peak overlaps the feature, 'NO' if not", - 'direction': "'U' if hit is upstream, 'D' if downstream, '.' if overlapped", - 'differentially_expressed': "1 if feature is differentially expressed, 0 if not", - 'order': "the 'order' of the feature/peak pair (e.g. '1 of 4')", - 'number_of_results': "number of hits being reported", -} - -####################################################################### -# Classes -####################################################################### - -class AnalysisReporter: - """ - Class to handle reporting of analysis results - - Once initialised the reporter can be used to generate 'reports' - of each peak along with the nearest features (using the - 'report_nearest_features' method) or for each feature along - with the nearest peaks (using 'report_nearest_peaks'). - - Output can be in either 'multi-line' (one line per result pair), - or 'single-line' format (one line containing all results). - - For each method a list of the fields to be reported can be - specified. Available fields are: - - - (peak.)chr: chromosome for the peak - - (peak.)start: peak start position - - (peak.)end: peak end position - - (feature.)id: feature ID - - feature.chr: chromosome for the feature - - feature.start: feature start position - - feature.end: feature end position - - (feature.)TSS: feature TSS - - (feature.)TES: feature TES - - (feature.)strand: feature strand - - dist_closest: closest distance between peak and feature - - dist_TSS: distance between peak and feature TSS - - dist_TES: distance between peak and feature TES - - overlap_feature: 'YES' if peak overlaps the feature, 'NO' if not - - overlap_promoter: 1 if peak overlaps the promoter region, 0 if not - - in_the_feature: synonym for 'overlap_feature' - - 'differentially_expressed': flag value for feature - - (In the field names above, the parts in (...) are optional e.g. - 'chr' == 'peak.chr' etc.) - - For multi-line output these additional fields are available: - - - order: the 'order' of the feature/peak pair (e.g. '1 of 4') - - For single-line output these additional fields are available: - - - number_of_results - - list(...): output all results (peaks or features, as - appropriate) - - For the 'list' options, the paranthese should enclose a list - of fields to output for each peak or feature in the list e.g. - 'list(chr,start,dist_closest)' or 'list(feature.id)'. - - The following fields have not been implemented: - - - features_inbetween - - """ - def __init__(self,mode,fields,promoter_region=None, - max_hits=None,pad=False, - null_placeholder='.', - feature_type=None): - """ - Create new AnalysisReporter instance - - Arguments: - mode (int): either SINGLE_LINE or MULTI_LINE - fields (list): list of fields to output - promoter_region (tuple): promoter region extent (optional) - max_hits (int): optional maximum number of hits to - report for each set of results - null_placeholder (str): placeholder to use in output for - fields which evaluate to 'null' - pad (bool): add extra 'None' items to output hits to - pad out to max_closest results (n.b. padding is - always performed in SINGLE_LINE mode) - feature_type (str): if not 'None' then replace 'feature' - with 'feature_type' (e.g. 'gene', 'transcript' etc) in - the output - - """ - self._fields = fields - self._mode = mode - self._promoter_region = promoter_region - self._placeholder = null_placeholder - self._max_hits = max_hits - self._pad = pad - self._context_peak = None - self._context_feature = None - self._is_features = None - self._feature_type = feature_type - self._max_pairs = 0 - - def report_nearest(self,reference,results): - """ - Return details of nearest objects to a reference - - This is a generic reporting method which can handle - either nearest features to a reference peak (in which - case ``reference`` should be a Peak and ``results`` - the corresponding FeatureSet), or nearest peaks to a - reference Feature (when ``reference`` is a Feature and - ``results`` is a PeakSet). - - Arguments: - reference (Object): reference object (i.e. - Peak or Feature of interest) - results (Object): list of corresponding results - i.e. FeatureSet (for reference Peak) or - PeakSet (reference Feature) - - Yields: - string: line(s) of text reporting the results - - """ - # Initialise and set the context - if isinstance(reference,Peak): - self._context_peak = reference - self._is_features = True - else: - self._context_feature = reference - self._is_features = False - is_features = self._is_features - # Store largest number of pairs reported - self._max_pairs = max(self._max_pairs,len(results)) - # Reduce to maximum number of hits - if self._max_hits is not None: - results = results[:self._max_hits] - else: - results = results[:] - nresults = len(results) - # Pad with null results - if self._mode == SINGLE_LINE or self._pad: - while len(results) < self._max_hits: - if is_features: - results.addFeature(None) - else: - results.addPeak(None) - # Write the results - if self._mode == SINGLE_LINE: - # Report everything on a single line - line = [] - for field in self._fields: - if field == 'number_of_results': - value = nresults - elif field.startswith('list('): - # Extract the subfields - subfields = field[:-1].split('(')[1].split(',') - # Report list of features - value = [] - for result in results: - if is_features: - self._context_feature = result - else: - self._context_peak = result - for subfield in subfields: - value.append(self.value_for(subfield)) - value = '\t'.join([str(x) for x in value]) - else: - # All other fields - value = self.value_for(field) - line.append(str(value)) - # Return (yield) the line - yield '\t'.join(line) - elif self._mode == MULTI_LINE: - # Report each result pair on a new line - i = 0 - for result in results: - if is_features: - self._context_feature = result - else: - self._context_peak = result - i += 1 - line = [] - for field in self._fields: - if field == 'order' and result is not None: - value = '%d of %d' % (i,nresults) - else: - value = self.value_for(field) - line.append(str(value)) - # Return (yield) the line - yield '\t'.join(line) - # Reset the context - self._context_peak = None - self._context_feature = None - self._is_features = None - - def report_nearest_features(self,peak,features): - """ - Return details of nearest features for a peak - - This is a wrapper for ``report_nearest``. - - Arguments: - peak (Peak): peak of interest - features (FeatureSet): list of nearest features - - Yields: - string: line(s) of text reporting the results - - """ - for line in self.report_nearest(peak,features): - yield line - - def report_nearest_peaks(self,feature,peaks): - """ - Return details of nearest peaks for a feature - - This is a wrapper for ``report_nearest``. - - Arguments: - feature (Feature): feature of interest - peaks (PeakSet): list of nearest peaks - - Returns: - string: block of text reporting the results - - """ - for line in self.report_nearest(feature,peaks): - yield line - - def value_for(self,attr): - """ - Return the value for the specified attribute - - Wraps '_value_for' method, and returns the null - placeholder value in the event of an AttributeError - being raised. - - Arguments: - attr (string): attribute name - - Returns: - Value of the field for the current peak/feature - pair - - """ - try: - return self._value_for(attr) - except (AttributeError,KeyError): - return self._placeholder - - def _value_for(self,attr): - """ - Return the value for the specified attribute - - Given the name of a field/attribute (see above for - a list and definition of each), return the value - for the current peak/feature pair (which should have - been set by the calling method in the '_context_peak' - and '_context_feature' properties). - - Arguments: - attr (string): attribute name - - Returns: - Value of the field for the current peak/feature - pair - - Raises: - AttributeError: if valid ``attr`` cannot be derived - KeyError: if ``attr`` is not a recognised attribute - name - - """ - peak = self._context_peak - feature = self._context_feature - is_features = self._is_features - if attr == 'chr' or attr == 'peak.chr': - return peak.chrom - elif attr == 'peak.start' or attr == 'start': - return peak.start - elif attr == 'peak.end' or attr == 'end': - return peak.end - elif attr == 'id' or attr == 'feature.id': - return feature.id - elif attr == 'feature.chr': - return feature.chrom - elif attr == 'feature.start': - return feature.start - elif attr == 'feature.end': - return feature.end - elif attr == 'TSS': - return feature.tss - elif attr == 'TES': - return feature.tes - elif attr == 'strand' or attr == 'feature.strand': - return feature.strand - elif attr == 'differentially_expressed': - return feature.flag - elif attr == 'dist_closest': - return distances.distance_closest_edge(peak,feature) - elif attr == 'dist_TSS': - return distances.distance_tss(peak,feature) - elif attr == 'dist_TES': - return distances.distance_tes(peak,feature) - elif attr == 'overlap_feature' or attr == 'in_the_feature': - if distances.regions_overlap((peak.start,peak.end), - (feature.tss,feature.tes)): - overlap_feature = 1 - else: - overlap_feature = 0 - if attr == 'in_the_feature': - overlap_feature = ('YES' if overlap_feature == 1 else 'NO') - return overlap_feature - elif attr == 'overlap_promoter': - if self._promoter_region is not None: - promoter = feature.getPromoterRegion(*self._promoter_region) - if distances.regions_overlap((peak.start,peak.end), - promoter): - overlap_promoter = 1 - else: - overlap_promoter = 0 - else: - raise Exception("'overlap_promoter' requested but no " - "promoter region has been defined") - return overlap_promoter - elif attr == 'direction': - if self._is_features: - direction = distances.direction(feature,peak) - else: - direction = distances.direction(peak,feature) - if direction == distances.UPSTREAM: - return 'U' - elif direction == distances.DOWNSTREAM: - return 'D' - else: - return '.' - elif attr == 'features_inbetween': - raise NotImplementedError("'features_inbetween' not implemented") - else: - raise KeyError("Unrecognised report field: '%s'" % attr) - - def make_header(self): - """ - Create a 'header' line for output - - Builds a header line which can be incorporated into - an output file, based on the fields that are being - reported. - - Returns: - str: tab-delimited header line - - """ - if self._mode == MULTI_LINE: - if self._feature_type is None: - return '\t'.join(self._fields) - else: - return '\t'.join([x.replace('feature',self._feature_type) - for x in self._fields]) - elif self._mode == SINGLE_LINE: - header_fields = [] - if self._max_hits is not None: - max_pairs = self._max_hits - else: - max_pairs = self._max_pairs - for f in self._fields: - try: - # Handle fields in a list(...) - subfields = f[:-1].split('(')[1].split(',') - for i in range(1,max_pairs+1): - for s in subfields: - header_fields.append("%s_%d" % (s,i)) - except IndexError: - # Not a list - header_fields.append(f) - if self._feature_type is not None: - header_fields = [x.replace('feature',self._feature_type) - for x in header_fields] - return '\t'.join(header_fields) - -class AnalysisReportWriter(AnalysisReporter): - """ - Write analysis results to file - - Wrapper for AnalysisReporter that writes the results to - a file; optionally it can also write 'summary' files - (only top result is reported). - - """ - def __init__(self,mode,fields,promoter_region=None, - null_placeholder='.',feature_type=None, - max_hits=None,pad=None, - outfile=None,summary=None): - """ - Create new AnalysisReportWriter instance - - Arguments: - mode (int): either SINGLE_LINE or MULTI_LINE - fields (list): list of fields to output - promoter_region (tuple): promoter region extent (optional) - null_placeholder (str): placeholder to use in output for - fields which evaluate to 'null' - feature_type (str): if not 'None' then replace 'feature' - with 'feature_type' (e.g. 'gene', 'transcript' etc) in - the output - max_hits (int): optional maximum number of hits to - report for each set of results - pad (bool): add extra 'None' items to output hits to - pad out to max_closest results - outfile (str): name of output file to write results to - summary (str): optional, name of file to write summary - results to - - """ - AnalysisReporter.__init__(self,mode,fields, - promoter_region=promoter_region, - null_placeholder=null_placeholder, - pad=pad,max_hits=max_hits, - feature_type=feature_type) - self.outfile = outfile - if self.outfile is not None: - # Open temporary file to handle output - self._fp = tempfile.TemporaryFile() - else: - self._fp = None - self.summary = summary - if self.summary is not None: - # Open temporary file to handle summary - self._summary = tempfile.TemporaryFile() - else: - self._summary = None - - def write_nearest_features(self,peak,features): - """ - Write a set of features to the output file(s) - - Arguments: - peak (Peak): peak of interest - features (FeatureSet): list of nearest features - - """ - lines = list(self.report_nearest_features(peak,features)) - if self._fp is not None: - self._fp.write("%s\n" % '\n'.join(lines)) - if self._summary is not None: - self._summary.write("%s\n" % lines[0]) - - def write_nearest_peaks(self,feature,peaks): - """ - Write a set of peaks to the output file(s) - - Arguments: - feature (Feature): feature of interest - peaks (PeakSet): list of nearest peaks - - """ - lines = list(self.report_nearest_peaks(feature,peaks)) - if self._fp is not None: - self._fp.write("%s\n" % '\n'.join(lines)) - if self._summary is not None: - self._summary.write("%s\n" % lines[0]) - - def close(self): - """ - Close the files associated with the writer - - In reality the data has been written to temporary - files; the purpose of this method is to open, - write and close the final 'visible' output files. - - """ - # Full output file - if self.outfile: - # Rewind to the start of the temp file - self._fp.seek(0) - # Write the final output file - with open(self.outfile,'w') as fp: - # Write the header - fp.write("#%s\n" % self.make_header()) - # Write the content - nitems = len(self.make_header().split('\t')) - for line in self._fp: - if self._mode == SINGLE_LINE: - # Handle padding trailing empty fields - fields = line.rstrip().split('\t') - while len(fields) < nitems: - fields.append(self._placeholder) - line = '\t'.join(fields) + '\n' - fp.write(line) - # Dispose of the temp file - self._fp.close() - # Summary output file - if self.summary: - # Rewind to the start of the temp file - self._summary.seek(0) - # Write the final summary file - with open(self.summary,'w') as fp: - # Write the header - fp.write("#%s\n" % self.make_header()) - # Write the content - for line in self._summary: - fp.write(line) - # Dispose of the temp file - self._summary.close() - -def describe_fields(fields): - """ - Return list of field descriptions - - Creates a list consisting of (FIELD,DESC) tuples - where FIELD is the name of the field and DESC is - its corresponding description text. - - For example if the supplied fields were: - - "chr,start,id,dist_closest" - - then the resulting desciption list would look like: - - [('chr','Chromosome'), - ('start','Peak start position'), - ('id','Feature ID'), - ('dist_closest','Closest distance between peak and feature')] - - Arguments: - fields (list): list of fields - - Returns: - list: list of (field,description) tuples. - - """ - descriptions = [] - for attr in fields: - try: - descriptions.append(("%s" % attr, - "%s" % FIELDS[attr])) - except KeyError: - if attr.startswith('list('): - descriptions.append(('For each hit:',)) - sub_attrs = attr[:-1].split('(')[1].split(',') - for sub_attr in sub_attrs: - descriptions.append(("%s_#" % sub_attr, - "%s" % FIELDS[sub_attr])) - return descriptions
Binary file test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/rnachipintegrator/output.pyc has changed
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/rnachipintegrator/utils.py Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,62 +0,0 @@ -#!/bin/env python -# -# utils.py: utility functions for RnaChipIntegrator -# Copyright (C) University of Manchester 2011-15 Peter Briggs, Leo Zeef -# & Ian Donaldson -# -""" -utils.py - -Utility functions for RnaChipIntegrator: - -- make_errline: highlight problem fields in a string -- truncate_text: truncate a text string to a specified length - -""" - -def make_errline(line,bad_fields=[]): - """Return an 'error line' indicating problem fields in a string - - Given a tab-delimited line and a list of integer indices - indicating which fields in the line have problems, this function - returns a tab-delimited string where the original fields are - replaced by either spaces or '^' characters. - - When printed beneath the original line, the '^'s indicate which - fields are 'bad' according to the supplied indices, e.g. - - Input line: 'good good bad bad good' - Error line: ' ^^^ ^^^ ' - - Arguments: - line: string where tabs delimit fields - bad_fields: list of integer indices corresponding to 'bad' - values in 'line' - - Returns: - Tab-delimited 'error line' to be printed beneath the original - line, to indicate which fields are 'bad'. - """ - # Indicate problem field(s) - errline = [] - items = line.rstrip().split('\t') - for i in range(len(items)): - if i in bad_fields: - errline.append("^"*len(items[i])) - else: - errline.append(" "*len(items[i])) - return '\t'.join(errline) - -def truncate_text(text,max_len): - """Truncate a text string - - Given a title and an optional extension, remove characters - and replace with ellipsis (i.e. ...) so that it fit into - the maxium number of characters (max_len). - - """ - len_text = len(text) - if len_text <= max_len: - return text - text = text[len_text-max_len:] - return '...' + text[3:]
Binary file test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/rnachipintegrator/utils.pyc has changed
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/rnachipintegrator/xls_output.py Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,270 +0,0 @@ -#!/bin/env python -# -# xls_output.py: functions for writing analysis results to Excel files -# Copyright (C) University of Manchester 2015-16 Peter Briggs, Leo Zeef -# & Ian Donaldson -# -""" -xls_output.py - -Functions for outputting analysis results to XLSX spreadsheet - -""" -import datetime -import xlsxwriter -import re -import output -import utils - -# Regular expressions for styling tags -RE_STYLE = re.compile(r"^<style +([^>]*)>(.*)</style>$") - -# Notes text -NOTES = dict() -NOTES['preamble'] = """<style font=bold bgcolor=gray>%s</style> - -Find nearest peaks to %ss (and vice versa) - -Bioinformatics Core Facility, Faculty of Life Sciences, University of Manchester -http://fls-bioinformatics-core.github.com/RnaChipIntegrator/ -Run on %s - -<style font=bold bgcolor=gray>Settings</style>""" -NOTES['peak_centric'] = """ -<style font=bold bgcolor=gray>'Peak-centric': nearest %ss to each peak</style> -Column\tDescription""" -NOTES['feature_centric'] = """ -<style font=bold bgcolor=gray>'%s-centric': nearest peaks to each %s</style> -Column\tDescription""" - -class XLSX: - """ - Class to assemble XLSX output file - - Utility class to help build an XLSX file from existing - output TSV files. - - Example usage: - - >>> xlsx = XLS('results.xlsx') - >>> xlsx.add_result_sheet('results','results.tsv') - >>> xlsx.write() - - """ - def __init__(self,xlsx_file,program_version,feature_type=None): - """ - Create a new XLSX instance - - Arguments: - xlsx_file (str): name or path of output file - program_version (str): name and version of the program - that is writing the spreadsheet - feature_type (str): if not None then replace 'feature' - with 'feature_type' (e.g. 'gene', 'transcript' etc) in - the output - - """ - self._xlsx = xlsxwriter.Workbook(xlsx_file) - self._sheets = {} - self._rows = {} - self._widths = {} - self._styles = {} - self._feature_type = ('gene' if feature_type is None - else feature_type) - self.add_sheet("Notes") - self.append_to_notes(NOTES['preamble'] % (program_version, - self._feature_type, - datetime.date.today())) - - def add_sheet(self,name): - """ - Create a new worksheet in the XLSX file - - Arguments: - name (str): title for the new sheet (must be - unique across the XLSX file) - - Returns: - WorkSheet: new worksheet. - - """ - if name in self._sheets: - raise KeyError("'%s': worksheet already exists") - ws = self._xlsx.add_worksheet(name) - self._sheets[name] = ws - self._rows[name] = 0 - self._widths[name] = [] - return ws - - def get_format(self,*args): - """ - Return a cell format object matching arguments - - Returns a Format object matching the supplied - arguments, which should be strings of the form - - 'KEY=VALUE' - - Formats are cached so there will be one Format - per unique set of key/value pairs. - - """ - # Create a name for this style - name = list(args)[:] - name.sort() - name = "_".join(name) - # See if it's already defined - if name not in self._styles: - # Create a new style (cell_format) - fmt = self._xlsx.add_format() - for style in args: - if style == "font=bold": - fmt.set_bold(True) - elif style.startswith("bgcolor="): - color = style.split('=')[1] - fmt.set_bg_color(color) - else: - raise NotImplementedError("%s: not implemented" % - style) - self._styles[name] = fmt - # Return the cell format for this style - return self._styles[name] - - def add_text(self,name,text): - """ - Add (append) arbitrary text to a worksheet - - Arguments: - name (str): name of the worksheet - text (str): text that will be added to the - end of the worksheet - - """ - ws = self._sheets[name] - i = self._rows[name] - for line in text.split('\n'): - j = 0 - for item in line.split('\t'): - # Check for styles - style_match = RE_STYLE.match(item) - if style_match: - item = style_match.group(2) - style = style_match.group(1).split() - fmt = self.get_format(*style) - else: - fmt = None - # Write the item - ws.write(i,j,item,fmt) - # Update the widths - try: - self._widths[name][j] = max(self._widths[name][j], - len(item)) - except IndexError: - self._widths[name].append(len(item)) - # Increment column counter - j += 1 - # Increment row counter - i += 1 - self._rows[name] = i - - def append_to_notes(self,text): - """ - Append arbitrary text to the 'notes' page - - Arguments: - text (str): text that will be added to the - end of the notes. - - """ - self.add_text("Notes",text) - - def write_peak_centric(self,fields): - """ - Write details of the 'peak-centric' results to XLSX notes - - Arguments: - fields (list): list of fields in the output - - """ - self.append_to_notes(NOTES['peak_centric'] % - self._feature_type) - self.append_to_notes(self._field_descriptions(fields)) - - def write_feature_centric(self,fields): - """ - Write details of the 'feature-centric' results to XLSX notes - - Arguments: - fields (list): list of fields in the output - - """ - self.append_to_notes(NOTES['feature_centric'] % - (self._feature_type.title(), - self._feature_type)) - self.append_to_notes(self._field_descriptions(fields)) - - def _field_descriptions(self,fields): - """ - Generate field (column) descriptions for XLSX notes - - Arguments: - fields (list): list of fields to describe - - Returns: - string: text with one field name/description pair - (separated by a tab) per line - - """ - return '\n'.join(['\t'.join(x) for x in - output.describe_fields(fields)]).\ - replace('feature',self._feature_type).\ - replace('Feature',self._feature_type.title()) - - def add_result_sheet(self,title,tsv_file): - """ - Add a sheet populated from a file - - Creates a new sheet in the spreadsheet with the - supplied title and populates using the contents - of a tab-delimited file. - - If there are more lines than can be written to a - single worksheet then creates additional sheets - as required. - - Arguments: - title (str): a title for the sheet - tsv_file (str): path to a tab-delimited file - - """ - ws = self.add_sheet(title) - # Get header line - with open(tsv_file,'r') as fp: - i = self._rows[title] - for line in fp: - j = 0 - for value in line.rstrip('\n').split('\t'): - ws.write(i,j,value) - try: - self._widths[title][j] = max(self._widths[title][j], - len(value)) - except IndexError: - self._widths[title].append(len(value)) - j += 1 - i += 1 - self._rows[title] = i - # Freeze the header - ws.freeze_panes(1,0) - - def write(self): - """ - Write XLSX to file - - """ - # Set the column widths - for name in self._sheets: - ws = self._sheets[name] - for j,w in enumerate(self._widths[name]): - ws.set_column(j,j,w*1.2) - # Close to write to file - self._xlsx.close()
Binary file test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/rnachipintegrator/xls_output.pyc has changed
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/__init__.py Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3 +0,0 @@ -__version__ = '0.8.4' -__VERSION__ = __version__ -from .workbook import Workbook
Binary file test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/__init__.pyc has changed
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/app.py Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,196 +0,0 @@ -############################################################################### -# -# App - A class for writing the Excel XLSX App file. -# -# Copyright 2013-2016, John McNamara, jmcnamara@cpan.org -# - -# Package imports. -from . import xmlwriter - - -class App(xmlwriter.XMLwriter): - """ - A class for writing the Excel XLSX App file. - - - """ - - ########################################################################### - # - # Public API. - # - ########################################################################### - - def __init__(self): - """ - Constructor. - - """ - - super(App, self).__init__() - - self.part_names = [] - self.heading_pairs = [] - self.properties = {} - - def _add_part_name(self, part_name): - # Add the name of a workbook Part such as 'Sheet1' or 'Print_Titles'. - self.part_names.append(part_name) - - def _add_heading_pair(self, heading_pair): - # Add the name of a workbook Heading Pair such as 'Worksheets', - # 'Charts' or 'Named Ranges'. - - # Ignore empty pairs such as chartsheets. - if not heading_pair[1]: - return - - self.heading_pairs.append(('lpstr', heading_pair[0])) - self.heading_pairs.append(('i4', heading_pair[1])) - - def _set_properties(self, properties): - # Set the document properties. - self.properties = properties - - ########################################################################### - # - # Private API. - # - ########################################################################### - - def _assemble_xml_file(self): - # Assemble and write the XML file. - - # Write the XML declaration. - self._xml_declaration() - - self._write_properties() - self._write_application() - self._write_doc_security() - self._write_scale_crop() - self._write_heading_pairs() - self._write_titles_of_parts() - self._write_manager() - self._write_company() - self._write_links_up_to_date() - self._write_shared_doc() - self._write_hyperlink_base() - self._write_hyperlinks_changed() - self._write_app_version() - - self._xml_end_tag('Properties') - - # Close the file. - self._xml_close() - - ########################################################################### - # - # XML methods. - # - ########################################################################### - - def _write_properties(self): - # Write the <Properties> element. - schema = 'http://schemas.openxmlformats.org/officeDocument/2006/' - xmlns = schema + 'extended-properties' - xmlns_vt = schema + 'docPropsVTypes' - - attributes = [ - ('xmlns', xmlns), - ('xmlns:vt', xmlns_vt), - ] - - self._xml_start_tag('Properties', attributes) - - def _write_application(self): - # Write the <Application> element. - self._xml_data_element('Application', 'Microsoft Excel') - - def _write_doc_security(self): - # Write the <DocSecurity> element. - self._xml_data_element('DocSecurity', '0') - - def _write_scale_crop(self): - # Write the <ScaleCrop> element. - self._xml_data_element('ScaleCrop', 'false') - - def _write_heading_pairs(self): - # Write the <HeadingPairs> element. - self._xml_start_tag('HeadingPairs') - self._write_vt_vector('variant', self.heading_pairs) - self._xml_end_tag('HeadingPairs') - - def _write_titles_of_parts(self): - # Write the <TitlesOfParts> element. - parts_data = [] - - self._xml_start_tag('TitlesOfParts') - - for part_name in self.part_names: - parts_data.append(('lpstr', part_name)) - - self._write_vt_vector('lpstr', parts_data) - - self._xml_end_tag('TitlesOfParts') - - def _write_vt_vector(self, base_type, vector_data): - # Write the <vt:vector> element. - attributes = [ - ('size', len(vector_data)), - ('baseType', base_type), - ] - - self._xml_start_tag('vt:vector', attributes) - - for vt_data in vector_data: - if base_type == 'variant': - self._xml_start_tag('vt:variant') - - self._write_vt_data(vt_data) - - if base_type == 'variant': - self._xml_end_tag('vt:variant') - - self._xml_end_tag('vt:vector') - - def _write_vt_data(self, vt_data): - # Write the <vt:*> elements such as <vt:lpstr> and <vt:if>. - self._xml_data_element("vt:%s" % vt_data[0], vt_data[1]) - - def _write_company(self): - company = self.properties.get('company', '') - - self._xml_data_element('Company', company) - - def _write_manager(self): - # Write the <Manager> element. - if 'manager' not in self.properties: - return - - self._xml_data_element('Manager', self.properties['manager']) - - def _write_links_up_to_date(self): - # Write the <LinksUpToDate> element. - self._xml_data_element('LinksUpToDate', 'false') - - def _write_shared_doc(self): - # Write the <SharedDoc> element. - self._xml_data_element('SharedDoc', 'false') - - def _write_hyperlink_base(self): - # Write the <HyperlinkBase> element. - hyperlink_base = self.properties.get('hyperlink_base') - - if hyperlink_base is None: - return - - self._xml_data_element('HyperlinkBase', hyperlink_base) - - def _write_hyperlinks_changed(self): - # Write the <HyperlinksChanged> element. - self._xml_data_element('HyperlinksChanged', 'false') - - def _write_app_version(self): - # Write the <AppVersion> element. - self._xml_data_element('AppVersion', '12.0000')
Binary file test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/app.pyc has changed
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/chart.py Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3906 +0,0 @@ -############################################################################### -# -# Chart - A class for writing the Excel XLSX Worksheet file. -# -# Copyright 2013-2016, John McNamara, jmcnamara@cpan.org -# -import re -import copy -from warnings import warn - -from .shape import Shape -from . import xmlwriter -from .utility import get_rgb_color -from .utility import xl_rowcol_to_cell -from .utility import xl_range_formula -from .utility import supported_datetime -from .utility import datetime_to_excel_datetime -from .utility import quote_sheetname - - -class Chart(xmlwriter.XMLwriter): - """ - A class for writing the Excel XLSX Chart file. - - - """ - - ########################################################################### - # - # Public API. - # - ########################################################################### - - def __init__(self, options=None): - """ - Constructor. - - """ - - super(Chart, self).__init__() - - self.subtype = None - self.sheet_type = 0x0200 - self.orientation = 0x0 - self.series = [] - self.embedded = 0 - self.id = -1 - self.series_index = 0 - self.style_id = 2 - self.axis_ids = [] - self.axis2_ids = [] - self.cat_has_num_fmt = 0 - self.requires_category = False - self.legend_position = 'right' - self.legend_delete_series = None - self.legend_font = None - self.legend_layout = None - self.cat_axis_position = 'b' - self.val_axis_position = 'l' - self.formula_ids = {} - self.formula_data = [] - self.horiz_cat_axis = 0 - self.horiz_val_axis = 1 - self.protection = 0 - self.chartarea = {} - self.plotarea = {} - self.x_axis = {} - self.y_axis = {} - self.y2_axis = {} - self.x2_axis = {} - self.chart_name = '' - self.show_blanks = 'gap' - self.show_hidden = 0 - self.show_crosses = 1 - self.width = 480 - self.height = 288 - self.x_scale = 1 - self.y_scale = 1 - self.x_offset = 0 - self.y_offset = 0 - self.table = None - self.cross_between = 'between' - self.default_marker = None - self.series_gap_1 = None - self.series_gap_2 = None - self.series_overlap_1 = None - self.series_overlap_2 = None - self.drop_lines = None - self.hi_low_lines = None - self.up_down_bars = None - self.smooth_allowed = False - self.title_font = None - self.title_name = None - self.title_formula = None - self.title_data_id = None - self.title_layout = None - self.title_overlay = None - self.title_none = False - self.date_category = False - self.date_1904 = False - self.label_positions = {} - self.label_position_default = '' - self.already_inserted = False - self.combined = None - self.is_secondary = False - self._set_default_properties() - - def add_series(self, options): - """ - Add a data series to a chart. - - Args: - options: A dictionary of chart series options. - - Returns: - Nothing. - - """ - # Add a series and it's properties to a chart. - - # Check that the required input has been specified. - if 'values' not in options: - warn("Must specify 'values' in add_series()") - return - - if self.requires_category and 'categories' not in options: - warn("Must specify 'categories' in add_series() " - "for this chart type") - - # Convert list into a formula string. - values = self._list_to_formula(options.get('values')) - categories = self._list_to_formula(options.get('categories')) - - # Switch name and name_formula parameters if required. - name, name_formula = self._process_names(options.get('name'), - options.get('name_formula')) - - # Get an id for the data equivalent to the range formula. - cat_id = self._get_data_id(categories, options.get('categories_data')) - val_id = self._get_data_id(values, options.get('values_data')) - name_id = self._get_data_id(name_formula, options.get('name_data')) - - # Set the line properties for the series. - line = Shape._get_line_properties(options.get('line')) - - # Allow 'border' as a synonym for 'line' in bar/column style charts. - if options.get('border'): - line = Shape._get_line_properties(options['border']) - - # Set the fill properties for the series. - fill = Shape._get_fill_properties(options.get('fill')) - - # Set the pattern fill properties for the series. - pattern = Shape._get_pattern_properties(options.get('pattern')) - - # Set the gradient fill properties for the series. - gradient = Shape._get_gradient_properties(options.get('gradient')) - - # Pattern fill overrides solid fill. - if pattern: - self.fill = None - - # Gradient fill overrides the solid and pattern fill. - if gradient: - pattern = None - fill = None - - # Set the marker properties for the series. - marker = self._get_marker_properties(options.get('marker')) - - # Set the trendline properties for the series. - trendline = self._get_trendline_properties(options.get('trendline')) - - # Set the line smooth property for the series. - smooth = options.get('smooth') - - # Set the error bars properties for the series. - y_error_bars = self._get_error_bars_props(options.get('y_error_bars')) - x_error_bars = self._get_error_bars_props(options.get('x_error_bars')) - - error_bars = {'x_error_bars': x_error_bars, - 'y_error_bars': y_error_bars} - - # Set the point properties for the series. - points = self._get_points_properties(options.get('points')) - - # Set the labels properties for the series. - labels = self._get_labels_properties(options.get('data_labels')) - - # Set the "invert if negative" fill property. - invert_if_neg = options.get('invert_if_negative', False) - - # Set the secondary axis properties. - x2_axis = options.get('x2_axis') - y2_axis = options.get('y2_axis') - - # Store secondary status for combined charts. - if x2_axis or y2_axis: - self.is_secondary = True - - # Set the gap for Bar/Column charts. - if options.get('gap') is not None: - if y2_axis: - self.series_gap_2 = options['gap'] - else: - self.series_gap_1 = options['gap'] - - # Set the overlap for Bar/Column charts. - if options.get('overlap'): - if y2_axis: - self.series_overlap_2 = options['overlap'] - else: - self.series_overlap_1 = options['overlap'] - - # Add the user supplied data to the internal structures. - series = { - 'values': values, - 'categories': categories, - 'name': name, - 'name_formula': name_formula, - 'name_id': name_id, - 'val_data_id': val_id, - 'cat_data_id': cat_id, - 'line': line, - 'fill': fill, - 'pattern': pattern, - 'gradient': gradient, - 'marker': marker, - 'trendline': trendline, - 'labels': labels, - 'invert_if_neg': invert_if_neg, - 'x2_axis': x2_axis, - 'y2_axis': y2_axis, - 'points': points, - 'error_bars': error_bars, - 'smooth': smooth - } - - self.series.append(series) - - def set_x_axis(self, options): - """ - Set the chart X axis options. - - Args: - options: A dictionary of axis options. - - Returns: - Nothing. - - """ - axis = self._convert_axis_args(self.x_axis, options) - - self.x_axis = axis - - def set_y_axis(self, options): - """ - Set the chart Y axis options. - - Args: - options: A dictionary of axis options. - - Returns: - Nothing. - - """ - axis = self._convert_axis_args(self.y_axis, options) - - self.y_axis = axis - - def set_x2_axis(self, options): - """ - Set the chart secondary X axis options. - - Args: - options: A dictionary of axis options. - - Returns: - Nothing. - - """ - axis = self._convert_axis_args(self.x2_axis, options) - - self.x2_axis = axis - - def set_y2_axis(self, options): - """ - Set the chart secondary Y axis options. - - Args: - options: A dictionary of axis options. - - Returns: - Nothing. - - """ - axis = self._convert_axis_args(self.y2_axis, options) - - self.y2_axis = axis - - def set_title(self, options): - """ - Set the chart title options. - - Args: - options: A dictionary of chart title options. - - Returns: - Nothing. - - """ - name, name_formula = self._process_names(options.get('name'), - options.get('name_formula')) - - data_id = self._get_data_id(name_formula, options.get('data')) - - self.title_name = name - self.title_formula = name_formula - self.title_data_id = data_id - - # Set the font properties if present. - self.title_font = self._convert_font_args(options.get('name_font')) - - # Set the axis name layout. - self.title_layout = self._get_layout_properties(options.get('layout'), - True) - # Set the title overlay option. - self.title_overlay = options.get('overlay') - - # Set the automatic title option. - self.title_none = options.get('none') - - def set_legend(self, options): - """ - Set the chart legend options. - - Args: - options: A dictionary of chart legend options. - - Returns: - Nothing. - """ - self.legend_position = options.get('position', 'right') - self.legend_delete_series = options.get('delete_series') - self.legend_font = self._convert_font_args(options.get('font')) - self.legend_layout = self._get_layout_properties(options.get('layout'), - False) - # Turn off the legend. - if options.get('none'): - self.legend_position = 'none' - - def set_plotarea(self, options): - """ - Set the chart plot area options. - - Args: - options: A dictionary of chart plot area options. - - Returns: - Nothing. - """ - # Convert the user defined properties to internal properties. - self.plotarea = self._get_area_properties(options) - - def set_chartarea(self, options): - """ - Set the chart area options. - - Args: - options: A dictionary of chart area options. - - Returns: - Nothing. - """ - # Convert the user defined properties to internal properties. - self.chartarea = self._get_area_properties(options) - - def set_style(self, style_id): - """ - Set the chart style type. - - Args: - style_id: An int representing the chart style. - - Returns: - Nothing. - """ - # Set one of the 48 built-in Excel chart styles. The default is 2. - if style_id is None: - style_id = 2 - - if style_id < 0 or style_id > 48: - style_id = 2 - - self.style_id = style_id - - def show_blanks_as(self, option): - """ - Set the option for displaying blank data in a chart. - - Args: - option: A string representing the display option. - - Returns: - Nothing. - """ - if not option: - return - - valid_options = { - 'gap': 1, - 'zero': 1, - 'span': 1, - } - - if option not in valid_options: - warn("Unknown show_blanks_as() option '%s'" % option) - return - - self.show_blanks = option - - def show_hidden_data(self): - """ - Display data on charts from hidden rows or columns. - - Args: - option: A string representing the display option. - - Returns: - Nothing. - """ - self.show_hidden = 1 - - def set_size(self, options): - """ - Set size or scale of the chart. - - Args: - options: A dictionary of chart size options. - - Returns: - Nothing. - """ - - # Set dimensions or scale for the chart. - self.width = options.get('width', self.width) - self.height = options.get('height', self.height) - self.x_scale = options.get('x_scale', 1) - self.y_scale = options.get('y_scale', 1) - self.x_offset = options.get('x_offset', 0) - self.y_offset = options.get('y_offset', 0) - - def set_table(self, options=None): - """ - Set properties for an axis data table. - - Args: - options: A dictionary of axis table options. - - Returns: - Nothing. - - """ - if options is None: - options = {} - - table = {} - - table['horizontal'] = options.get('horizontal', 1) - table['vertical'] = options.get('vertical', 1) - table['outline'] = options.get('outline', 1) - table['show_keys'] = options.get('show_keys', 0) - - self.table = table - - def set_up_down_bars(self, options=None): - """ - Set properties for the chart up-down bars. - - Args: - options: A dictionary of options. - - Returns: - Nothing. - - """ - if options is None: - options = {} - - # Defaults. - up_line = None - up_fill = None - down_line = None - down_fill = None - - # Set properties for 'up' bar. - if options.get('up'): - if 'border' in options['up']: - # Map border to line. - up_line = Shape._get_line_properties(options['up']['border']) - - if 'line' in options['up']: - up_line = Shape._get_line_properties(options['up']['line']) - - if 'fill' in options['up']: - up_fill = Shape._get_line_properties(options['up']['fill']) - - # Set properties for 'down' bar. - if options.get('down'): - if 'border' in options['down']: - # Map border to line. - down_line = \ - Shape._get_line_properties(options['down']['border']) - - if 'line' in options['down']: - down_line = Shape._get_line_properties(options['down']['line']) - - if 'fill' in options['down']: - down_fill = Shape._get_line_properties(options['down']['fill']) - - self.up_down_bars = {'up': {'line': up_line, - 'fill': up_fill, - }, - 'down': {'line': down_line, - 'fill': down_fill, - }, - } - - def set_drop_lines(self, options=None): - """ - Set properties for the chart drop lines. - - Args: - options: A dictionary of options. - - Returns: - Nothing. - - """ - if options is None: - options = {} - - line = Shape._get_line_properties(options.get('line')) - fill = Shape._get_fill_properties(options.get('fill')) - - # Set the pattern fill properties for the series. - pattern = Shape._get_pattern_properties(options.get('pattern')) - - # Set the gradient fill properties for the series. - gradient = Shape._get_gradient_properties(options.get('gradient')) - - # Pattern fill overrides solid fill. - if pattern: - self.fill = None - - # Gradient fill overrides the solid and pattern fill. - if gradient: - pattern = None - fill = None - - self.drop_lines = {'line': line, - 'fill': fill, - 'pattern': pattern, - 'gradient': gradient} - - def set_high_low_lines(self, options=None): - """ - Set properties for the chart high-low lines. - - Args: - options: A dictionary of options. - - Returns: - Nothing. - - """ - if options is None: - options = {} - - line = Shape._get_line_properties(options.get('line')) - fill = Shape._get_fill_properties(options.get('fill')) - - # Set the pattern fill properties for the series. - pattern = Shape._get_pattern_properties(options.get('pattern')) - - # Set the gradient fill properties for the series. - gradient = Shape._get_gradient_properties(options.get('gradient')) - - # Pattern fill overrides solid fill. - if pattern: - self.fill = None - - # Gradient fill overrides the solid and pattern fill. - if gradient: - pattern = None - fill = None - - self.hi_low_lines = {'line': line, - 'fill': fill, - 'pattern': pattern, - 'gradient': gradient} - - def combine(self, chart=None): - """ - Create a combination chart with a secondary chart. - - Args: - chart: The secondary chart to combine with the primary chart. - - Returns: - Nothing. - - """ - if chart is None: - return - - self.combined = chart - - ########################################################################### - # - # Private API. - # - ########################################################################### - - def _assemble_xml_file(self): - # Assemble and write the XML file. - - # Write the XML declaration. - self._xml_declaration() - - # Write the c:chartSpace element. - self._write_chart_space() - - # Write the c:lang element. - self._write_lang() - - # Write the c:style element. - self._write_style() - - # Write the c:protection element. - self._write_protection() - - # Write the c:chart element. - self._write_chart() - - # Write the c:spPr element for the chartarea formatting. - self._write_sp_pr(self.chartarea) - - # Write the c:printSettings element. - if self.embedded: - self._write_print_settings() - - # Close the worksheet tag. - self._xml_end_tag('c:chartSpace') - # Close the file. - self._xml_close() - - def _convert_axis_args(self, axis, user_options): - # Convert user defined axis values into private hash values. - options = axis['defaults'].copy() - options.update(user_options) - - name, name_formula = self._process_names(options.get('name'), - options.get('name_formula')) - - data_id = self._get_data_id(name_formula, options.get('data')) - - axis = { - 'defaults': axis['defaults'], - 'name': name, - 'formula': name_formula, - 'data_id': data_id, - 'reverse': options.get('reverse'), - 'min': options.get('min'), - 'max': options.get('max'), - 'minor_unit': options.get('minor_unit'), - 'major_unit': options.get('major_unit'), - 'minor_unit_type': options.get('minor_unit_type'), - 'major_unit_type': options.get('major_unit_type'), - 'display_units': options.get('display_units'), - 'log_base': options.get('log_base'), - 'crossing': options.get('crossing'), - 'position_axis': options.get('position_axis'), - 'position': options.get('position'), - 'label_position': options.get('label_position'), - 'num_format': options.get('num_format'), - 'num_format_linked': options.get('num_format_linked'), - 'interval_unit': options.get('interval_unit'), - 'interval_tick': options.get('interval_tick'), - 'text_axis': False, - } - - if 'visible' in options: - axis['visible'] = options.get('visible') - else: - axis['visible'] = 1 - - # Convert the display units. - axis['display_units'] = self._get_display_units(axis['display_units']) - axis['display_units_visible'] = \ - options.get('display_units_visible', True) - - # Map major_gridlines properties. - if (options.get('major_gridlines') - and options['major_gridlines']['visible']): - axis['major_gridlines'] = \ - self._get_gridline_properties(options['major_gridlines']) - - # Map minor_gridlines properties. - if (options.get('minor_gridlines') - and options['minor_gridlines']['visible']): - axis['minor_gridlines'] = \ - self._get_gridline_properties(options['minor_gridlines']) - - # Only use the first letter of bottom, top, left or right. - if axis.get('position'): - axis['position'] = axis['position'].lower()[0] - - # Set the position for a category axis on or between the tick marks. - if axis.get('position_axis'): - if axis['position_axis'] == 'on_tick': - axis['position_axis'] = 'midCat' - elif axis['position_axis'] == 'between': - # Doesn't need to be modified. - pass - else: - # Otherwise use the default value. - axis['position_axis'] = None - - # Set the category axis as a date axis. - if options.get('date_axis'): - self.date_category = True - - # Set the category axis as a text axis. - if options.get('text_axis'): - self.date_category = False - axis['text_axis'] = True - - # Convert datetime args if required. - if axis.get('min') and supported_datetime(axis['min']): - axis['min'] = datetime_to_excel_datetime(axis['min'], - self.date_1904) - if axis.get('max') and supported_datetime(axis['max']): - axis['max'] = datetime_to_excel_datetime(axis['max'], - self.date_1904) - if axis.get('crossing') and supported_datetime(axis['crossing']): - axis['crossing'] = datetime_to_excel_datetime(axis['crossing'], - self.date_1904) - - # Set the font properties if present. - axis['num_font'] = self._convert_font_args(options.get('num_font')) - axis['name_font'] = self._convert_font_args(options.get('name_font')) - - # Set the axis name layout. - axis['name_layout'] = \ - self._get_layout_properties(options.get('name_layout'), True) - - # Set the line properties for the axis. - axis['line'] = Shape._get_line_properties(options.get('line')) - - # Set the fill properties for the axis. - axis['fill'] = Shape._get_fill_properties(options.get('fill')) - - # Set the pattern fill properties for the series. - axis['pattern'] = Shape._get_pattern_properties(options.get('pattern')) - - # Set the gradient fill properties for the series. - axis['gradient'] = \ - Shape._get_gradient_properties(options.get('gradient')) - - # Pattern fill overrides solid fill. - if axis.get('pattern'): - axis['fill'] = None - - # Gradient fill overrides the solid and pattern fill. - if axis.get('gradient'): - axis['pattern'] = None - axis['fill'] = None - - # Set the tick marker types. - axis['minor_tick_mark'] = \ - self._get_tick_type(options.get('minor_tick_mark')) - axis['major_tick_mark'] = \ - self._get_tick_type(options.get('major_tick_mark')) - - return axis - - def _convert_font_args(self, options): - # Convert user defined font values into private dict values. - if not options: - return - - font = { - 'name': options.get('name'), - 'color': options.get('color'), - 'size': options.get('size'), - 'bold': options.get('bold'), - 'italic': options.get('italic'), - 'underline': options.get('underline'), - 'pitch_family': options.get('pitch_family'), - 'charset': options.get('charset'), - 'baseline': options.get('baseline', 0), - 'rotation': options.get('rotation'), - } - - # Convert font size units. - if font['size']: - font['size'] = int(font['size'] * 100) - - # Convert rotation into 60,000ths of a degree. - if font['rotation']: - font['rotation'] = 60000 * int(font['rotation']) - - return font - - def _list_to_formula(self, data): - # Convert and list of row col values to a range formula. - - # If it isn't an array ref it is probably a formula already. - if type(data) is not list: - return data - - formula = xl_range_formula(*data) - - return formula - - def _process_names(self, name, name_formula): - # Switch name and name_formula parameters if required. - - if name is not None: - if isinstance(name, list): - # Convert an list of values into a name formula. - cell = xl_rowcol_to_cell(name[1], name[2], True, True) - name_formula = quote_sheetname(name[0]) + '!' + cell - name = '' - elif re.match(r'^=?[^!]+!\$?[A-Z]+\$?[0-9]+', name): - # Name looks like a formula, use it to set name_formula. - name_formula = name - name = '' - - return name, name_formula - - def _get_data_type(self, data): - # Find the overall type of the data associated with a series. - - # Check for no data in the series. - if data is None or len(data) == 0: - return 'none' - - if isinstance(data[0], list): - return 'multi_str' - - # Determine if data is numeric or strings. - for token in data: - if token is None: - continue - - try: - float(token) - except ValueError: - # Not a number. Assume entire data series is string data. - return 'str' - - # The series data was all numeric. - return 'num' - - def _get_data_id(self, formula, data): - # Assign an id to a each unique series formula or title/axis formula. - # Repeated formulas such as for categories get the same id. If the - # series or title has user specified data associated with it then - # that is also stored. This data is used to populate cached Excel - # data when creating a chart. If there is no user defined data then - # it will be populated by the parent Workbook._add_chart_data(). - - # Ignore series without a range formula. - if not formula: - return - - # Strip the leading '=' from the formula. - if formula.startswith('='): - formula = formula.lstrip('=') - - # Store the data id in a hash keyed by the formula and store the data - # in a separate array with the same id. - if formula not in self.formula_ids: - # Haven't seen this formula before. - formula_id = len(self.formula_data) - - self.formula_data.append(data) - self.formula_ids[formula] = formula_id - else: - # Formula already seen. Return existing id. - formula_id = self.formula_ids[formula] - - # Store user defined data if it isn't already there. - if self.formula_data[formula_id] is None: - self.formula_data[formula_id] = data - - return formula_id - - def _get_marker_properties(self, marker): - # Convert user marker properties to the structure required internally. - - if not marker: - return - - # Copy the user defined properties since they will be modified. - marker = copy.deepcopy(marker) - - types = { - 'automatic': 'automatic', - 'none': 'none', - 'square': 'square', - 'diamond': 'diamond', - 'triangle': 'triangle', - 'x': 'x', - 'star': 'star', - 'dot': 'dot', - 'short_dash': 'dot', - 'dash': 'dash', - 'long_dash': 'dash', - 'circle': 'circle', - 'plus': 'plus', - 'picture': 'picture', - } - - # Check for valid types. - marker_type = marker.get('type') - - if marker_type is not None: - if marker_type == 'automatic': - marker['automatic'] = 1 - - if marker_type in types: - marker['type'] = types[marker_type] - else: - warn("Unknown marker type '%s" % marker_type) - return - - # Set the line properties for the marker. - line = Shape._get_line_properties(marker.get('line')) - - # Allow 'border' as a synonym for 'line'. - if 'border' in marker: - line = Shape._get_line_properties(marker['border']) - - # Set the fill properties for the marker. - fill = Shape._get_fill_properties(marker.get('fill')) - - # Set the pattern fill properties for the series. - pattern = Shape._get_pattern_properties(marker.get('pattern')) - - # Set the gradient fill properties for the series. - gradient = Shape._get_gradient_properties(marker.get('gradient')) - - # Pattern fill overrides solid fill. - if pattern: - self.fill = None - - # Gradient fill overrides the solid and pattern fill. - if gradient: - pattern = None - fill = None - - marker['line'] = line - marker['fill'] = fill - marker['pattern'] = pattern - marker['gradient'] = gradient - - return marker - - def _get_trendline_properties(self, trendline): - # Convert user trendline properties to structure required internally. - - if not trendline: - return - - # Copy the user defined properties since they will be modified. - trendline = copy.deepcopy(trendline) - - types = { - 'exponential': 'exp', - 'linear': 'linear', - 'log': 'log', - 'moving_average': 'movingAvg', - 'polynomial': 'poly', - 'power': 'power', - } - - # Check the trendline type. - trend_type = trendline.get('type') - - if trend_type in types: - trendline['type'] = types[trend_type] - else: - warn("Unknown trendline type '%s'" % trend_type) - return - - # Set the line properties for the trendline. - line = Shape._get_line_properties(trendline.get('line')) - - # Allow 'border' as a synonym for 'line'. - if 'border' in trendline: - line = Shape._get_line_properties(trendline['border']) - - # Set the fill properties for the trendline. - fill = Shape._get_fill_properties(trendline.get('fill')) - - # Set the pattern fill properties for the series. - pattern = Shape._get_pattern_properties(trendline.get('pattern')) - - # Set the gradient fill properties for the series. - gradient = Shape._get_gradient_properties(trendline.get('gradient')) - - # Pattern fill overrides solid fill. - if pattern: - self.fill = None - - # Gradient fill overrides the solid and pattern fill. - if gradient: - pattern = None - fill = None - - trendline['line'] = line - trendline['fill'] = fill - trendline['pattern'] = pattern - trendline['gradient'] = gradient - - return trendline - - def _get_error_bars_props(self, options): - # Convert user error bars properties to structure required internally. - if not options: - return - - # Default values. - error_bars = { - 'type': 'fixedVal', - 'value': 1, - 'endcap': 1, - 'direction': 'both' - } - - types = { - 'fixed': 'fixedVal', - 'percentage': 'percentage', - 'standard_deviation': 'stdDev', - 'standard_error': 'stdErr', - 'custom': 'cust', - } - - # Check the error bars type. - error_type = options['type'] - - if error_type in types: - error_bars['type'] = types[error_type] - else: - warn("Unknown error bars type '%s" % error_type) - return - - # Set the value for error types that require it. - if 'value' in options: - error_bars['value'] = options['value'] - - # Set the end-cap style. - if 'end_style' in options: - error_bars['endcap'] = options['end_style'] - - # Set the error bar direction. - if 'direction' in options: - if options['direction'] == 'minus': - error_bars['direction'] = 'minus' - elif options['direction'] == 'plus': - error_bars['direction'] = 'plus' - else: - # Default to 'both'. - pass - - # Set any custom values. - error_bars['plus_values'] = options.get('plus_values') - error_bars['minus_values'] = options.get('minus_values') - error_bars['plus_data'] = options.get('plus_data') - error_bars['minus_data'] = options.get('minus_data') - - # Set the line properties for the error bars. - error_bars['line'] = Shape._get_line_properties(options.get('line')) - error_bars['fill'] = Shape._get_line_properties(options.get('fill')) - - return error_bars - - def _get_gridline_properties(self, options): - # Convert user gridline properties to structure required internally. - - # Set the visible property for the gridline. - gridline = {'visible': options.get('visible')} - - # Set the line properties for the gridline. - gridline['line'] = Shape._get_line_properties(options.get('line')) - gridline['fill'] = Shape._get_line_properties(options.get('fill')) - - return gridline - - def _get_labels_properties(self, labels): - # Convert user labels properties to the structure required internally. - - if not labels: - return None - - # Copy the user defined properties since they will be modified. - labels = copy.deepcopy(labels) - - # Map user defined label positions to Excel positions. - position = labels.get('position') - - if position: - if position in self.label_positions: - if position == self.label_position_default: - labels['position'] = None - else: - labels['position'] = self.label_positions[position] - else: - warn("Unsupported label position '%s' for this chart type" - % position) - return - - # Map the user defined label separator to the Excel separator. - separator = labels.get('separator') - separators = { - ',': ', ', - ';': '; ', - '.': '. ', - "\n": "\n", - ' ': ' ', - } - - if separator: - if separator in separators: - labels['separator'] = separators[separator] - else: - warn("Unsupported label separator") - return - - # Set the font properties if present. - labels['font'] = self._convert_font_args(labels.get('font')) - - return labels - - def _get_area_properties(self, options): - # Convert user area properties to the structure required internally. - area = {} - - # Set the line properties for the chartarea. - line = Shape._get_line_properties(options.get('line')) - - # Allow 'border' as a synonym for 'line'. - if options.get('border'): - line = Shape._get_line_properties(options['border']) - - # Set the fill properties for the chartarea. - fill = Shape._get_fill_properties(options.get('fill')) - - # Set the pattern fill properties for the series. - pattern = Shape._get_pattern_properties(options.get('pattern')) - - # Set the gradient fill properties for the series. - gradient = Shape._get_gradient_properties(options.get('gradient')) - - # Pattern fill overrides solid fill. - if pattern: - self.fill = None - - # Gradient fill overrides the solid and pattern fill. - if gradient: - pattern = None - fill = None - - # Set the plotarea layout. - layout = self._get_layout_properties(options.get('layout'), False) - - area['line'] = line - area['fill'] = fill - area['pattern'] = pattern - area['layout'] = layout - area['gradient'] = gradient - - return area - - def _get_layout_properties(self, args, is_text): - # Convert user defined layout properties to format used internally. - layout = {} - - if not args: - return - - if is_text: - properties = ('x', 'y') - else: - properties = ('x', 'y', 'width', 'height') - - # Check for valid properties. - for key in args.keys(): - if key not in properties: - warn("Property '%s' allowed not in layout options" % key) - return - - # Set the layout properties. - for prop in properties: - if prop not in args.keys(): - warn("Property '%s' must be specified in layout options" - % prop) - return - - value = args[prop] - - try: - float(value) - except ValueError: - warn("Property '%s' value '%s' must be numeric in layout" % - (prop, value)) - return - - if value < 0 or value > 1: - warn("Property '%s' value '%s' must be in range " - "0 < x <= 1 in layout options" % (prop, value)) - return - - # Convert to the format used by Excel for easier testing - layout[prop] = "%.17g" % value - - return layout - - def _get_points_properties(self, user_points): - # Convert user points properties to structure required internally. - points = [] - - if not user_points: - return - - for user_point in user_points: - point = {} - - if user_point is not None: - - # Set the line properties for the point. - line = Shape._get_line_properties(user_point.get('line')) - - # Allow 'border' as a synonym for 'line'. - if 'border' in user_point: - line = Shape._get_line_properties(user_point['border']) - - # Set the fill properties for the chartarea. - fill = Shape._get_fill_properties(user_point.get('fill')) - - # Set the pattern fill properties for the series. - pattern = \ - Shape._get_pattern_properties(user_point.get('pattern')) - - # Set the gradient fill properties for the series. - gradient = \ - Shape._get_gradient_properties(user_point.get('gradient')) - - # Pattern fill overrides solid fill. - if pattern: - self.fill = None - - # Gradient fill overrides the solid and pattern fill. - if gradient: - pattern = None - fill = None - - point['line'] = line - point['fill'] = fill - point['pattern'] = pattern - point['gradient'] = gradient - - points.append(point) - - return points - - def _get_display_units(self, display_units): - # Convert user defined display units to internal units. - if not display_units: - return - - types = { - 'hundreds': 'hundreds', - 'thousands': 'thousands', - 'ten_thousands': 'tenThousands', - 'hundred_thousands': 'hundredThousands', - 'millions': 'millions', - 'ten_millions': 'tenMillions', - 'hundred_millions': 'hundredMillions', - 'billions': 'billions', - 'trillions': 'trillions', - } - - if display_units in types: - display_units = types[display_units] - else: - warn("Unknown display_units type '%s'" % display_units) - return - - return display_units - - def _get_tick_type(self, tick_type): - # Convert user defined display units to internal units. - if not tick_type: - return - - types = { - 'outside': 'out', - 'inside': 'in', - 'none': 'none', - 'cross': 'cross', - } - - if tick_type in types: - tick_type = types[tick_type] - else: - warn("Unknown tick_type '%s'" % tick_type) - return - - return tick_type - - def _get_primary_axes_series(self): - # Returns series which use the primary axes. - primary_axes_series = [] - - for series in self.series: - if not series['y2_axis']: - primary_axes_series.append(series) - - return primary_axes_series - - def _get_secondary_axes_series(self): - # Returns series which use the secondary axes. - secondary_axes_series = [] - - for series in self.series: - if series['y2_axis']: - secondary_axes_series.append(series) - - return secondary_axes_series - - def _add_axis_ids(self, args): - # Add unique ids for primary or secondary axes - chart_id = 5001 + int(self.id) - axis_count = 1 + len(self.axis2_ids) + len(self.axis_ids) - - id1 = '%04d%04d' % (chart_id, axis_count) - id2 = '%04d%04d' % (chart_id, axis_count + 1) - - if args['primary_axes']: - self.axis_ids.append(id1) - self.axis_ids.append(id2) - - if not args['primary_axes']: - self.axis2_ids.append(id1) - self.axis2_ids.append(id2) - - def _set_default_properties(self): - # Setup the default properties for a chart. - - self.x_axis['defaults'] = { - 'num_format': 'General', - 'major_gridlines': {'visible': 0} - } - - self.y_axis['defaults'] = { - 'num_format': 'General', - 'major_gridlines': {'visible': 1} - } - - self.x2_axis['defaults'] = { - 'num_format': 'General', - 'label_position': 'none', - 'crossing': 'max', - 'visible': 0 - } - - self.y2_axis['defaults'] = { - 'num_format': 'General', - 'major_gridlines': {'visible': 0}, - 'position': 'right', - 'visible': 1 - } - - self.set_x_axis({}) - self.set_y_axis({}) - - self.set_x2_axis({}) - self.set_y2_axis({}) - - ########################################################################### - # - # XML methods. - # - ########################################################################### - - def _write_chart_space(self): - # Write the <c:chartSpace> element. - schema = 'http://schemas.openxmlformats.org/' - xmlns_c = schema + 'drawingml/2006/chart' - xmlns_a = schema + 'drawingml/2006/main' - xmlns_r = schema + 'officeDocument/2006/relationships' - - attributes = [ - ('xmlns:c', xmlns_c), - ('xmlns:a', xmlns_a), - ('xmlns:r', xmlns_r), - ] - - self._xml_start_tag('c:chartSpace', attributes) - - def _write_lang(self): - # Write the <c:lang> element. - val = 'en-US' - - attributes = [('val', val)] - - self._xml_empty_tag('c:lang', attributes) - - def _write_style(self): - # Write the <c:style> element. - style_id = self.style_id - - # Don't write an element for the default style, 2. - if style_id == 2: - return - - attributes = [('val', style_id)] - - self._xml_empty_tag('c:style', attributes) - - def _write_chart(self): - # Write the <c:chart> element. - self._xml_start_tag('c:chart') - - if self.title_none: - # Turn off the title. - self._write_c_auto_title_deleted() - else: - # Write the chart title elements. - if self.title_formula is not None: - self._write_title_formula(self.title_formula, - self.title_data_id, - None, - self.title_font, - self.title_layout, - self.title_overlay) - elif self.title_name is not None: - self._write_title_rich(self.title_name, - None, - self.title_font, - self.title_layout, - self.title_overlay) - - # Write the c:plotArea element. - self._write_plot_area() - - # Write the c:legend element. - self._write_legend() - - # Write the c:plotVisOnly element. - self._write_plot_vis_only() - - # Write the c:dispBlanksAs element. - self._write_disp_blanks_as() - - self._xml_end_tag('c:chart') - - def _write_disp_blanks_as(self): - # Write the <c:dispBlanksAs> element. - val = self.show_blanks - - # Ignore the default value. - if val == 'gap': - return - - attributes = [('val', val)] - - self._xml_empty_tag('c:dispBlanksAs', attributes) - - def _write_plot_area(self): - # Write the <c:plotArea> element. - self._xml_start_tag('c:plotArea') - - # Write the c:layout element. - self._write_layout(self.plotarea.get('layout'), 'plot') - - # Write subclass chart type elements for primary and secondary axes. - self._write_chart_type({'primary_axes': True}) - self._write_chart_type({'primary_axes': False}) - - # Configure a combined chart if present. - second_chart = self.combined - if second_chart: - # Secondary axis has unique id otherwise use same as primary. - if second_chart.is_secondary: - second_chart.id = 1000 + self.id - else: - second_chart.id = self.id - - # Share the same filehandle for writing. - second_chart.fh = self.fh - - # Share series index with primary chart. - second_chart.series_index = self.series_index - - # Write the subclass chart type elements for combined chart. - second_chart._write_chart_type({'primary_axes': True}) - second_chart._write_chart_type({'primary_axes': False}) - - # Write the category and value elements for the primary axes. - args = {'x_axis': self.x_axis, - 'y_axis': self.y_axis, - 'axis_ids': self.axis_ids} - - if self.date_category: - self._write_date_axis(args) - else: - self._write_cat_axis(args) - - self._write_val_axis(args) - - # Write the category and value elements for the secondary axes. - args = {'x_axis': self.x2_axis, - 'y_axis': self.y2_axis, - 'axis_ids': self.axis2_ids} - - self._write_val_axis(args) - - # Write the secondary axis for the secondary chart. - if second_chart and second_chart.is_secondary: - args = {'x_axis': second_chart.x2_axis, - 'y_axis': second_chart.y2_axis, - 'axis_ids': second_chart.axis2_ids} - - second_chart._write_val_axis(args) - - if self.date_category: - self._write_date_axis(args) - else: - self._write_cat_axis(args) - - # Write the c:dTable element. - self._write_d_table() - - # Write the c:spPr element for the plotarea formatting. - self._write_sp_pr(self.plotarea) - - self._xml_end_tag('c:plotArea') - - def _write_layout(self, layout, layout_type): - # Write the <c:layout> element. - - if not layout: - # Automatic layout. - self._xml_empty_tag('c:layout') - else: - # User defined manual layout. - self._xml_start_tag('c:layout') - self._write_manual_layout(layout, layout_type) - self._xml_end_tag('c:layout') - - def _write_manual_layout(self, layout, layout_type): - # Write the <c:manualLayout> element. - self._xml_start_tag('c:manualLayout') - - # Plotarea has a layoutTarget element. - if layout_type == 'plot': - self._xml_empty_tag('c:layoutTarget', [('val', 'inner')]) - - # Set the x, y positions. - self._xml_empty_tag('c:xMode', [('val', 'edge')]) - self._xml_empty_tag('c:yMode', [('val', 'edge')]) - self._xml_empty_tag('c:x', [('val', layout['x'])]) - self._xml_empty_tag('c:y', [('val', layout['y'])]) - - # For plotarea and legend set the width and height. - if layout_type != 'text': - self._xml_empty_tag('c:w', [('val', layout['width'])]) - self._xml_empty_tag('c:h', [('val', layout['height'])]) - - self._xml_end_tag('c:manualLayout') - - def _write_chart_type(self, options): - # Write the chart type element. This method should be overridden - # by the subclasses. - return - - def _write_grouping(self, val): - # Write the <c:grouping> element. - attributes = [('val', val)] - - self._xml_empty_tag('c:grouping', attributes) - - def _write_series(self, series): - # Write the series elements. - self._write_ser(series) - - def _write_ser(self, series): - # Write the <c:ser> element. - index = self.series_index - self.series_index += 1 - - self._xml_start_tag('c:ser') - - # Write the c:idx element. - self._write_idx(index) - - # Write the c:order element. - self._write_order(index) - - # Write the series name. - self._write_series_name(series) - - # Write the c:spPr element. - self._write_sp_pr(series) - - # Write the c:marker element. - self._write_marker(series['marker']) - - # Write the c:invertIfNegative element. - self._write_c_invert_if_negative(series['invert_if_neg']) - - # Write the c:dPt element. - self._write_d_pt(series['points']) - - # Write the c:dLbls element. - self._write_d_lbls(series['labels']) - - # Write the c:trendline element. - self._write_trendline(series['trendline']) - - # Write the c:errBars element. - self._write_error_bars(series['error_bars']) - - # Write the c:cat element. - self._write_cat(series) - - # Write the c:val element. - self._write_val(series) - - # Write the c:smooth element. - if self.smooth_allowed: - self._write_c_smooth(series['smooth']) - - self._xml_end_tag('c:ser') - - def _write_idx(self, val): - # Write the <c:idx> element. - - attributes = [('val', val)] - - self._xml_empty_tag('c:idx', attributes) - - def _write_order(self, val): - # Write the <c:order> element. - - attributes = [('val', val)] - - self._xml_empty_tag('c:order', attributes) - - def _write_series_name(self, series): - # Write the series name. - - if series['name_formula'] is not None: - self._write_tx_formula(series['name_formula'], series['name_id']) - elif series['name'] is not None: - self._write_tx_value(series['name']) - - def _write_c_smooth(self, smooth): - # Write the <c:smooth> element. - - if smooth: - self._xml_empty_tag('c:smooth', [('val', '1')]) - - def _write_cat(self, series): - # Write the <c:cat> element. - formula = series['categories'] - data_id = series['cat_data_id'] - data = None - - if data_id is not None: - data = self.formula_data[data_id] - - # Ignore <c:cat> elements for charts without category values. - if not formula: - return - - self._xml_start_tag('c:cat') - - # Check the type of cached data. - cat_type = self._get_data_type(data) - - if cat_type == 'str': - self.cat_has_num_fmt = 0 - # Write the c:numRef element. - self._write_str_ref(formula, data, cat_type) - - elif cat_type == 'multi_str': - self.cat_has_num_fmt = 0 - # Write the c:numRef element. - self._write_multi_lvl_str_ref(formula, data) - - else: - self.cat_has_num_fmt = 1 - # Write the c:numRef element. - self._write_num_ref(formula, data, cat_type) - - self._xml_end_tag('c:cat') - - def _write_val(self, series): - # Write the <c:val> element. - formula = series['values'] - data_id = series['val_data_id'] - data = self.formula_data[data_id] - - self._xml_start_tag('c:val') - - # Unlike Cat axes data should only be numeric. - # Write the c:numRef element. - self._write_num_ref(formula, data, 'num') - - self._xml_end_tag('c:val') - - def _write_num_ref(self, formula, data, ref_type): - # Write the <c:numRef> element. - self._xml_start_tag('c:numRef') - - # Write the c:f element. - self._write_series_formula(formula) - - if ref_type == 'num': - # Write the c:numCache element. - self._write_num_cache(data) - elif ref_type == 'str': - # Write the c:strCache element. - self._write_str_cache(data) - - self._xml_end_tag('c:numRef') - - def _write_str_ref(self, formula, data, ref_type): - # Write the <c:strRef> element. - - self._xml_start_tag('c:strRef') - - # Write the c:f element. - self._write_series_formula(formula) - - if ref_type == 'num': - # Write the c:numCache element. - self._write_num_cache(data) - elif ref_type == 'str': - # Write the c:strCache element. - self._write_str_cache(data) - - self._xml_end_tag('c:strRef') - - def _write_multi_lvl_str_ref(self, formula, data): - # Write the <c:multiLvlStrRef> element. - - if not data: - return - - self._xml_start_tag('c:multiLvlStrRef') - - # Write the c:f element. - self._write_series_formula(formula) - - self._xml_start_tag('c:multiLvlStrCache') - - # Write the c:ptCount element. - count = len(data[-1]) - self._write_pt_count(count) - - for cat_data in reversed(data): - - self._xml_start_tag('c:lvl') - - for i, point in enumerate(cat_data): - # Write the c:pt element. - self._write_pt(i, cat_data[i]) - - self._xml_end_tag('c:lvl') - - self._xml_end_tag('c:multiLvlStrCache') - self._xml_end_tag('c:multiLvlStrRef') - - def _write_series_formula(self, formula): - # Write the <c:f> element. - - # Strip the leading '=' from the formula. - if formula.startswith('='): - formula = formula.lstrip('=') - - self._xml_data_element('c:f', formula) - - def _write_axis_ids(self, args): - # Write the <c:axId> elements for the primary or secondary axes. - - # Generate the axis ids. - self._add_axis_ids(args) - - if args['primary_axes']: - # Write the axis ids for the primary axes. - self._write_axis_id(self.axis_ids[0]) - self._write_axis_id(self.axis_ids[1]) - else: - # Write the axis ids for the secondary axes. - self._write_axis_id(self.axis2_ids[0]) - self._write_axis_id(self.axis2_ids[1]) - - def _write_axis_id(self, val): - # Write the <c:axId> element. - - attributes = [('val', val)] - - self._xml_empty_tag('c:axId', attributes) - - def _write_cat_axis(self, args): - # Write the <c:catAx> element. Usually the X axis. - x_axis = args['x_axis'] - y_axis = args['y_axis'] - axis_ids = args['axis_ids'] - - # If there are no axis_ids then we don't need to write this element. - if axis_ids is None or not len(axis_ids): - return - - position = self.cat_axis_position - horiz = self.horiz_cat_axis - - # Overwrite the default axis position with a user supplied value. - if x_axis.get('position'): - position = x_axis['position'] - - self._xml_start_tag('c:catAx') - - self._write_axis_id(axis_ids[0]) - - # Write the c:scaling element. - self._write_scaling(x_axis.get('reverse'), - None, - None, - None) - - if not x_axis.get('visible'): - self._write_delete(1) - - # Write the c:axPos element. - self._write_axis_pos(position, y_axis.get('reverse')) - - # Write the c:majorGridlines element. - self._write_major_gridlines(x_axis.get('major_gridlines')) - - # Write the c:minorGridlines element. - self._write_minor_gridlines(x_axis.get('minor_gridlines')) - - # Write the axis title elements. - if x_axis['formula'] is not None: - self._write_title_formula(x_axis['formula'], - x_axis['data_id'], - horiz, - x_axis['name_font'], - x_axis['name_layout']) - elif x_axis['name'] is not None: - self._write_title_rich(x_axis['name'], - horiz, - x_axis['name_font'], - x_axis['name_layout']) - - # Write the c:numFmt element. - self._write_cat_number_format(x_axis) - - # Write the c:majorTickMark element. - self._write_major_tick_mark(x_axis.get('major_tick_mark')) - - # Write the c:minorTickMark element. - self._write_minor_tick_mark(x_axis.get('minor_tick_mark')) - - # Write the c:tickLblPos element. - self._write_tick_label_pos(x_axis.get('label_position')) - - # Write the c:spPr element for the axis line. - self._write_sp_pr(x_axis) - - # Write the axis font elements. - self._write_axis_font(x_axis.get('num_font')) - - # Write the c:crossAx element. - self._write_cross_axis(axis_ids[1]) - - if self.show_crosses or x_axis.get('visible'): - - # Note, the category crossing comes from the value axis. - if (y_axis.get('crossing') is None - or y_axis.get('crossing') == 'max'): - - # Write the c:crosses element. - self._write_crosses(y_axis.get('crossing')) - else: - - # Write the c:crossesAt element. - self._write_c_crosses_at(y_axis.get('crossing')) - - # Write the c:auto element. - if not x_axis.get('text_axis'): - self._write_auto(1) - - # Write the c:labelAlign element. - self._write_label_align('ctr') - - # Write the c:labelOffset element. - self._write_label_offset(100) - - # Write the c:tickLblSkip element. - self._write_c_tick_lbl_skip(x_axis.get('interval_unit')) - - # Write the c:tickMarkSkip element. - self._write_c_tick_mark_skip(x_axis.get('interval_tick')) - - self._xml_end_tag('c:catAx') - - def _write_val_axis(self, args): - # Write the <c:valAx> element. Usually the Y axis. - x_axis = args['x_axis'] - y_axis = args['y_axis'] - axis_ids = args['axis_ids'] - position = args.get('position', self.val_axis_position) - horiz = self.horiz_val_axis - - # If there are no axis_ids then we don't need to write this element. - if axis_ids is None or not len(axis_ids): - return - - # Overwrite the default axis position with a user supplied value. - position = y_axis.get('position') or position - - self._xml_start_tag('c:valAx') - - self._write_axis_id(axis_ids[1]) - - # Write the c:scaling element. - self._write_scaling(y_axis.get('reverse'), - y_axis.get('min'), - y_axis.get('max'), - y_axis.get('log_base')) - - if not y_axis.get('visible'): - self._write_delete(1) - - # Write the c:axPos element. - self._write_axis_pos(position, x_axis.get('reverse')) - - # Write the c:majorGridlines element. - self._write_major_gridlines(y_axis.get('major_gridlines')) - - # Write the c:minorGridlines element. - self._write_minor_gridlines(y_axis.get('minor_gridlines')) - - # Write the axis title elements. - if y_axis['formula'] is not None: - self._write_title_formula(y_axis['formula'], - y_axis['data_id'], - horiz, - y_axis['name_font'], - y_axis['name_layout']) - elif y_axis['name'] is not None: - self._write_title_rich(y_axis['name'], - horiz, - y_axis.get('name_font'), - y_axis.get('name_layout')) - - # Write the c:numberFormat element. - self._write_number_format(y_axis) - - # Write the c:majorTickMark element. - self._write_major_tick_mark(y_axis.get('major_tick_mark')) - - # Write the c:minorTickMark element. - self._write_minor_tick_mark(y_axis.get('minor_tick_mark')) - - # Write the c:tickLblPos element. - self._write_tick_label_pos(y_axis.get('label_position')) - - # Write the c:spPr element for the axis line. - self._write_sp_pr(y_axis) - - # Write the axis font elements. - self._write_axis_font(y_axis.get('num_font')) - - # Write the c:crossAx element. - self._write_cross_axis(axis_ids[0]) - - # Note, the category crossing comes from the value axis. - if x_axis.get('crossing') is None or x_axis['crossing'] == 'max': - - # Write the c:crosses element. - self._write_crosses(x_axis.get('crossing')) - else: - - # Write the c:crossesAt element. - self._write_c_crosses_at(x_axis.get('crossing')) - - # Write the c:crossBetween element. - self._write_cross_between(x_axis.get('position_axis')) - - # Write the c:majorUnit element. - self._write_c_major_unit(y_axis.get('major_unit')) - - # Write the c:minorUnit element. - self._write_c_minor_unit(y_axis.get('minor_unit')) - - # Write the c:dispUnits element. - self._write_disp_units(y_axis.get('display_units'), - y_axis.get('display_units_visible')) - - self._xml_end_tag('c:valAx') - - def _write_cat_val_axis(self, args): - # Write the <c:valAx> element. This is for the second valAx - # in scatter plots. Usually the X axis. - x_axis = args['x_axis'] - y_axis = args['y_axis'] - axis_ids = args['axis_ids'] - position = args['position'] or self.val_axis_position - horiz = self.horiz_val_axis - - # If there are no axis_ids then we don't need to write this element. - if axis_ids is None or not len(axis_ids): - return - - # Overwrite the default axis position with a user supplied value. - position = x_axis.get('position') or position - - self._xml_start_tag('c:valAx') - - self._write_axis_id(axis_ids[0]) - - # Write the c:scaling element. - self._write_scaling(x_axis.get('reverse'), - x_axis.get('min'), - x_axis.get('max'), - x_axis.get('log_base')) - - if not x_axis.get('visible'): - self._write_delete(1) - - # Write the c:axPos element. - self._write_axis_pos(position, y_axis.get('reverse')) - - # Write the c:majorGridlines element. - self._write_major_gridlines(x_axis.get('major_gridlines')) - - # Write the c:minorGridlines element. - self._write_minor_gridlines(x_axis.get('minor_gridlines')) - - # Write the axis title elements. - if x_axis['formula'] is not None: - self._write_title_formula(x_axis['formula'], - x_axis['data_id'], - horiz, - x_axis['name_font'], - x_axis['name_layout']) - elif x_axis['name'] is not None: - self._write_title_rich(x_axis['name'], - horiz, - x_axis['name_font'], - x_axis['name_layout']) - - # Write the c:numberFormat element. - self._write_number_format(x_axis) - - # Write the c:majorTickMark element. - self._write_major_tick_mark(x_axis.get('major_tick_mark')) - - # Write the c:minorTickMark element. - self._write_minor_tick_mark(x_axis.get('minor_tick_mark')) - - # Write the c:tickLblPos element. - self._write_tick_label_pos(x_axis.get('label_position')) - - # Write the c:spPr element for the axis line. - self._write_sp_pr(x_axis) - - # Write the axis font elements. - self._write_axis_font(x_axis.get('num_font')) - - # Write the c:crossAx element. - self._write_cross_axis(axis_ids[1]) - - # Note, the category crossing comes from the value axis. - if y_axis.get('crossing') is None or y_axis['crossing'] == 'max': - - # Write the c:crosses element. - self._write_crosses(y_axis.get('crossing')) - else: - - # Write the c:crossesAt element. - self._write_c_crosses_at(y_axis.get('crossing')) - - # Write the c:crossBetween element. - self._write_cross_between(y_axis.get('position_axis')) - - # Write the c:majorUnit element. - self._write_c_major_unit(x_axis.get('major_unit')) - - # Write the c:minorUnit element. - self._write_c_minor_unit(x_axis.get('minor_unit')) - - # Write the c:dispUnits element. - self._write_disp_units(x_axis.get('display_units'), - x_axis.get('display_units_visible')) - - self._xml_end_tag('c:valAx') - - def _write_date_axis(self, args): - # Write the <c:dateAx> element. Usually the X axis. - x_axis = args['x_axis'] - y_axis = args['y_axis'] - axis_ids = args['axis_ids'] - - # If there are no axis_ids then we don't need to write this element. - if axis_ids is None or not len(axis_ids): - return - - position = self.cat_axis_position - - # Overwrite the default axis position with a user supplied value. - position = x_axis.get('position') or position - - self._xml_start_tag('c:dateAx') - - self._write_axis_id(axis_ids[0]) - - # Write the c:scaling element. - self._write_scaling(x_axis.get('reverse'), - x_axis.get('min'), - x_axis.get('max'), - x_axis.get('log_base')) - - if not x_axis.get('visible'): - self._write_delete(1) - - # Write the c:axPos element. - self._write_axis_pos(position, y_axis.get('reverse')) - - # Write the c:majorGridlines element. - self._write_major_gridlines(x_axis.get('major_gridlines')) - - # Write the c:minorGridlines element. - self._write_minor_gridlines(x_axis.get('minor_gridlines')) - - # Write the axis title elements. - if x_axis['formula'] is not None: - self._write_title_formula(x_axis['formula'], - x_axis['data_id'], - None, - x_axis['name_font'], - x_axis['name_layout']) - elif x_axis['name'] is not None: - self._write_title_rich(x_axis['name'], - None, - x_axis['name_font'], - x_axis['name_layout']) - - # Write the c:numFmt element. - self._write_number_format(x_axis) - - # Write the c:majorTickMark element. - self._write_major_tick_mark(x_axis.get('major_tick_mark')) - - # Write the c:minorTickMark element. - self._write_minor_tick_mark(x_axis.get('minor_tick_mark')) - - # Write the c:tickLblPos element. - self._write_tick_label_pos(x_axis.get('label_position')) - - # Write the c:spPr element for the axis line. - self._write_sp_pr(x_axis) - - # Write the axis font elements. - self._write_axis_font(x_axis.get('num_font')) - - # Write the c:crossAx element. - self._write_cross_axis(axis_ids[1]) - - if self.show_crosses or x_axis.get('visible'): - - # Note, the category crossing comes from the value axis. - if (y_axis.get('crossing') is None - or y_axis.get('crossing') == 'max'): - - # Write the c:crosses element. - self._write_crosses(y_axis.get('crossing')) - else: - - # Write the c:crossesAt element. - self._write_c_crosses_at(y_axis.get('crossing')) - - # Write the c:auto element. - self._write_auto(1) - - # Write the c:labelOffset element. - self._write_label_offset(100) - - # Write the c:tickLblSkip element. - self._write_c_tick_lbl_skip(x_axis.get('interval_unit')) - - # Write the c:tickMarkSkip element. - self._write_c_tick_mark_skip(x_axis.get('interval_tick')) - - # Write the c:majorUnit element. - self._write_c_major_unit(x_axis.get('major_unit')) - - # Write the c:majorTimeUnit element. - if x_axis.get('major_unit'): - self._write_c_major_time_unit(x_axis['major_unit_type']) - - # Write the c:minorUnit element. - self._write_c_minor_unit(x_axis.get('minor_unit')) - - # Write the c:minorTimeUnit element. - if x_axis.get('minor_unit'): - self._write_c_minor_time_unit(x_axis['minor_unit_type']) - - self._xml_end_tag('c:dateAx') - - def _write_scaling(self, reverse, min_val, max_val, log_base): - # Write the <c:scaling> element. - - self._xml_start_tag('c:scaling') - - # Write the c:logBase element. - self._write_c_log_base(log_base) - - # Write the c:orientation element. - self._write_orientation(reverse) - - # Write the c:max element. - self._write_c_max(max_val) - - # Write the c:min element. - self._write_c_min(min_val) - - self._xml_end_tag('c:scaling') - - def _write_c_log_base(self, val): - # Write the <c:logBase> element. - - if not val: - return - - attributes = [('val', val)] - - self._xml_empty_tag('c:logBase', attributes) - - def _write_orientation(self, reverse): - # Write the <c:orientation> element. - val = 'minMax' - - if reverse: - val = 'maxMin' - - attributes = [('val', val)] - - self._xml_empty_tag('c:orientation', attributes) - - def _write_c_max(self, max_val): - # Write the <c:max_val> element. - - if max_val is None: - return - - attributes = [('val', max_val)] - - self._xml_empty_tag('c:max', attributes) - - def _write_c_min(self, min_val): - # Write the <c:min_val> element. - - if min_val is None: - return - - attributes = [('val', min_val)] - - self._xml_empty_tag('c:min', attributes) - - def _write_axis_pos(self, val, reverse): - # Write the <c:axPos> element. - - if reverse: - if val == 'l': - val = 'r' - if val == 'b': - val = 't' - - attributes = [('val', val)] - - self._xml_empty_tag('c:axPos', attributes) - - def _write_number_format(self, axis): - # Write the <c:numberFormat> element. Note: It is assumed that if - # a user defined number format is supplied (i.e., non-default) then - # the sourceLinked attribute is 0. - # The user can override this if required. - format_code = axis.get('num_format') - source_linked = 1 - - # Check if a user defined number format has been set. - if (format_code is not None - and format_code != axis['defaults']['num_format']): - source_linked = 0 - - # User override of sourceLinked. - if axis.get('num_format_linked'): - source_linked = 1 - - attributes = [ - ('formatCode', format_code), - ('sourceLinked', source_linked), - ] - - self._xml_empty_tag('c:numFmt', attributes) - - def _write_cat_number_format(self, axis): - # Write the <c:numFmt> element. Special case handler for category - # axes which don't always have a number format. - format_code = axis.get('num_format') - source_linked = 1 - default_format = 1 - - # Check if a user defined number format has been set. - if (format_code is not None - and format_code != axis['defaults']['num_format']): - source_linked = 0 - default_format = 0 - - # User override of linkedSource. - if axis.get('num_format_linked'): - source_linked = 1 - - # Skip if cat doesn't have a num format (unless it is non-default). - if not self.cat_has_num_fmt and default_format: - return - - attributes = [ - ('formatCode', format_code), - ('sourceLinked', source_linked), - ] - - self._xml_empty_tag('c:numFmt', attributes) - - def _write_data_label_number_format(self, format_code): - # Write the <c:numberFormat> element for data labels. - source_linked = 0 - - attributes = [ - ('formatCode', format_code), - ('sourceLinked', source_linked), - ] - - self._xml_empty_tag('c:numFmt', attributes) - - def _write_major_tick_mark(self, val): - # Write the <c:majorTickMark> element. - - if not val: - return - - attributes = [('val', val)] - - self._xml_empty_tag('c:majorTickMark', attributes) - - def _write_minor_tick_mark(self, val): - # Write the <c:minorTickMark> element. - - if not val: - return - - attributes = [('val', val)] - - self._xml_empty_tag('c:minorTickMark', attributes) - - def _write_tick_label_pos(self, val=None): - # Write the <c:tickLblPos> element. - if val is None or val == 'next_to': - val = 'nextTo' - - attributes = [('val', val)] - - self._xml_empty_tag('c:tickLblPos', attributes) - - def _write_cross_axis(self, val): - # Write the <c:crossAx> element. - - attributes = [('val', val)] - - self._xml_empty_tag('c:crossAx', attributes) - - def _write_crosses(self, val=None): - # Write the <c:crosses> element. - if val is None: - val = 'autoZero' - - attributes = [('val', val)] - - self._xml_empty_tag('c:crosses', attributes) - - def _write_c_crosses_at(self, val): - # Write the <c:crossesAt> element. - - attributes = [('val', val)] - - self._xml_empty_tag('c:crossesAt', attributes) - - def _write_auto(self, val): - # Write the <c:auto> element. - - attributes = [('val', val)] - - self._xml_empty_tag('c:auto', attributes) - - def _write_label_align(self, val): - # Write the <c:labelAlign> element. - - attributes = [('val', val)] - - self._xml_empty_tag('c:lblAlgn', attributes) - - def _write_label_offset(self, val): - # Write the <c:labelOffset> element. - - attributes = [('val', val)] - - self._xml_empty_tag('c:lblOffset', attributes) - - def _write_c_tick_lbl_skip(self, val): - # Write the <c:tickLblSkip> element. - if val is None: - return - - attributes = [('val', val)] - - self._xml_empty_tag('c:tickLblSkip', attributes) - - def _write_c_tick_mark_skip(self, val): - # Write the <c:tickMarkSkip> element. - if val is None: - return - - attributes = [('val', val)] - - self._xml_empty_tag('c:tickMarkSkip', attributes) - - def _write_major_gridlines(self, gridlines): - # Write the <c:majorGridlines> element. - - if not gridlines: - return - - if not gridlines['visible']: - return - - if gridlines['line']['defined']: - self._xml_start_tag('c:majorGridlines') - - # Write the c:spPr element. - self._write_sp_pr(gridlines) - - self._xml_end_tag('c:majorGridlines') - else: - self._xml_empty_tag('c:majorGridlines') - - def _write_minor_gridlines(self, gridlines): - # Write the <c:minorGridlines> element. - - if not gridlines: - return - - if not gridlines['visible']: - return - - if gridlines['line']['defined']: - self._xml_start_tag('c:minorGridlines') - - # Write the c:spPr element. - self._write_sp_pr(gridlines) - - self._xml_end_tag('c:minorGridlines') - else: - self._xml_empty_tag('c:minorGridlines') - - def _write_cross_between(self, val): - # Write the <c:crossBetween> element. - if val is None: - val = self.cross_between - - attributes = [('val', val)] - - self._xml_empty_tag('c:crossBetween', attributes) - - def _write_c_major_unit(self, val): - # Write the <c:majorUnit> element. - - if not val: - return - - attributes = [('val', val)] - - self._xml_empty_tag('c:majorUnit', attributes) - - def _write_c_minor_unit(self, val): - # Write the <c:minorUnit> element. - - if not val: - return - - attributes = [('val', val)] - - self._xml_empty_tag('c:minorUnit', attributes) - - def _write_c_major_time_unit(self, val=None): - # Write the <c:majorTimeUnit> element. - if val is None: - val = 'days' - - attributes = [('val', val)] - - self._xml_empty_tag('c:majorTimeUnit', attributes) - - def _write_c_minor_time_unit(self, val=None): - # Write the <c:minorTimeUnit> element. - if val is None: - val = 'days' - - attributes = [('val', val)] - - self._xml_empty_tag('c:minorTimeUnit', attributes) - - def _write_legend(self): - # Write the <c:legend> element. - position = self.legend_position - font = self.legend_font - delete_series = [] - overlay = 0 - - if (self.legend_delete_series is not None - and type(self.legend_delete_series) is list): - delete_series = self.legend_delete_series - - if position.startswith('overlay_'): - position = position.replace('overlay_', '') - overlay = 1 - - allowed = { - 'right': 'r', - 'left': 'l', - 'top': 't', - 'bottom': 'b', - } - - if position == 'none': - return - - if position not in allowed: - return - - position = allowed[position] - - self._xml_start_tag('c:legend') - - # Write the c:legendPos element. - self._write_legend_pos(position) - - # Remove series labels from the legend. - for index in delete_series: - # Write the c:legendEntry element. - self._write_legend_entry(index) - - # Write the c:layout element. - self._write_layout(self.legend_layout, 'legend') - - if font: - self._write_tx_pr(None, font) - - # Write the c:overlay element. - if overlay: - self._write_overlay() - - self._xml_end_tag('c:legend') - - def _write_legend_pos(self, val): - # Write the <c:legendPos> element. - - attributes = [('val', val)] - - self._xml_empty_tag('c:legendPos', attributes) - - def _write_legend_entry(self, index): - # Write the <c:legendEntry> element. - - self._xml_start_tag('c:legendEntry') - - # Write the c:idx element. - self._write_idx(index) - - # Write the c:delete element. - self._write_delete(1) - - self._xml_end_tag('c:legendEntry') - - def _write_overlay(self): - # Write the <c:overlay> element. - val = 1 - - attributes = [('val', val)] - - self._xml_empty_tag('c:overlay', attributes) - - def _write_plot_vis_only(self): - # Write the <c:plotVisOnly> element. - val = 1 - - # Ignore this element if we are plotting hidden data. - if self.show_hidden: - return - - attributes = [('val', val)] - - self._xml_empty_tag('c:plotVisOnly', attributes) - - def _write_print_settings(self): - # Write the <c:printSettings> element. - self._xml_start_tag('c:printSettings') - - # Write the c:headerFooter element. - self._write_header_footer() - - # Write the c:pageMargins element. - self._write_page_margins() - - # Write the c:pageSetup element. - self._write_page_setup() - - self._xml_end_tag('c:printSettings') - - def _write_header_footer(self): - # Write the <c:headerFooter> element. - self._xml_empty_tag('c:headerFooter') - - def _write_page_margins(self): - # Write the <c:pageMargins> element. - b = 0.75 - l = 0.7 - r = 0.7 - t = 0.75 - header = 0.3 - footer = 0.3 - - attributes = [ - ('b', b), - ('l', l), - ('r', r), - ('t', t), - ('header', header), - ('footer', footer), - ] - - self._xml_empty_tag('c:pageMargins', attributes) - - def _write_page_setup(self): - # Write the <c:pageSetup> element. - self._xml_empty_tag('c:pageSetup') - - def _write_c_auto_title_deleted(self): - # Write the <c:autoTitleDeleted> element. - self._xml_empty_tag('c:autoTitleDeleted', [('val', 1)]) - - def _write_title_rich(self, title, horiz, font, layout, overlay=False): - # Write the <c:title> element for a rich string. - - self._xml_start_tag('c:title') - - # Write the c:tx element. - self._write_tx_rich(title, horiz, font) - - # Write the c:layout element. - self._write_layout(layout, 'text') - - # Write the c:overlay element. - if overlay: - self._write_overlay() - - self._xml_end_tag('c:title') - - def _write_title_formula(self, title, data_id, horiz, font, layout, - overlay=False): - # Write the <c:title> element for a rich string. - - self._xml_start_tag('c:title') - - # Write the c:tx element. - self._write_tx_formula(title, data_id) - - # Write the c:layout element. - self._write_layout(layout, 'text') - - # Write the c:overlay element. - if overlay: - self._write_overlay() - - # Write the c:txPr element. - self._write_tx_pr(horiz, font) - - self._xml_end_tag('c:title') - - def _write_tx_rich(self, title, horiz, font): - # Write the <c:tx> element. - - self._xml_start_tag('c:tx') - - # Write the c:rich element. - self._write_rich(title, horiz, font) - - self._xml_end_tag('c:tx') - - def _write_tx_value(self, title): - # Write the <c:tx> element with a value such as for series names. - - self._xml_start_tag('c:tx') - - # Write the c:v element. - self._write_v(title) - - self._xml_end_tag('c:tx') - - def _write_tx_formula(self, title, data_id): - # Write the <c:tx> element. - data = None - - if data_id is not None: - data = self.formula_data[data_id] - - self._xml_start_tag('c:tx') - - # Write the c:strRef element. - self._write_str_ref(title, data, 'str') - - self._xml_end_tag('c:tx') - - def _write_rich(self, title, horiz, font): - # Write the <c:rich> element. - - if font and font.get('rotation'): - rotation = font['rotation'] - else: - rotation = None - - self._xml_start_tag('c:rich') - - # Write the a:bodyPr element. - self._write_a_body_pr(rotation, horiz) - - # Write the a:lstStyle element. - self._write_a_lst_style() - - # Write the a:p element. - self._write_a_p_rich(title, font) - - self._xml_end_tag('c:rich') - - def _write_a_body_pr(self, rotation, horiz): - # Write the <a:bodyPr> element. - attributes = [] - - if rotation is None and horiz: - rotation = -5400000 - - if rotation is not None: - attributes.append(('rot', rotation)) - - if horiz: - attributes.append(('vert', 'horz')) - - self._xml_empty_tag('a:bodyPr', attributes) - - def _write_a_lst_style(self): - # Write the <a:lstStyle> element. - self._xml_empty_tag('a:lstStyle') - - def _write_a_p_rich(self, title, font): - # Write the <a:p> element for rich string titles. - - self._xml_start_tag('a:p') - - # Write the a:pPr element. - self._write_a_p_pr_rich(font) - - # Write the a:r element. - self._write_a_r(title, font) - - self._xml_end_tag('a:p') - - def _write_a_p_formula(self, font): - # Write the <a:p> element for formula titles. - - self._xml_start_tag('a:p') - - # Write the a:pPr element. - self._write_a_p_pr_formula(font) - - # Write the a:endParaRPr element. - self._write_a_end_para_rpr() - - self._xml_end_tag('a:p') - - def _write_a_p_pr_rich(self, font): - # Write the <a:pPr> element for rich string titles. - - self._xml_start_tag('a:pPr') - - # Write the a:defRPr element. - self._write_a_def_rpr(font) - - self._xml_end_tag('a:pPr') - - def _write_a_p_pr_formula(self, font): - # Write the <a:pPr> element for formula titles. - - self._xml_start_tag('a:pPr') - - # Write the a:defRPr element. - self._write_a_def_rpr(font) - - self._xml_end_tag('a:pPr') - - def _write_a_def_rpr(self, font): - # Write the <a:defRPr> element. - has_color = 0 - - style_attributes = Shape._get_font_style_attributes(font) - latin_attributes = Shape._get_font_latin_attributes(font) - - if font and font.get('color') is not None: - has_color = 1 - - if latin_attributes or has_color: - self._xml_start_tag('a:defRPr', style_attributes) - - if has_color: - self._write_a_solid_fill({'color': font['color']}) - - if latin_attributes: - self._write_a_latin(latin_attributes) - - self._xml_end_tag('a:defRPr') - else: - self._xml_empty_tag('a:defRPr', style_attributes) - - def _write_a_end_para_rpr(self): - # Write the <a:endParaRPr> element. - lang = 'en-US' - - attributes = [('lang', lang)] - - self._xml_empty_tag('a:endParaRPr', attributes) - - def _write_a_r(self, title, font): - # Write the <a:r> element. - - self._xml_start_tag('a:r') - - # Write the a:rPr element. - self._write_a_r_pr(font) - - # Write the a:t element. - self._write_a_t(title) - - self._xml_end_tag('a:r') - - def _write_a_r_pr(self, font): - # Write the <a:rPr> element. - has_color = 0 - lang = 'en-US' - - style_attributes = Shape._get_font_style_attributes(font) - latin_attributes = Shape._get_font_latin_attributes(font) - - if font and font['color'] is not None: - has_color = 1 - - # Add the lang type to the attributes. - style_attributes.insert(0, ('lang', lang)) - - if latin_attributes or has_color: - self._xml_start_tag('a:rPr', style_attributes) - - if has_color: - self._write_a_solid_fill({'color': font['color']}) - - if latin_attributes: - self._write_a_latin(latin_attributes) - - self._xml_end_tag('a:rPr') - else: - self._xml_empty_tag('a:rPr', style_attributes) - - def _write_a_t(self, title): - # Write the <a:t> element. - - self._xml_data_element('a:t', title) - - def _write_tx_pr(self, horiz, font): - # Write the <c:txPr> element. - - if font and font.get('rotation'): - rotation = font['rotation'] - else: - rotation = None - - self._xml_start_tag('c:txPr') - - # Write the a:bodyPr element. - self._write_a_body_pr(rotation, horiz) - - # Write the a:lstStyle element. - self._write_a_lst_style() - - # Write the a:p element. - self._write_a_p_formula(font) - - self._xml_end_tag('c:txPr') - - def _write_marker(self, marker): - # Write the <c:marker> element. - if marker is None: - marker = self.default_marker - - if not marker: - return - if 'automatic' in marker: - return - - self._xml_start_tag('c:marker') - - # Write the c:symbol element. - self._write_symbol(marker['type']) - - # Write the c:size element. - if marker.get('size'): - self._write_marker_size(marker['size']) - - # Write the c:spPr element. - self._write_sp_pr(marker) - - self._xml_end_tag('c:marker') - - def _write_marker_value(self): - # Write the <c:marker> element without a sub-element. - style = self.default_marker - - if not style: - return - - attributes = [('val', 1)] - - self._xml_empty_tag('c:marker', attributes) - - def _write_marker_size(self, val): - # Write the <c:size> element. - - attributes = [('val', val)] - - self._xml_empty_tag('c:size', attributes) - - def _write_symbol(self, val): - # Write the <c:symbol> element. - - attributes = [('val', val)] - - self._xml_empty_tag('c:symbol', attributes) - - def _write_sp_pr(self, series): - # Write the <c:spPr> element. - - has_fill = False - has_line = False - has_pattern = series.get('pattern') - has_gradient = series.get('gradient') - - if series.get('fill') and series['fill']['defined']: - has_fill = True - - if series.get('line') and series['line']['defined']: - has_line = True - - if (not has_fill and not has_line and not has_pattern - and not has_gradient): - return - - self._xml_start_tag('c:spPr') - - # Write the fill elements for solid charts such as pie and bar. - if series.get('fill') and series['fill']['defined']: - if 'none' in series['fill']: - # Write the a:noFill element. - self._write_a_no_fill() - else: - # Write the a:solidFill element. - self._write_a_solid_fill(series['fill']) - - if series.get('pattern'): - # Write the a:gradFill element. - self._write_a_patt_fill(series['pattern']) - - if series.get('gradient'): - # Write the a:gradFill element. - self._write_a_grad_fill(series['gradient']) - - # Write the a:ln element. - if series.get('line') and series['line']['defined']: - self._write_a_ln(series['line']) - - self._xml_end_tag('c:spPr') - - def _write_a_ln(self, line): - # Write the <a:ln> element. - attributes = [] - - # Add the line width as an attribute. - width = line.get('width') - - if width: - # Round width to nearest 0.25, like Excel. - width = int((width + 0.125) * 4) / 4.0 - - # Convert to internal units. - width = int(0.5 + (12700 * width)) - - attributes = [('w', width)] - - self._xml_start_tag('a:ln', attributes) - - # Write the line fill. - if 'none' in line: - # Write the a:noFill element. - self._write_a_no_fill() - elif 'color' in line: - # Write the a:solidFill element. - self._write_a_solid_fill(line) - - # Write the line/dash type. - line_type = line.get('dash_type') - if line_type: - # Write the a:prstDash element. - self._write_a_prst_dash(line_type) - - self._xml_end_tag('a:ln') - - def _write_a_no_fill(self): - # Write the <a:noFill> element. - self._xml_empty_tag('a:noFill') - - def _write_a_solid_fill(self, fill): - # Write the <a:solidFill> element. - - self._xml_start_tag('a:solidFill') - - if 'color' in fill: - color = get_rgb_color(fill['color']) - transparency = fill.get('transparency') - # Write the a:srgbClr element. - self._write_a_srgb_clr(color, transparency) - - self._xml_end_tag('a:solidFill') - - def _write_a_srgb_clr(self, val, transparency=None): - # Write the <a:srgbClr> element. - attributes = [('val', val)] - - if transparency: - self._xml_start_tag('a:srgbClr', attributes) - - # Write the a:alpha element. - self._write_a_alpha(transparency) - - self._xml_end_tag('a:srgbClr') - else: - self._xml_empty_tag('a:srgbClr', attributes) - - def _write_a_alpha(self, val): - # Write the <a:alpha> element. - - val = int((100 - int(val)) * 1000) - - attributes = [('val', val)] - - self._xml_empty_tag('a:alpha', attributes) - - def _write_a_prst_dash(self, val): - # Write the <a:prstDash> element. - - attributes = [('val', val)] - - self._xml_empty_tag('a:prstDash', attributes) - - def _write_trendline(self, trendline): - # Write the <c:trendline> element. - - if not trendline: - return - - self._xml_start_tag('c:trendline') - - # Write the c:name element. - self._write_name(trendline.get('name')) - - # Write the c:spPr element. - self._write_sp_pr(trendline) - - # Write the c:trendlineType element. - self._write_trendline_type(trendline['type']) - - # Write the c:order element for polynomial trendlines. - if trendline['type'] == 'poly': - self._write_trendline_order(trendline.get('order')) - - # Write the c:period element for moving average trendlines. - if trendline['type'] == 'movingAvg': - self._write_period(trendline.get('period')) - - # Write the c:forward element. - self._write_forward(trendline.get('forward')) - - # Write the c:backward element. - self._write_backward(trendline.get('backward')) - - self._xml_end_tag('c:trendline') - - def _write_trendline_type(self, val): - # Write the <c:trendlineType> element. - - attributes = [('val', val)] - - self._xml_empty_tag('c:trendlineType', attributes) - - def _write_name(self, data): - # Write the <c:name> element. - - if data is None: - return - - self._xml_data_element('c:name', data) - - def _write_trendline_order(self, val): - # Write the <c:order> element. - # val = _[0] is not None ? _[0]: 2 - - attributes = [('val', val)] - - self._xml_empty_tag('c:order', attributes) - - def _write_period(self, val): - # Write the <c:period> element. - # val = _[0] is not None ? _[0]: 2 - - attributes = [('val', val)] - - self._xml_empty_tag('c:period', attributes) - - def _write_forward(self, val): - # Write the <c:forward> element. - - if not val: - return - - attributes = [('val', val)] - - self._xml_empty_tag('c:forward', attributes) - - def _write_backward(self, val): - # Write the <c:backward> element. - - if not val: - return - - attributes = [('val', val)] - - self._xml_empty_tag('c:backward', attributes) - - def _write_hi_low_lines(self): - # Write the <c:hiLowLines> element. - hi_low_lines = self.hi_low_lines - - if hi_low_lines is None: - return - - if 'line' in hi_low_lines and hi_low_lines['line']['defined']: - - self._xml_start_tag('c:hiLowLines') - - # Write the c:spPr element. - self._write_sp_pr(hi_low_lines) - - self._xml_end_tag('c:hiLowLines') - else: - self._xml_empty_tag('c:hiLowLines') - - def _write_drop_lines(self): - # Write the <c:dropLines> element. - drop_lines = self.drop_lines - - if drop_lines is None: - return - - if drop_lines['line']['defined']: - - self._xml_start_tag('c:dropLines') - - # Write the c:spPr element. - self._write_sp_pr(drop_lines) - - self._xml_end_tag('c:dropLines') - else: - self._xml_empty_tag('c:dropLines') - - def _write_overlap(self, val): - # Write the <c:overlap> element. - - if val is None: - return - - attributes = [('val', val)] - - self._xml_empty_tag('c:overlap', attributes) - - def _write_num_cache(self, data): - # Write the <c:numCache> element. - if data: - count = len(data) - else: - count = 0 - - self._xml_start_tag('c:numCache') - - # Write the c:formatCode element. - self._write_format_code('General') - - # Write the c:ptCount element. - self._write_pt_count(count) - - for i in range(count): - token = data[i] - - if token is None: - continue - - try: - float(token) - except ValueError: - # Write non-numeric data as 0. - token = 0 - - # Write the c:pt element. - self._write_pt(i, token) - - self._xml_end_tag('c:numCache') - - def _write_str_cache(self, data): - # Write the <c:strCache> element. - count = len(data) - - self._xml_start_tag('c:strCache') - - # Write the c:ptCount element. - self._write_pt_count(count) - - for i in range(count): - # Write the c:pt element. - self._write_pt(i, data[i]) - - self._xml_end_tag('c:strCache') - - def _write_format_code(self, data): - # Write the <c:formatCode> element. - - self._xml_data_element('c:formatCode', data) - - def _write_pt_count(self, val): - # Write the <c:ptCount> element. - - attributes = [('val', val)] - - self._xml_empty_tag('c:ptCount', attributes) - - def _write_pt(self, idx, value): - # Write the <c:pt> element. - - if value is None: - return - - attributes = [('idx', idx)] - - self._xml_start_tag('c:pt', attributes) - - # Write the c:v element. - self._write_v(value) - - self._xml_end_tag('c:pt') - - def _write_v(self, data): - # Write the <c:v> element. - - self._xml_data_element('c:v', data) - - def _write_protection(self): - # Write the <c:protection> element. - if not self.protection: - return - - self._xml_empty_tag('c:protection') - - def _write_d_pt(self, points): - # Write the <c:dPt> elements. - index = -1 - - if not points: - return - - for point in points: - index += 1 - if not point: - continue - - self._write_d_pt_point(index, point) - - def _write_d_pt_point(self, index, point): - # Write an individual <c:dPt> element. - - self._xml_start_tag('c:dPt') - - # Write the c:idx element. - self._write_idx(index) - - # Write the c:spPr element. - self._write_sp_pr(point) - - self._xml_end_tag('c:dPt') - - def _write_d_lbls(self, labels): - # Write the <c:dLbls> element. - - if not labels: - return - - self._xml_start_tag('c:dLbls') - - # Write the c:numFmt element. - if labels.get('num_format'): - self._write_data_label_number_format(labels['num_format']) - - # Write the data label font elements. - if labels.get('font'): - self._write_axis_font(labels['font']) - - # Write the c:dLblPos element. - if labels.get('position'): - self._write_d_lbl_pos(labels['position']) - - # Write the c:showLegendKey element. - if labels.get('legend_key'): - self._write_show_legend_key() - - # Write the c:showVal element. - if labels.get('value'): - self._write_show_val() - - # Write the c:showCatName element. - if labels.get('category'): - self._write_show_cat_name() - - # Write the c:showSerName element. - if labels.get('series_name'): - self._write_show_ser_name() - - # Write the c:showPercent element. - if labels.get('percentage'): - self._write_show_percent() - - # Write the c:separator element. - if labels.get('separator'): - self._write_separator(labels['separator']) - - # Write the c:showLeaderLines element. - if labels.get('leader_lines'): - self._write_show_leader_lines() - - self._xml_end_tag('c:dLbls') - - def _write_show_legend_key(self): - # Write the <c:showLegendKey> element. - val = '1' - - attributes = [('val', val)] - - self._xml_empty_tag('c:showLegendKey', attributes) - - def _write_show_val(self): - # Write the <c:showVal> element. - val = 1 - - attributes = [('val', val)] - - self._xml_empty_tag('c:showVal', attributes) - - def _write_show_cat_name(self): - # Write the <c:showCatName> element. - val = 1 - - attributes = [('val', val)] - - self._xml_empty_tag('c:showCatName', attributes) - - def _write_show_ser_name(self): - # Write the <c:showSerName> element. - val = 1 - - attributes = [('val', val)] - - self._xml_empty_tag('c:showSerName', attributes) - - def _write_show_percent(self): - # Write the <c:showPercent> element. - val = 1 - - attributes = [('val', val)] - - self._xml_empty_tag('c:showPercent', attributes) - - def _write_separator(self, data): - # Write the <c:separator> element. - self._xml_data_element('c:separator', data) - - def _write_show_leader_lines(self): - # Write the <c:showLeaderLines> element. - val = 1 - - attributes = [('val', val)] - - self._xml_empty_tag('c:showLeaderLines', attributes) - - def _write_d_lbl_pos(self, val): - # Write the <c:dLblPos> element. - - attributes = [('val', val)] - - self._xml_empty_tag('c:dLblPos', attributes) - - def _write_delete(self, val): - # Write the <c:delete> element. - - attributes = [('val', val)] - - self._xml_empty_tag('c:delete', attributes) - - def _write_c_invert_if_negative(self, invert): - # Write the <c:invertIfNegative> element. - val = 1 - - if not invert: - return - - attributes = [('val', val)] - - self._xml_empty_tag('c:invertIfNegative', attributes) - - def _write_axis_font(self, font): - # Write the axis font elements. - - if not font: - return - - self._xml_start_tag('c:txPr') - self._write_a_body_pr(font.get('rotation'), None) - self._write_a_lst_style() - self._xml_start_tag('a:p') - - self._write_a_p_pr_rich(font) - - self._write_a_end_para_rpr() - self._xml_end_tag('a:p') - self._xml_end_tag('c:txPr') - - def _write_a_latin(self, attributes): - # Write the <a:latin> element. - self._xml_empty_tag('a:latin', attributes) - - def _write_d_table(self): - # Write the <c:dTable> element. - table = self.table - - if not table: - return - - self._xml_start_tag('c:dTable') - - if table['horizontal']: - # Write the c:showHorzBorder element. - self._write_show_horz_border() - - if table['vertical']: - # Write the c:showVertBorder element. - self._write_show_vert_border() - - if table['outline']: - # Write the c:showOutline element. - self._write_show_outline() - - if table['show_keys']: - # Write the c:showKeys element. - self._write_show_keys() - - self._xml_end_tag('c:dTable') - - def _write_show_horz_border(self): - # Write the <c:showHorzBorder> element. - attributes = [('val', 1)] - - self._xml_empty_tag('c:showHorzBorder', attributes) - - def _write_show_vert_border(self): - # Write the <c:showVertBorder> element. - attributes = [('val', 1)] - - self._xml_empty_tag('c:showVertBorder', attributes) - - def _write_show_outline(self): - # Write the <c:showOutline> element. - attributes = [('val', 1)] - - self._xml_empty_tag('c:showOutline', attributes) - - def _write_show_keys(self): - # Write the <c:showKeys> element. - attributes = [('val', 1)] - - self._xml_empty_tag('c:showKeys', attributes) - - def _write_error_bars(self, error_bars): - # Write the X and Y error bars. - - if not error_bars: - return - - if error_bars['x_error_bars']: - self._write_err_bars('x', error_bars['x_error_bars']) - - if error_bars['y_error_bars']: - self._write_err_bars('y', error_bars['y_error_bars']) - - def _write_err_bars(self, direction, error_bars): - # Write the <c:errBars> element. - - if not error_bars: - return - - self._xml_start_tag('c:errBars') - - # Write the c:errDir element. - self._write_err_dir(direction) - - # Write the c:errBarType element. - self._write_err_bar_type(error_bars['direction']) - - # Write the c:errValType element. - self._write_err_val_type(error_bars['type']) - - if not error_bars['endcap']: - # Write the c:noEndCap element. - self._write_no_end_cap() - - if error_bars['type'] == 'stdErr': - # Don't need to write a c:errValType tag. - pass - elif error_bars['type'] == 'cust': - # Write the custom error tags. - self._write_custom_error(error_bars) - else: - # Write the c:val element. - self._write_error_val(error_bars['value']) - - # Write the c:spPr element. - self._write_sp_pr(error_bars) - - self._xml_end_tag('c:errBars') - - def _write_err_dir(self, val): - # Write the <c:errDir> element. - - attributes = [('val', val)] - - self._xml_empty_tag('c:errDir', attributes) - - def _write_err_bar_type(self, val): - # Write the <c:errBarType> element. - - attributes = [('val', val)] - - self._xml_empty_tag('c:errBarType', attributes) - - def _write_err_val_type(self, val): - # Write the <c:errValType> element. - - attributes = [('val', val)] - - self._xml_empty_tag('c:errValType', attributes) - - def _write_no_end_cap(self): - # Write the <c:noEndCap> element. - attributes = [('val', 1)] - - self._xml_empty_tag('c:noEndCap', attributes) - - def _write_error_val(self, val): - # Write the <c:val> element for error bars. - - attributes = [('val', val)] - - self._xml_empty_tag('c:val', attributes) - - def _write_custom_error(self, error_bars): - # Write the custom error bars tags. - - if error_bars['plus_values']: - # Write the c:plus element. - self._xml_start_tag('c:plus') - - if isinstance(error_bars['plus_values'], list): - self._write_num_lit(error_bars['plus_values']) - else: - self._write_num_ref(error_bars['plus_values'], - error_bars['plus_data'], - 'num') - self._xml_end_tag('c:plus') - - if error_bars['minus_values']: - # Write the c:minus element. - self._xml_start_tag('c:minus') - - if isinstance(error_bars['minus_values'], list): - self._write_num_lit(error_bars['minus_values']) - else: - self._write_num_ref(error_bars['minus_values'], - error_bars['minus_data'], - 'num') - self._xml_end_tag('c:minus') - - def _write_num_lit(self, data): - # Write the <c:numLit> element for literal number list elements. - count = len(data) - - # Write the c:numLit element. - self._xml_start_tag('c:numLit') - - # Write the c:formatCode element. - self._write_format_code('General') - - # Write the c:ptCount element. - self._write_pt_count(count) - - for i in range(count): - token = data[i] - - if token is None: - continue - - try: - float(token) - except ValueError: - # Write non-numeric data as 0. - token = 0 - - # Write the c:pt element. - self._write_pt(i, token) - - self._xml_end_tag('c:numLit') - - def _write_up_down_bars(self): - # Write the <c:upDownBars> element. - up_down_bars = self.up_down_bars - - if up_down_bars is None: - return - - self._xml_start_tag('c:upDownBars') - - # Write the c:gapWidth element. - self._write_gap_width(150) - - # Write the c:upBars element. - self._write_up_bars(up_down_bars.get('up')) - - # Write the c:downBars element. - self._write_down_bars(up_down_bars.get('down')) - - self._xml_end_tag('c:upDownBars') - - def _write_gap_width(self, val): - # Write the <c:gapWidth> element. - - if val is None: - return - - attributes = [('val', val)] - - self._xml_empty_tag('c:gapWidth', attributes) - - def _write_up_bars(self, bar_format): - # Write the <c:upBars> element. - - if bar_format['line'] and bar_format['line']['defined']: - self._xml_start_tag('c:upBars') - - # Write the c:spPr element. - self._write_sp_pr(bar_format) - - self._xml_end_tag('c:upBars') - else: - self._xml_empty_tag('c:upBars') - - def _write_down_bars(self, bar_format): - # Write the <c:downBars> element. - - if bar_format['line'] and bar_format['line']['defined']: - self._xml_start_tag('c:downBars') - - # Write the c:spPr element. - self._write_sp_pr(bar_format) - - self._xml_end_tag('c:downBars') - else: - self._xml_empty_tag('c:downBars') - - def _write_disp_units(self, units, display): - # Write the <c:dispUnits> element. - - if not units: - return - - attributes = [('val', units)] - - self._xml_start_tag('c:dispUnits') - self._xml_empty_tag('c:builtInUnit', attributes) - - if display: - self._xml_start_tag('c:dispUnitsLbl') - self._xml_empty_tag('c:layout') - self._xml_end_tag('c:dispUnitsLbl') - - self._xml_end_tag('c:dispUnits') - - def _write_a_grad_fill(self, gradient): - # Write the <a:gradFill> element. - - attributes = [('flip', 'none'), ('rotWithShape', '1')] - - if gradient['type'] == 'linear': - attributes = [] - - self._xml_start_tag('a:gradFill', attributes) - - # Write the a:gsLst element. - self._write_a_gs_lst(gradient) - - if gradient['type'] == 'linear': - # Write the a:lin element. - self._write_a_lin(gradient['angle']) - else: - # Write the a:path element. - self._write_a_path(gradient['type']) - - # Write the a:tileRect element. - self._write_a_tile_rect(gradient['type']) - - self._xml_end_tag('a:gradFill') - - def _write_a_gs_lst(self, gradient): - # Write the <a:gsLst> element. - positions = gradient['positions'] - colors = gradient['colors'] - - self._xml_start_tag('a:gsLst') - - for i in range(len(colors)): - pos = int(positions[i] * 1000) - attributes = [('pos', pos)] - self._xml_start_tag('a:gs', attributes) - - # Write the a:srgbClr element. - # TODO: Wait for a feature request to support transparency. - color = get_rgb_color(colors[i]) - self._write_a_srgb_clr(color) - - self._xml_end_tag('a:gs') - - self._xml_end_tag('a:gsLst') - - def _write_a_lin(self, angle): - # Write the <a:lin> element. - - angle = int(60000 * angle) - - attributes = [ - ('ang', angle), - ('scaled', '0'), - ] - - self._xml_empty_tag('a:lin', attributes) - - def _write_a_path(self, gradient_type): - # Write the <a:path> element. - - attributes = [('path', gradient_type)] - - self._xml_start_tag('a:path', attributes) - - # Write the a:fillToRect element. - self._write_a_fill_to_rect(gradient_type) - - self._xml_end_tag('a:path') - - def _write_a_fill_to_rect(self, gradient_type): - # Write the <a:fillToRect> element. - - l = '100000' - t = '100000' - - if gradient_type == 'shape': - attributes = [ - ('l', '50000'), - ('t', '50000'), - ('r', '50000'), - ('b', '50000'), - ] - else: - attributes = [ - ('l', '100000'), - ('t', '100000'), - ] - - self._xml_empty_tag('a:fillToRect', attributes) - - def _write_a_tile_rect(self, gradient_type): - # Write the <a:tileRect> element. - - if gradient_type == 'shape': - attributes = [] - else: - attributes = [ - ('r', '-100000'), - ('b', '-100000'), - ] - - self._xml_empty_tag('a:tileRect', attributes) - - def _write_a_patt_fill(self, pattern): - # Write the <a:pattFill> element. - - attributes = [('prst', pattern['pattern'])] - - self._xml_start_tag('a:pattFill', attributes) - - # Write the a:fgClr element. - self._write_a_fg_clr(pattern['fg_color']) - - # Write the a:bgClr element. - self._write_a_bg_clr(pattern['bg_color']) - - self._xml_end_tag('a:pattFill') - - def _write_a_fg_clr(self, color): - # Write the <a:fgClr> element. - - color = get_rgb_color(color) - - self._xml_start_tag('a:fgClr') - - # Write the a:srgbClr element. - self._write_a_srgb_clr(color) - - self._xml_end_tag('a:fgClr') - - def _write_a_bg_clr(self, color): - # Write the <a:bgClr> element. - - color = get_rgb_color(color) - - self._xml_start_tag('a:bgClr') - - # Write the a:srgbClr element. - self._write_a_srgb_clr(color) - - self._xml_end_tag('a:bgClr')
Binary file test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/chart.pyc has changed
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/chart_area.py Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,103 +0,0 @@ -############################################################################### -# -# ChartArea - A class for writing the Excel XLSX Area charts. -# -# Copyright 2013-2016, John McNamara, jmcnamara@cpan.org -# - -from . import chart - - -class ChartArea(chart.Chart): - """ - A class for writing the Excel XLSX Area charts. - - - """ - - ########################################################################### - # - # Public API. - # - ########################################################################### - - def __init__(self, options=None): - """ - Constructor. - - """ - super(ChartArea, self).__init__() - - if options is None: - options = {} - - self.subtype = options.get('subtype') - - if not self.subtype: - self.subtype = 'standard' - - self.cross_between = 'midCat' - self.show_crosses = 0 - - # Override and reset the default axis values. - if self.subtype == 'percent_stacked': - self.y_axis['defaults']['num_format'] = '0%' - - # Set the available data label positions for this chart type. - self.label_position_default = 'center' - self.label_positions = {'center': 'ctr'} - - self.set_y_axis({}) - - ########################################################################### - # - # Private API. - # - ########################################################################### - - def _write_chart_type(self, args): - # Override the virtual superclass method with a chart specific method. - # Write the c:areaChart element. - self._write_area_chart(args) - - ########################################################################### - # - # XML methods. - # - ########################################################################### - # - def _write_area_chart(self, args): - # Write the <c:areaChart> element. - - if args['primary_axes']: - series = self._get_primary_axes_series() - else: - series = self._get_secondary_axes_series() - - if not len(series): - return - - subtype = self.subtype - - if subtype == 'percent_stacked': - subtype = 'percentStacked' - - self._xml_start_tag('c:areaChart') - - # Write the c:grouping element. - self._write_grouping(subtype) - - # Write the series elements. - for data in series: - self._write_ser(data) - - # Write the c:dropLines element. - self._write_drop_lines() - - # Write the c:marker element. - self._write_marker_value() - - # Write the c:axId elements - self._write_axis_ids(args) - - self._xml_end_tag('c:areaChart')
Binary file test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/chart_area.pyc has changed
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/chart_bar.py Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,175 +0,0 @@ -############################################################################### -# -# ChartBar - A class for writing the Excel XLSX Bar charts. -# -# Copyright 2013-2016, John McNamara, jmcnamara@cpan.org -# - -from . import chart -from warnings import warn - - -class ChartBar(chart.Chart): - """ - A class for writing the Excel XLSX Bar charts. - - - """ - - ########################################################################### - # - # Public API. - # - ########################################################################### - - def __init__(self, options=None): - """ - Constructor. - - """ - super(ChartBar, self).__init__() - - if options is None: - options = {} - - self.subtype = options.get('subtype') - - if not self.subtype: - self.subtype = 'clustered' - - self.cat_axis_position = 'l' - self.val_axis_position = 'b' - self.horiz_val_axis = 0 - self.horiz_cat_axis = 1 - self.show_crosses = 0 - - # Override and reset the default axis values. - self.x_axis['defaults']['major_gridlines'] = {'visible': 1} - self.y_axis['defaults']['major_gridlines'] = {'visible': 0} - - if self.subtype == 'percent_stacked': - self.x_axis['defaults']['num_format'] = '0%' - - # Set the available data label positions for this chart type. - self.label_position_default = 'outside_end' - self.label_positions = { - 'center': 'ctr', - 'inside_base': 'inBase', - 'inside_end': 'inEnd', - 'outside_end': 'outEnd'} - - self.set_x_axis({}) - self.set_y_axis({}) - - def combine(self, chart=None): - """ - Create a combination chart with a secondary chart. - - Note: Override parent method to add an extra check that is required - for Bar charts to ensure that their combined chart is on a secondary - axis. - - Args: - chart: The secondary chart to combine with the primary chart. - - Returns: - Nothing. - - """ - if chart is None: - return - - if not chart.is_secondary: - warn('Charts combined with Bar charts must be on a secondary axis') - - self.combined = chart - - ########################################################################### - # - # Private API. - # - ########################################################################### - - def _write_chart_type(self, args): - # Override the virtual superclass method with a chart specific method. - if args['primary_axes']: - # Reverse X and Y axes for Bar charts. - tmp = self.y_axis - self.y_axis = self.x_axis - self.x_axis = tmp - - if self.y2_axis['position'] == 'r': - self.y2_axis['position'] = 't' - - # Write the c:barChart element. - self._write_bar_chart(args) - - def _write_bar_chart(self, args): - # Write the <c:barChart> element. - - if args['primary_axes']: - series = self._get_primary_axes_series() - else: - series = self._get_secondary_axes_series() - - if not len(series): - return - - subtype = self.subtype - if subtype == 'percent_stacked': - subtype = 'percentStacked' - - # Set a default overlap for stacked charts. - if 'stacked' in self.subtype: - if self.series_overlap_1 is None: - self.series_overlap_1 = 100 - - self._xml_start_tag('c:barChart') - - # Write the c:barDir element. - self._write_bar_dir() - - # Write the c:grouping element. - self._write_grouping(subtype) - - # Write the c:ser elements. - for data in series: - self._write_ser(data) - - # Write the c:marker element. - self._write_marker_value() - - # Write the c:gapWidth element. - if args['primary_axes']: - self._write_gap_width(self.series_gap_1) - else: - self._write_gap_width(self.series_gap_2) - - # Write the c:overlap element. - if args['primary_axes']: - self._write_overlap(self.series_overlap_1) - else: - self._write_overlap(self.series_overlap_2) - - # Write the c:axId elements - self._write_axis_ids(args) - - self._xml_end_tag('c:barChart') - - ########################################################################### - # - # XML methods. - # - ########################################################################### - - def _write_bar_dir(self): - # Write the <c:barDir> element. - val = 'bar' - - attributes = [('val', val)] - - self._xml_empty_tag('c:barDir', attributes) - - def _write_err_dir(self, val): - # Overridden from Chart class since it is not used in Bar charts. - pass
Binary file test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/chart_bar.pyc has changed
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/chart_column.py Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,134 +0,0 @@ -############################################################################### -# -# ChartColumn - A class for writing the Excel XLSX Column charts. -# -# Copyright 2013-2016, John McNamara, jmcnamara@cpan.org -# - -from . import chart - - -class ChartColumn(chart.Chart): - """ - A class for writing the Excel XLSX Column charts. - - - """ - - ########################################################################### - # - # Public API. - # - ########################################################################### - - def __init__(self, options=None): - """ - Constructor. - - """ - super(ChartColumn, self).__init__() - - if options is None: - options = {} - - self.subtype = options.get('subtype') - - if not self.subtype: - self.subtype = 'clustered' - - self.horiz_val_axis = 0 - - if self.subtype == 'percent_stacked': - self.y_axis['defaults']['num_format'] = '0%' - - # Set the available data label positions for this chart type. - self.label_position_default = 'outside_end' - self.label_positions = { - 'center': 'ctr', - 'inside_base': 'inBase', - 'inside_end': 'inEnd', - 'outside_end': 'outEnd'} - - self.set_y_axis({}) - - ########################################################################### - # - # Private API. - # - ########################################################################### - - def _write_chart_type(self, args): - # Override the virtual superclass method with a chart specific method. - - # Write the c:barChart element. - self._write_bar_chart(args) - - def _write_bar_chart(self, args): - # Write the <c:barChart> element. - - if args['primary_axes']: - series = self._get_primary_axes_series() - else: - series = self._get_secondary_axes_series() - - if not len(series): - return - - subtype = self.subtype - if subtype == 'percent_stacked': - subtype = 'percentStacked' - - # Set a default overlap for stacked charts. - if 'stacked' in self.subtype: - if self.series_overlap_1 is None: - self.series_overlap_1 = 100 - - self._xml_start_tag('c:barChart') - - # Write the c:barDir element. - self._write_bar_dir() - - # Write the c:grouping element. - self._write_grouping(subtype) - - # Write the c:ser elements. - for data in series: - self._write_ser(data) - - # Write the c:marker element. - self._write_marker_value() - - # Write the c:gapWidth element. - if args['primary_axes']: - self._write_gap_width(self.series_gap_1) - else: - self._write_gap_width(self.series_gap_2) - - # Write the c:overlap element. - if args['primary_axes']: - self._write_overlap(self.series_overlap_1) - else: - self._write_overlap(self.series_overlap_2) - - # Write the c:axId elements - self._write_axis_ids(args) - - self._xml_end_tag('c:barChart') - - ########################################################################### - # - # XML methods. - # - ########################################################################### - - def _write_bar_dir(self): - # Write the <c:barDir> element. - val = 'col' - - attributes = [('val', val)] - - self._xml_empty_tag('c:barDir', attributes) - - def _write_err_dir(self, val): - # Overridden from Chart class since it is not used in Column charts. - pass
Binary file test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/chart_column.pyc has changed
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/chart_doughnut.py Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,102 +0,0 @@ -############################################################################### -# -# ChartDoughnut - A class for writing the Excel XLSX Doughnut charts. -# -# Copyright 2013-2016, John McNamara, jmcnamara@cpan.org -# - -from warnings import warn -from . import chart_pie - - -class ChartDoughnut(chart_pie.ChartPie): - """ - A class for writing the Excel XLSX Doughnut charts. - - - """ - - ########################################################################### - # - # Public API. - # - ########################################################################### - - def __init__(self, options=None): - """ - Constructor. - - """ - super(ChartDoughnut, self).__init__() - - if options is None: - options = {} - - self.vary_data_color = 1 - self.rotation = 0 - self.hole_size = 50 - - def set_hole_size(self, size): - """ - Set the Doughnut chart hole size. - - Args: - size: 10 <= size <= 90. - - Returns: - Nothing. - - """ - if size is None: - return - - # Ensure the size is in Excel's range. - if size < 10 or size > 90: - warn("Chart hole size %d outside Excel range: 10 <= size <= 90" - % size) - return - - self.hole_size = int(size) - - ########################################################################### - # - # Private API. - # - ########################################################################### - - def _write_chart_type(self, args): - # Override the virtual superclass method with a chart specific method. - # Write the c:doughnutChart element. - self._write_doughnut_chart(args) - - ########################################################################### - # - # XML methods. - # - ########################################################################### - - def _write_doughnut_chart(self, args): - # Write the <c:doughnutChart> element. Over-ridden method to remove - # axis_id code since Doughnut charts don't require val and cat axes. - self._xml_start_tag('c:doughnutChart') - - # Write the c:varyColors element. - self._write_vary_colors() - - # Write the series elements. - for data in self.series: - self._write_ser(data) - - # Write the c:firstSliceAng element. - self._write_first_slice_ang() - - # Write the c:holeSize element. - self._write_c_hole_size() - - self._xml_end_tag('c:doughnutChart') - - def _write_c_hole_size(self): - # Write the <c:holeSize> element. - attributes = [('val', self.hole_size)] - - self._xml_empty_tag('c:holeSize', attributes)
Binary file test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/chart_doughnut.pyc has changed
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/chart_line.py Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,119 +0,0 @@ -############################################################################### -# -# ChartLine - A class for writing the Excel XLSX Line charts. -# -# Copyright 2013-2016, John McNamara, jmcnamara@cpan.org -# - -from . import chart - - -class ChartLine(chart.Chart): - """ - A class for writing the Excel XLSX Line charts. - - - """ - - ########################################################################### - # - # Public API. - # - ########################################################################### - - def __init__(self, options=None): - """ - Constructor. - - """ - super(ChartLine, self).__init__() - - if options is None: - options = {} - - self.default_marker = {'type': 'none'} - self.smooth_allowed = True - - # Set the available data label positions for this chart type. - self.label_position_default = 'right' - self.label_positions = { - 'center': 'ctr', - 'right': 'r', - 'left': 'l', - 'above': 't', - 'below': 'b', - # For backward compatibility. - 'top': 't', - 'bottom': 'b'} - - ########################################################################### - # - # Private API. - # - ########################################################################### - - def _write_chart_type(self, args): - # Override the virtual superclass method with a chart specific method. - # Write the c:lineChart element. - self._write_line_chart(args) - - ########################################################################### - # - # XML methods. - # - ########################################################################### - - def _write_line_chart(self, args): - # Write the <c:lineChart> element. - - if args['primary_axes']: - series = self._get_primary_axes_series() - else: - series = self._get_secondary_axes_series() - - if not len(series): - return - - self._xml_start_tag('c:lineChart') - - # Write the c:grouping element. - self._write_grouping('standard') - - # Write the series elements. - for data in series: - self._write_ser(data) - - # Write the c:dropLines element. - self._write_drop_lines() - - # Write the c:hiLowLines element. - self._write_hi_low_lines() - - # Write the c:upDownBars element. - self._write_up_down_bars() - - # Write the c:marker element. - self._write_marker_value() - - # Write the c:axId elements - self._write_axis_ids(args) - - self._xml_end_tag('c:lineChart') - - def _write_d_pt_point(self, index, point): - # Write an individual <c:dPt> element. Override the parent method to - # add markers. - - self._xml_start_tag('c:dPt') - - # Write the c:idx element. - self._write_idx(index) - - self._xml_start_tag('c:marker') - - # Write the c:spPr element. - self._write_sp_pr(point) - - self._xml_end_tag('c:marker') - - self._xml_end_tag('c:dPt')
Binary file test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/chart_line.pyc has changed
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/chart_pie.py Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,227 +0,0 @@ -############################################################################### -# -# ChartPie - A class for writing the Excel XLSX Pie charts. -# -# Copyright 2013-2016, John McNamara, jmcnamara@cpan.org -# - -from warnings import warn -from . import chart - - -class ChartPie(chart.Chart): - """ - A class for writing the Excel XLSX Pie charts. - - - """ - - ########################################################################### - # - # Public API. - # - ########################################################################### - - def __init__(self, options=None): - """ - Constructor. - - """ - super(ChartPie, self).__init__() - - if options is None: - options = {} - - self.vary_data_color = 1 - self.rotation = 0 - - # Set the available data label positions for this chart type. - self.label_position_default = 'best_fit' - self.label_positions = { - 'center': 'ctr', - 'inside_end': 'inEnd', - 'outside_end': 'outEnd', - 'best_fit': 'bestFit'} - - def set_rotation(self, rotation): - """ - Set the Pie/Doughnut chart rotation: the angle of the first slice. - - Args: - rotation: First segment angle: 0 <= rotation <= 360. - - Returns: - Nothing. - - """ - if rotation is None: - return - - # Ensure the rotation is in Excel's range. - if rotation < 0 or rotation > 360: - warn("Chart rotation %d outside Excel range: 0 <= rotation <= 360" - % rotation) - return - - self.rotation = int(rotation) - - ########################################################################### - # - # Private API. - # - ########################################################################### - - def _write_chart_type(self, args): - # Override the virtual superclass method with a chart specific method. - # Write the c:pieChart element. - self._write_pie_chart(args) - - ########################################################################### - # - # XML methods. - # - ########################################################################### - - def _write_pie_chart(self, args): - # Write the <c:pieChart> element. Over-ridden method to remove - # axis_id code since Pie charts don't require val and cat axes. - self._xml_start_tag('c:pieChart') - - # Write the c:varyColors element. - self._write_vary_colors() - - # Write the series elements. - for data in self.series: - self._write_ser(data) - - # Write the c:firstSliceAng element. - self._write_first_slice_ang() - - self._xml_end_tag('c:pieChart') - - def _write_plot_area(self): - # Over-ridden method to remove the cat_axis() and val_axis() code - # since Pie charts don't require those axes. - # - # Write the <c:plotArea> element. - - self._xml_start_tag('c:plotArea') - - # Write the c:layout element. - self._write_layout(self.plotarea.get('layout'), 'plot') - - # Write the subclass chart type element. - self._write_chart_type(None) - - self._xml_end_tag('c:plotArea') - - def _write_legend(self): - # Over-ridden method to add <c:txPr> to legend. - # Write the <c:legend> element. - - position = self.legend_position - font = self.legend_font - delete_series = [] - overlay = 0 - - if (self.legend_delete_series is not None - and type(self.legend_delete_series) is list): - delete_series = self.legend_delete_series - - if position.startswith('overlay_'): - position = position.replace('overlay_', '') - overlay = 1 - - allowed = { - 'right': 'r', - 'left': 'l', - 'top': 't', - 'bottom': 'b', - } - - if position == 'none': - return - - if position not in allowed: - return - - position = allowed[position] - - self._xml_start_tag('c:legend') - - # Write the c:legendPos element. - self._write_legend_pos(position) - - # Remove series labels from the legend. - for index in delete_series: - # Write the c:legendEntry element. - self._write_legend_entry(index) - - # Write the c:layout element. - self._write_layout(self.legend_layout, 'legend') - - # Write the c:overlay element. - if overlay: - self._write_overlay() - - # Write the c:txPr element. Over-ridden. - self._write_tx_pr_legend(None, font) - - self._xml_end_tag('c:legend') - - def _write_tx_pr_legend(self, horiz, font): - # Write the <c:txPr> element for legends. - - if font and font.get('rotation'): - rotation = font['rotation'] - else: - rotation = None - - self._xml_start_tag('c:txPr') - - # Write the a:bodyPr element. - self._write_a_body_pr(rotation, horiz) - - # Write the a:lstStyle element. - self._write_a_lst_style() - - # Write the a:p element. - self._write_a_p_legend(font) - - self._xml_end_tag('c:txPr') - - def _write_a_p_legend(self, font): - # Write the <a:p> element for legends. - - self._xml_start_tag('a:p') - - # Write the a:pPr element. - self._write_a_p_pr_legend(font) - - # Write the a:endParaRPr element. - self._write_a_end_para_rpr() - - self._xml_end_tag('a:p') - - def _write_a_p_pr_legend(self, font): - # Write the <a:pPr> element for legends. - attributes = [('rtl', 0)] - - self._xml_start_tag('a:pPr', attributes) - - # Write the a:defRPr element. - self._write_a_def_rpr(font) - - self._xml_end_tag('a:pPr') - - def _write_vary_colors(self): - # Write the <c:varyColors> element. - attributes = [('val', 1)] - - self._xml_empty_tag('c:varyColors', attributes) - - def _write_first_slice_ang(self): - # Write the <c:firstSliceAng> element. - attributes = [('val', self.rotation)] - - self._xml_empty_tag('c:firstSliceAng', attributes)
Binary file test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/chart_pie.pyc has changed
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/chart_radar.py Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,101 +0,0 @@ -############################################################################### -# -# ChartRadar - A class for writing the Excel XLSX Radar charts. -# -# Copyright 2013-2016, John McNamara, jmcnamara@cpan.org -# - -from . import chart - - -class ChartRadar(chart.Chart): - """ - A class for writing the Excel XLSX Radar charts. - - - """ - - ########################################################################### - # - # Public API. - # - ########################################################################### - - def __init__(self, options=None): - """ - Constructor. - - """ - super(ChartRadar, self).__init__() - - if options is None: - options = {} - - self.subtype = options.get('subtype') - - if not self.subtype: - self.subtype = 'marker' - self.default_marker = {'type': 'none'} - - # Override and reset the default axis values. - self.x_axis['defaults']['major_gridlines'] = {'visible': 1} - self.set_x_axis({}) - - # Set the available data label positions for this chart type. - self.label_position_default = 'center' - self.label_positions = {'center': 'ctr'} - - # Hardcode major_tick_mark for now until there is an accessor. - self.y_axis['major_tick_mark'] = 'cross' - - ########################################################################### - # - # Private API. - # - ########################################################################### - - def _write_chart_type(self, args): - # Write the c:radarChart element. - self._write_radar_chart(args) - - ########################################################################### - # - # XML methods. - # - ########################################################################### - - def _write_radar_chart(self, args): - # Write the <c:radarChart> element. - - if args['primary_axes']: - series = self._get_primary_axes_series() - else: - series = self._get_secondary_axes_series() - - if not len(series): - return - - self._xml_start_tag('c:radarChart') - - # Write the c:radarStyle element. - self._write_radar_style() - - # Write the series elements. - for data in series: - self._write_ser(data) - - # Write the c:axId elements - self._write_axis_ids(args) - - self._xml_end_tag('c:radarChart') - - def _write_radar_style(self): - # Write the <c:radarStyle> element. - val = 'marker' - - if self.subtype == 'filled': - val = 'filled' - - attributes = [('val', val)] - - self._xml_empty_tag('c:radarStyle', attributes)
Binary file test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/chart_radar.pyc has changed
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/chart_scatter.py Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,327 +0,0 @@ -############################################################################### -# -# ChartScatter - A class for writing the Excel XLSX Scatter charts. -# -# Copyright 2013-2016, John McNamara, jmcnamara@cpan.org -# - -from . import chart - - -class ChartScatter(chart.Chart): - """ - A class for writing the Excel XLSX Scatter charts. - - - """ - - ########################################################################### - # - # Public API. - # - ########################################################################### - - def __init__(self, options=None): - """ - Constructor. - - """ - super(ChartScatter, self).__init__() - - if options is None: - options = {} - - self.subtype = options.get('subtype') - - if not self.subtype: - self.subtype = 'marker_only' - - self.cross_between = 'midCat' - self.horiz_val_axis = 0 - self.val_axis_position = 'b' - self.smooth_allowed = True - self.requires_category = True - - # Set the available data label positions for this chart type. - self.label_position_default = 'right' - self.label_positions = { - 'center': 'ctr', - 'right': 'r', - 'left': 'l', - 'above': 't', - 'below': 'b', - # For backward compatibility. - 'top': 't', - 'bottom': 'b'} - - def combine(self, chart=None): - """ - Create a combination chart with a secondary chart. - - Note: Override parent method to add a warning. - - Args: - chart: The secondary chart to combine with the primary chart. - - Returns: - Nothing. - - """ - if chart is None: - return - - warn('Combined chart not currently supported with scatter chart ' - 'as the primary chart') - - ########################################################################### - # - # Private API. - # - ########################################################################### - - def _write_chart_type(self, args): - # Override the virtual superclass method with a chart specific method. - # Write the c:scatterChart element. - self._write_scatter_chart(args) - - ########################################################################### - # - # XML methods. - # - ########################################################################### - - def _write_scatter_chart(self, args): - # Write the <c:scatterChart> element. - - if args['primary_axes']: - series = self._get_primary_axes_series() - else: - series = self._get_secondary_axes_series() - - if not len(series): - return - - style = 'lineMarker' - subtype = self.subtype - - # Set the user defined chart subtype. - if subtype == 'marker_only': - style = 'lineMarker' - - if subtype == 'straight_with_markers': - style = 'lineMarker' - - if subtype == 'straight': - style = 'lineMarker' - - if subtype == 'smooth_with_markers': - style = 'smoothMarker' - - if subtype == 'smooth': - style = 'smoothMarker' - - # Add default formatting to the series data. - self._modify_series_formatting() - - self._xml_start_tag('c:scatterChart') - - # Write the c:scatterStyle element. - self._write_scatter_style(style) - - # Write the series elements. - for data in series: - self._write_ser(data) - - # Write the c:marker element. - self._write_marker_value() - - # Write the c:axId elements - self._write_axis_ids(args) - - self._xml_end_tag('c:scatterChart') - - def _write_ser(self, series): - # Over-ridden to write c:xVal/c:yVal instead of c:cat/c:val elements. - # Write the <c:ser> element. - - index = self.series_index - self.series_index += 1 - - self._xml_start_tag('c:ser') - - # Write the c:idx element. - self._write_idx(index) - - # Write the c:order element. - self._write_order(index) - - # Write the series name. - self._write_series_name(series) - - # Write the c:spPr element. - self._write_sp_pr(series) - - # Write the c:marker element. - self._write_marker(series.get('marker')) - - # Write the c:dPt element. - self._write_d_pt(series.get('points')) - - # Write the c:dLbls element. - self._write_d_lbls(series.get('labels')) - - # Write the c:trendline element. - self._write_trendline(series.get('trendline')) - - # Write the c:errBars element. - self._write_error_bars(series.get('error_bars')) - - # Write the c:xVal element. - self._write_x_val(series) - - # Write the c:yVal element. - self._write_y_val(series) - - # Write the c:smooth element. - if 'smooth' in self.subtype and series['smooth'] is None: - # Default is on for smooth scatter charts. - self._write_c_smooth(True) - else: - self._write_c_smooth(series['smooth']) - - self._xml_end_tag('c:ser') - - def _write_plot_area(self): - # Over-ridden to have 2 valAx elements for scatter charts instead - # of catAx/valAx. - # - # Write the <c:plotArea> element. - self._xml_start_tag('c:plotArea') - - # Write the c:layout element. - self._write_layout(self.plotarea.get('layout'), 'plot') - - # Write the subclass chart elements for primary and secondary axes. - self._write_chart_type({'primary_axes': 1}) - self._write_chart_type({'primary_axes': 0}) - - # Write c:catAx and c:valAx elements for series using primary axes. - self._write_cat_val_axis({'x_axis': self.x_axis, - 'y_axis': self.y_axis, - 'axis_ids': self.axis_ids, - 'position': 'b', - }) - - tmp = self.horiz_val_axis - self.horiz_val_axis = 1 - - self._write_val_axis({'x_axis': self.x_axis, - 'y_axis': self.y_axis, - 'axis_ids': self.axis_ids, - 'position': 'l', - }) - - self.horiz_val_axis = tmp - - # Write c:valAx and c:catAx elements for series using secondary axes - self._write_cat_val_axis({'x_axis': self.x2_axis, - 'y_axis': self.y2_axis, - 'axis_ids': self.axis2_ids, - 'position': 'b', - }) - self.horiz_val_axis = 1 - self._write_val_axis({'x_axis': self.x2_axis, - 'y_axis': self.y2_axis, - 'axis_ids': self.axis2_ids, - 'position': 'l', - }) - - # Write the c:spPr element for the plotarea formatting. - self._write_sp_pr(self.plotarea) - - self._xml_end_tag('c:plotArea') - - def _write_x_val(self, series): - # Write the <c:xVal> element. - formula = series.get('categories') - data_id = series.get('cat_data_id') - data = self.formula_data[data_id] - - self._xml_start_tag('c:xVal') - - # Check the type of cached data. - data_type = self._get_data_type(data) - - # TODO. Can a scatter plot have non-numeric data. - if data_type == 'str': - # Write the c:numRef element. - self._write_str_ref(formula, data, data_type) - else: - # Write the c:numRef element. - self._write_num_ref(formula, data, data_type) - - self._xml_end_tag('c:xVal') - - def _write_y_val(self, series): - # Write the <c:yVal> element. - formula = series.get('values') - data_id = series.get('val_data_id') - data = self.formula_data[data_id] - - self._xml_start_tag('c:yVal') - - # Unlike Cat axes data should only be numeric. - # Write the c:numRef element. - self._write_num_ref(formula, data, 'num') - - self._xml_end_tag('c:yVal') - - def _write_scatter_style(self, val): - # Write the <c:scatterStyle> element. - attributes = [('val', val)] - - self._xml_empty_tag('c:scatterStyle', attributes) - - def _modify_series_formatting(self): - # Add default formatting to the series data unless it has already been - # specified by the user. - subtype = self.subtype - - # The default scatter style "markers only" requires a line type. - if subtype == 'marker_only': - - # Go through each series and define default values. - for series in self.series: - - # Set a line type unless there is already a user defined type. - if not series['line']['defined']: - series['line'] = {'width': 2.25, - 'none': 1, - 'defined': 1, - } - - # Turn markers off for subtypes that don't have them. - if 'marker' not in subtype: - # Go through each series and define default values. - for series in self.series: - # Set a marker type unless there is a user defined type. - if not series.get('marker'): - series['marker'] = {'type': 'none', 'defined': 1} - - def _write_d_pt_point(self, index, point): - # Write an individual <c:dPt> element. Override the parent method to - # add markers. - - self._xml_start_tag('c:dPt') - - # Write the c:idx element. - self._write_idx(index) - - self._xml_start_tag('c:marker') - - # Write the c:spPr element. - self._write_sp_pr(point) - - self._xml_end_tag('c:marker') - - self._xml_end_tag('c:dPt')
Binary file test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/chart_scatter.pyc has changed
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/chart_stock.py Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,130 +0,0 @@ -############################################################################### -# -# ChartStock - A class for writing the Excel XLSX Stock charts. -# -# Copyright 2013-2016, John McNamara, jmcnamara@cpan.org -# - -from . import chart - - -class ChartStock(chart.Chart): - """ - A class for writing the Excel XLSX Stock charts. - - """ - - ########################################################################### - # - # Public API. - # - ########################################################################### - - def __init__(self, options=None): - """ - Constructor. - - """ - super(ChartStock, self).__init__() - - if options is None: - options = {} - - self.show_crosses = 0 - self.hi_low_lines = {} - self.date_category = True - - # Override and reset the default axis values. - self.x_axis['defaults']['num_format'] = 'dd/mm/yyyy' - self.x2_axis['defaults']['num_format'] = 'dd/mm/yyyy' - - # Set the available data label positions for this chart type. - self.label_position_default = 'right' - self.label_positions = { - 'center': 'ctr', - 'right': 'r', - 'left': 'l', - 'above': 't', - 'below': 'b', - # For backward compatibility. - 'top': 't', - 'bottom': 'b'} - - self.set_x_axis({}) - self.set_x2_axis({}) - - ########################################################################### - # - # Private API. - # - ########################################################################### - - def _write_chart_type(self, args): - # Override the virtual superclass method with a chart specific method. - # Write the c:stockChart element. - self._write_stock_chart(args) - - ########################################################################### - # - # XML methods. - # - ########################################################################### - - def _write_stock_chart(self, args): - # Write the <c:stockChart> element. - # Overridden to add hi_low_lines(). - - if args['primary_axes']: - series = self._get_primary_axes_series() - else: - series = self._get_secondary_axes_series() - - if not len(series): - return - - # Add default formatting to the series data. - self._modify_series_formatting() - - self._xml_start_tag('c:stockChart') - - # Write the series elements. - for data in series: - self._write_ser(data) - - # Write the c:dropLines element. - self._write_drop_lines() - - # Write the c:hiLowLines element. - if args.get('primary_axes'): - self._write_hi_low_lines() - - # Write the c:upDownBars element. - self._write_up_down_bars() - - # Write the c:marker element. - self._write_marker_value() - - # Write the c:axId elements - self._write_axis_ids(args) - - self._xml_end_tag('c:stockChart') - - def _modify_series_formatting(self): - # Add default formatting to the series data. - - index = 0 - - for series in self.series: - if index % 4 != 3: - if not series['line']['defined']: - series['line'] = {'width': 2.25, - 'none': 1, - 'defined': 1} - - if series['marker'] is None: - if index % 4 == 2: - series['marker'] = {'type': 'dot', 'size': 3} - else: - series['marker'] = {'type': 'none'} - - index += 1
Binary file test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/chart_stock.pyc has changed
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/chartsheet.py Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,179 +0,0 @@ -############################################################################### -# -# Chartsheet - A class for writing the Excel XLSX Worksheet file. -# -# Copyright 2013-2016, John McNamara, jmcnamara@cpan.org -# - -from . import worksheet -from .drawing import Drawing - - -class Chartsheet(worksheet.Worksheet): - """ - A class for writing the Excel XLSX Chartsheet file. - - - """ - - ########################################################################### - # - # Public API. - # - ########################################################################### - - def __init__(self): - """ - Constructor. - - """ - - super(Chartsheet, self).__init__() - - self.is_chartsheet = True - self.drawing = None - self.chart = None - self.charts = [] - self.zoom_scale_normal = 0 - self.orientation = 0 - self.protection = False - - def set_chart(self, chart): - """ - Set the chart object for the chartsheet. - Args: - chart: Chart object. - Returns: - chart: A reference to the chart object. - """ - chart.embedded = False - chart.protection = self.protection - self.chart = chart - self.charts.append([0, 0, chart, 0, 0, 1, 1]) - return chart - - def protect(self, password='', options=None): - """ - Set the password and protection options of the worksheet. - - Args: - password: An optional password string. - options: A dictionary of worksheet objects to protect. - - Returns: - Nothing. - - """ - # Overridden from parent worksheet class. - if self.chart: - self.chart.protection = True - else: - self.protection = True - - if not options: - options = {} - - options = options.copy() - - options['sheet'] = False - options['content'] = True - options['scenarios'] = True - - # Call the parent method. - super(Chartsheet, self).protect(password, options) - - ########################################################################### - # - # Private API. - # - ########################################################################### - def _assemble_xml_file(self): - # Assemble and write the XML file. - - # Write the XML declaration. - self._xml_declaration() - - # Write the root worksheet element. - self._write_chartsheet() - - # Write the worksheet properties. - self._write_sheet_pr() - - # Write the sheet view properties. - self._write_sheet_views() - - # Write the sheetProtection element. - self._write_sheet_protection() - - # Write the printOptions element. - self._write_print_options() - - # Write the worksheet page_margins. - self._write_page_margins() - - # Write the worksheet page setup. - self._write_page_setup() - - # Write the headerFooter element. - self._write_header_footer() - - # Write the drawing element. - self._write_drawings() - - # Close the worksheet tag. - self._xml_end_tag('chartsheet') - - # Close the file. - self._xml_close() - - def _prepare_chart(self, index, chart_id, drawing_id): - # Set up chart/drawings. - - self.chart.id = chart_id - 1 - - self.drawing = Drawing() - self.drawing.orientation = self.orientation - - self.external_drawing_links.append(['/drawing', - '../drawings/drawing' - + str(drawing_id) - + '.xml']) - - self.drawing_links.append(['/chart', - '../charts/chart' - + str(chart_id) - + '.xml']) - - ########################################################################### - # - # XML methods. - # - ########################################################################### - - def _write_chartsheet(self): - # Write the <worksheet> element. This is the root element. - - schema = 'http://schemas.openxmlformats.org/' - xmlns = schema + 'spreadsheetml/2006/main' - xmlns_r = schema + 'officeDocument/2006/relationships' - - attributes = [ - ('xmlns', xmlns), - ('xmlns:r', xmlns_r)] - - self._xml_start_tag('chartsheet', attributes) - - def _write_sheet_pr(self): - # Write the <sheetPr> element for Sheet level properties. - attributes = [] - - if self.filter_on: - attributes.append(('filterMode', 1)) - - if (self.fit_page or self.tab_color): - self._xml_start_tag('sheetPr', attributes) - self._write_tab_color() - self._write_page_set_up_pr() - self._xml_end_tag('sheetPr') - else: - self._xml_empty_tag('sheetPr', attributes)
Binary file test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/chartsheet.pyc has changed
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/comments.py Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,205 +0,0 @@ -############################################################################### -# -# Comments - A class for writing the Excel XLSX Worksheet file. -# -# Copyright 2013-2016, John McNamara, jmcnamara@cpan.org -# - -import re - -from . import xmlwriter -from .utility import xl_rowcol_to_cell - - -class Comments(xmlwriter.XMLwriter): - """ - A class for writing the Excel XLSX Comments file. - - - """ - - ########################################################################### - # - # Public API. - # - ########################################################################### - - def __init__(self): - """ - Constructor. - - """ - - super(Comments, self).__init__() - self.author_ids = {} - - ########################################################################### - # - # Private API. - # - ########################################################################### - - def _assemble_xml_file(self, comments_data=[]): - # Assemble and write the XML file. - - # Write the XML declaration. - self._xml_declaration() - - # Write the comments element. - self._write_comments() - - # Write the authors element. - self._write_authors(comments_data) - - # Write the commentList element. - self._write_comment_list(comments_data) - - self._xml_end_tag('comments') - - # Close the file. - self._xml_close() - - ########################################################################### - # - # XML methods. - # - ########################################################################### - - def _write_comments(self): - # Write the <comments> element. - xmlns = 'http://schemas.openxmlformats.org/spreadsheetml/2006/main' - - attributes = [('xmlns', xmlns)] - - self._xml_start_tag('comments', attributes) - - def _write_authors(self, comment_data): - # Write the <authors> element. - author_count = 0 - - self._xml_start_tag('authors') - - for comment in comment_data: - author = comment[3] - - if author is not None and author not in self.author_ids: - # Store the author id. - self.author_ids[author] = author_count - author_count += 1 - - # Write the author element. - self._write_author(author) - - self._xml_end_tag('authors') - - def _write_author(self, data): - # Write the <author> element. - self._xml_data_element('author', data) - - def _write_comment_list(self, comment_data): - # Write the <commentList> element. - self._xml_start_tag('commentList') - - for comment in comment_data: - row = comment[0] - col = comment[1] - text = comment[2] - author = comment[3] - - # Look up the author id. - author_id = None - if author is not None: - author_id = self.author_ids[author] - - # Write the comment element. - self._write_comment(row, col, text, author_id) - - self._xml_end_tag('commentList') - - def _write_comment(self, row, col, text, author_id): - # Write the <comment> element. - ref = xl_rowcol_to_cell(row, col) - - attributes = [('ref', ref)] - - if author_id is not None: - attributes.append(('authorId', author_id)) - - self._xml_start_tag('comment', attributes) - - # Write the text element. - self._write_text(text) - - self._xml_end_tag('comment') - - def _write_text(self, text): - # Write the <text> element. - self._xml_start_tag('text') - - # Write the text r element. - self._write_text_r(text) - - self._xml_end_tag('text') - - def _write_text_r(self, text): - # Write the <r> element. - self._xml_start_tag('r') - - # Write the rPr element. - self._write_r_pr() - - # Write the text r element. - self._write_text_t(text) - - self._xml_end_tag('r') - - def _write_text_t(self, text): - # Write the text <t> element. - attributes = [] - - if re.search('^\s', text) or re.search('\s$', text): - attributes.append(('xml:space', 'preserve')) - - self._xml_data_element('t', text, attributes) - - def _write_r_pr(self): - # Write the <rPr> element. - self._xml_start_tag('rPr') - - # Write the sz element. - self._write_sz() - - # Write the color element. - self._write_color() - - # Write the rFont element. - self._write_r_font() - - # Write the family element. - self._write_family() - - self._xml_end_tag('rPr') - - def _write_sz(self): - # Write the <sz> element. - attributes = [('val', 8)] - - self._xml_empty_tag('sz', attributes) - - def _write_color(self): - # Write the <color> element. - attributes = [('indexed', 81)] - - self._xml_empty_tag('color', attributes) - - def _write_r_font(self): - # Write the <rFont> element. - attributes = [('val', 'Tahoma')] - - self._xml_empty_tag('rFont', attributes) - - def _write_family(self): - # Write the <family> element. - attributes = [('val', 2)] - - self._xml_empty_tag('family', attributes)
Binary file test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/comments.pyc has changed
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/compat_collections.py Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,196 +0,0 @@ -""" -From the GC3Pie project: https://code.google.com/p/gc3pie/ - -A backport of the Python standard `collections` package, providing -`namedtuple` and `defaultdict` also on Python 2.4 and 2.5. - -This package actually imports your Python `collections`, and adds -its own versions of `namedtuple` and `defaultdict` only if they are -missing. -""" - -from collections import * -import sys - -try: - defaultdict -except NameError: - class defaultdict(dict): - """ - A backport of `defaultdict` to Python 2.4 - See http://docs.python.org/library/collections.html - """ - def __new__(cls, default_factory=None): - return dict.__new__(cls) - - def __init__(self, default_factory): - self.default_factory = default_factory - - def __missing__(self, key): - try: - return self.default_factory() - except: - raise KeyError("Key '%s' not in dictionary" % key) - - def __getitem__(self, key): - if not dict.__contains__(self, key): - dict.__setitem__(self, key, self.__missing__(key)) - return dict.__getitem__(self, key) - - -try: - namedtuple -except NameError: - # Use Raymond Hettinger's original `namedtuple` package. - # - # Source originally taken from: - # http://code.activestate.com/recipes/500261-named-tuples/ - from operator import itemgetter as _itemgetter - from keyword import iskeyword as _iskeyword - import sys as _sys - - def namedtuple(typename, field_names, verbose=False, rename=False): - """Returns a new subclass of tuple with named fields. - - >>> Point = namedtuple('Point', 'x y') - >>> Point.__doc__ # docstring for the new class - 'Point(x, y)' - >>> p = Point(11, y=22) # instantiate with positional args or keywords - >>> p[0] + p[1] # indexable like a plain tuple - 33 - >>> x, y = p # unpack like a regular tuple - >>> x, y - (11, 22) - >>> p.x + p.y # fields also accessible by name - 33 - >>> d = p._asdict() # convert to a dictionary - >>> d['x'] - 11 - >>> Point(**d) # convert from a dictionary - Point(x=11, y=22) - >>> p._replace(x=100) # _replace() is like str.replace() but targets named fields - Point(x=100, y=22) - - """ - - # Parse and validate the field names. Validation serves two purposes, - # generating informative error messages and preventing template injection attacks. - if isinstance(field_names, basestring): - field_names = field_names.replace(',', ' ').split() # names separated by whitespace and/or commas - field_names = tuple(map(str, field_names)) - if rename: - names = list(field_names) - seen = set() - for i, name in enumerate(names): - if (not min(c.isalnum() or c == '_' for c in name) - or _iskeyword(name) - or not name or name[0].isdigit() - or name.startswith('_') - or name in seen): - names[i] = '_%d' % i - - seen.add(name) - field_names = tuple(names) - for name in (typename,) + field_names: - if not min(c.isalnum() or c == '_' for c in name): - raise ValueError('Type names and field names can only contain alphanumeric characters and underscores: %r' % name) - if _iskeyword(name): - raise ValueError('Type names and field names cannot be a keyword: %r' % name) - if name[0].isdigit(): - raise ValueError('Type names and field names cannot start with a number: %r' % name) - seen_names = set() - for name in field_names: - if name.startswith('_') and not rename: - raise ValueError('Field names cannot start with an underscore: %r' % name) - if name in seen_names: - raise ValueError('Encountered duplicate field name: %r' % name) - seen_names.add(name) - - # Create and fill-in the class template - numfields = len(field_names) - argtxt = repr(field_names).replace("'", "")[1:-1] # tuple repr without parens or quotes - reprtxt = ', '.join('%s=%%r' % name for name in field_names) - template = '''class %(typename)s(tuple): - '%(typename)s(%(argtxt)s)' \n - __slots__ = () \n - _fields = %(field_names)r \n - def __new__(_cls, %(argtxt)s): - return _tuple.__new__(_cls, (%(argtxt)s)) \n - @classmethod - def _make(cls, iterable, new=tuple.__new__, len=len): - 'Make a new %(typename)s object from a sequence or iterable' - result = new(cls, iterable) - if len(result) != %(numfields)d: - raise TypeError('Expected %(numfields)d arguments, got %%d' %% len(result)) - return result \n - def __repr__(self): - return '%(typename)s(%(reprtxt)s)' %% self \n - def _asdict(self): - 'Return a new dict which maps field names to their values' - return dict(zip(self._fields, self)) \n - def _replace(_self, **kwds): - 'Return a new %(typename)s object replacing specified fields with new values' - result = _self._make(map(kwds.pop, %(field_names)r, _self)) - if kwds: - raise ValueError('Got unexpected field names: %%r' %% kwds.keys()) - return result \n - def __getnewargs__(self): - return tuple(self) \n\n''' % locals() - for i, name in enumerate(field_names): - template += ' %s = _property(_itemgetter(%d))\n' % (name, i) - if verbose: - print(template) - - # Execute the template string in a temporary namespace - namespace = dict(_itemgetter=_itemgetter, __name__='namedtuple_%s' % typename, - _property=property, _tuple=tuple) - try: - exec(template) in namespace - except SyntaxError: - e = sys.exc_info()[1] - raise SyntaxError(str(e) + ':\n' + template) - result = namespace[typename] - - # For pickling to work, the __module__ variable needs to be set to the frame - # where the named tuple is created. Bypass this step in environments where - # sys._getframe is not defined (Jython for example) or sys._getframe is not - # defined for arguments greater than 0 (IronPython). - try: - result.__module__ = _sys._getframe(1).f_globals.get('__name__', '__main__') - except (AttributeError, ValueError): - pass - - return result - - -if __name__ == '__main__': - # verify that instances can be pickled - from cPickle import loads, dumps - Point = namedtuple('Point', 'x, y', True) - p = Point(x=10, y=20) - assert p == loads(dumps(p, -1)) - - # test and demonstrate ability to override methods - class Point(namedtuple('Point', 'x y')): - @property - def hypot(self): - return (self.x ** 2 + self.y ** 2) ** 0.5 - - def __str__(self): - return 'Point: x=%6.3f y=%6.3f hypot=%6.3f' % (self.x, self.y, self.hypot) - - for p in Point(3, 4), Point(14, 5), Point(9. / 7, 6): - print(p) - - class Point(namedtuple('Point', 'x y')): - 'Point class with optimized _make() and _replace() without error-checking' - _make = classmethod(tuple.__new__) - - def _replace(self, _map=map, **kwds): - return self._make(_map(kwds.get, ('x', 'y'), self)) - - print(Point(11, 22)._replace(x=100)) - - import doctest - TestResults = namedtuple('TestResults', 'failed attempted') - print(TestResults(*doctest.testmod()))
Binary file test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/compat_collections.pyc has changed
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/compatibility.py Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -############################################################################### -# -# Python 2/3 compatibility functions for XlsxWriter. -# -# Copyright (c), 2013-2016, John McNamara, jmcnamara@cpan.org -# - -import sys -from decimal import Decimal - -try: - # For compatibility between Python 2 and 3. - from StringIO import StringIO -except ImportError: - from io import StringIO - -try: - # For Python 2.6+. - from fractions import Fraction -except ImportError: - Fraction = float - -try: - # For Python 2.6+. - from collections import defaultdict - from collections import namedtuple -except ImportError: - # For Python 2.5 support. - from .compat_collections import defaultdict - from .compat_collections import namedtuple - -# Types to check in Python 2/3. -if sys.version_info[0] == 2: - num_types = (float, int, long, Decimal, Fraction) - str_types = basestring -else: - num_types = (float, int, Decimal, Fraction) - str_types = str - - -if sys.version_info < (2, 6, 0): - from StringIO import StringIO as BytesIO -else: - from io import BytesIO as BytesIO - - -def force_unicode(string): - """Return string as a native string""" - if sys.version_info[0] == 2: - if isinstance(string, unicode): - return string.encode('utf-8') - return string
Binary file test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/compatibility.pyc has changed
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/contenttypes.py Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,197 +0,0 @@ -############################################################################### -# -# ContentTypes - A class for writing the Excel XLSX ContentTypes file. -# -# Copyright 2013-2016, John McNamara, jmcnamara@cpan.org -# - -import copy -from . import xmlwriter - -# Long namespace strings used in the class. -app_package = 'application/vnd.openxmlformats-package.' -app_document = 'application/vnd.openxmlformats-officedocument.' - -defaults = [ - ['rels', app_package + 'relationships+xml'], - ['xml', 'application/xml'], -] - -overrides = [ - ['/docProps/app.xml', app_document + 'extended-properties+xml'], - ['/docProps/core.xml', app_package + 'core-properties+xml'], - ['/xl/styles.xml', app_document + 'spreadsheetml.styles+xml'], - ['/xl/theme/theme1.xml', app_document + 'theme+xml'], - ['/xl/workbook.xml', app_document + 'spreadsheetml.sheet.main+xml'], -] - - -class ContentTypes(xmlwriter.XMLwriter): - """ - A class for writing the Excel XLSX ContentTypes file. - - - """ - - ########################################################################### - # - # Public API. - # - ########################################################################### - - def __init__(self): - """ - Constructor. - - """ - - super(ContentTypes, self).__init__() - - # Copy the defaults in case we need to change them. - self.defaults = copy.deepcopy(defaults) - self.overrides = copy.deepcopy(overrides) - - ########################################################################### - # - # Private API. - # - ########################################################################### - - def _assemble_xml_file(self): - # Assemble and write the XML file. - - # Write the XML declaration. - self._xml_declaration() - - self._write_types() - self._write_defaults() - self._write_overrides() - - self._xml_end_tag('Types') - - # Close the file. - self._xml_close() - - def _add_default(self, default): - # Add elements to the ContentTypes defaults. - self.defaults.append(default) - - def _add_override(self, override): - # Add elements to the ContentTypes overrides. - self.overrides.append(override) - - def _add_worksheet_name(self, worksheet_name): - # Add the name of a worksheet to the ContentTypes overrides. - worksheet_name = "/xl/worksheets/" + worksheet_name + ".xml" - - self._add_override((worksheet_name, - app_document + 'spreadsheetml.worksheet+xml')) - - def _add_chartsheet_name(self, chartsheet_name): - # Add the name of a chartsheet to the ContentTypes overrides. - chartsheet_name = "/xl/chartsheets/" + chartsheet_name + ".xml" - - self._add_override((chartsheet_name, - app_document + 'spreadsheetml.chartsheet+xml')) - - def _add_chart_name(self, chart_name): - # Add the name of a chart to the ContentTypes overrides. - chart_name = "/xl/charts/" + chart_name + ".xml" - - self._add_override((chart_name, app_document + 'drawingml.chart+xml')) - - def _add_drawing_name(self, drawing_name): - # Add the name of a drawing to the ContentTypes overrides. - drawing_name = "/xl/drawings/" + drawing_name + ".xml" - - self._add_override((drawing_name, app_document + 'drawing+xml')) - - def _add_vml_name(self): - # Add the name of a VML drawing to the ContentTypes defaults. - self._add_default(('vml', app_document + 'vmlDrawing')) - - def _add_comment_name(self, comment_name): - # Add the name of a comment to the ContentTypes overrides. - comment_name = "/xl/" + comment_name + ".xml" - - self._add_override((comment_name, - app_document + 'spreadsheetml.comments+xml')) - - def _add_shared_strings(self): - # Add the sharedStrings link to the ContentTypes overrides. - self._add_override(('/xl/sharedStrings.xml', - app_document + 'spreadsheetml.sharedStrings+xml')) - - def _add_calc_chain(self): - # Add the calcChain link to the ContentTypes overrides. - self._add_override(('/xl/calcChain.xml', - app_document + 'spreadsheetml.calcChain+xml')) - - def _add_image_types(self, image_types): - # Add the image default types. - for image_type in image_types: - self._add_default((image_type, 'image/' + image_type)) - - def _add_table_name(self, table_name): - # Add the name of a table to the ContentTypes overrides. - table_name = "/xl/tables/" + table_name + ".xml" - - self._add_override((table_name, - app_document + 'spreadsheetml.table+xml')) - - def _add_vba_project(self): - # Add a vbaProject to the ContentTypes defaults. - - # Change the workbook.xml content-type from xlsx to xlsm. - for i, override in enumerate(self.overrides): - if override[0] == '/xl/workbook.xml': - self.overrides[i][1] = 'application/vnd.ms-excel.' \ - 'sheet.macroEnabled.main+xml' - - self._add_default(('bin', 'application/vnd.ms-office.vbaProject')) - - ########################################################################### - # - # XML methods. - # - ########################################################################### - - def _write_defaults(self): - # Write out all of the <Default> types. - - for extension, content_type in self.defaults: - self._xml_empty_tag('Default', - [('Extension', extension), - ('ContentType', content_type)]) - - def _write_overrides(self): - # Write out all of the <Override> types. - for part_name, content_type in self.overrides: - self._xml_empty_tag('Override', - [('PartName', part_name), - ('ContentType', content_type)]) - - def _write_types(self): - # Write the <Types> element. - xmlns = 'http://schemas.openxmlformats.org/package/2006/content-types' - - attributes = [('xmlns', xmlns,)] - self._xml_start_tag('Types', attributes) - - def _write_default(self, extension, content_type): - # Write the <Default> element. - attributes = [ - ('Extension', extension), - ('ContentType', content_type), - ] - - self._xml_empty_tag('Default', attributes) - - def _write_override(self, part_name, content_type): - # Write the <Override> element. - attributes = [ - ('PartName', part_name), - ('ContentType', content_type), - ] - - self._xml_empty_tag('Override', attributes)
Binary file test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/contenttypes.pyc has changed
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/core.py Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,192 +0,0 @@ -############################################################################### -# -# Core - A class for writing the Excel XLSX Worksheet file. -# -# Copyright 2013-2016, John McNamara, jmcnamara@cpan.org -# - -# Standard packages. -from datetime import datetime - -# Package imports. -from . import xmlwriter - - -class Core(xmlwriter.XMLwriter): - """ - A class for writing the Excel XLSX Core file. - - - """ - - ########################################################################### - # - # Public API. - # - ########################################################################### - - def __init__(self): - """ - Constructor. - - """ - - super(Core, self).__init__() - - self.properties = {} - - ########################################################################### - # - # Private API. - # - ########################################################################### - - def _assemble_xml_file(self): - # Assemble and write the XML file. - - # Write the XML declaration. - self._xml_declaration() - - self._write_cp_core_properties() - self._write_dc_title() - self._write_dc_subject() - self._write_dc_creator() - self._write_cp_keywords() - self._write_dc_description() - self._write_cp_last_modified_by() - self._write_dcterms_created() - self._write_dcterms_modified() - self._write_cp_category() - self._write_cp_content_status() - - self._xml_end_tag('cp:coreProperties') - - # Close the file. - self._xml_close() - - def _set_properties(self, properties): - # Set the document properties. - self.properties = properties - - def _localtime_to_iso8601_date(self, date): - # Convert to a ISO 8601 style "2010-01-01T00:00:00Z" date. - if not date: - date = datetime.now() - - return date.strftime("%Y-%m-%dT%H:%M:%SZ") - - ########################################################################### - # - # XML methods. - # - ########################################################################### - - def _write_cp_core_properties(self): - # Write the <cp:coreProperties> element. - - xmlns_cp = ('http://schemas.openxmlformats.org/package/2006/' + - 'metadata/core-properties') - xmlns_dc = 'http://purl.org/dc/elements/1.1/' - xmlns_dcterms = 'http://purl.org/dc/terms/' - xmlns_dcmitype = 'http://purl.org/dc/dcmitype/' - xmlns_xsi = 'http://www.w3.org/2001/XMLSchema-instance' - - attributes = [ - ('xmlns:cp', xmlns_cp), - ('xmlns:dc', xmlns_dc), - ('xmlns:dcterms', xmlns_dcterms), - ('xmlns:dcmitype', xmlns_dcmitype), - ('xmlns:xsi', xmlns_xsi), - ] - - self._xml_start_tag('cp:coreProperties', attributes) - - def _write_dc_creator(self): - # Write the <dc:creator> element. - data = self.properties.get('author', '') - - self._xml_data_element('dc:creator', data) - - def _write_cp_last_modified_by(self): - # Write the <cp:lastModifiedBy> element. - data = self.properties.get('author', '') - - self._xml_data_element('cp:lastModifiedBy', data) - - def _write_dcterms_created(self): - # Write the <dcterms:created> element. - date = self.properties.get('created', datetime.now()) - - xsi_type = 'dcterms:W3CDTF' - - date = self._localtime_to_iso8601_date(date) - - attributes = [('xsi:type', xsi_type,)] - - self._xml_data_element('dcterms:created', date, attributes) - - def _write_dcterms_modified(self): - # Write the <dcterms:modified> element. - date = self.properties.get('created', datetime.now()) - - xsi_type = 'dcterms:W3CDTF' - - date = self._localtime_to_iso8601_date(date) - - attributes = [('xsi:type', xsi_type,)] - - self._xml_data_element('dcterms:modified', date, attributes) - - def _write_dc_title(self): - # Write the <dc:title> element. - if 'title' in self.properties: - data = self.properties['title'] - else: - return - - self._xml_data_element('dc:title', data) - - def _write_dc_subject(self): - # Write the <dc:subject> element. - if 'subject' in self.properties: - data = self.properties['subject'] - else: - return - - self._xml_data_element('dc:subject', data) - - def _write_cp_keywords(self): - # Write the <cp:keywords> element. - if 'keywords' in self.properties: - data = self.properties['keywords'] - else: - return - - self._xml_data_element('cp:keywords', data) - - def _write_dc_description(self): - # Write the <dc:description> element. - if 'comments' in self.properties: - data = self.properties['comments'] - else: - return - - self._xml_data_element('dc:description', data) - - def _write_cp_category(self): - # Write the <cp:category> element. - if 'category' in self.properties: - data = self.properties['category'] - else: - return - - self._xml_data_element('cp:category', data) - - def _write_cp_content_status(self): - # Write the <cp:contentStatus> element. - if 'status' in self.properties: - data = self.properties['status'] - else: - return - - self._xml_data_element('cp:contentStatus', data)
Binary file test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/core.pyc has changed
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/drawing.py Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1096 +0,0 @@ -############################################################################### -# -# Drawing - A class for writing the Excel XLSX Drawing file. -# -# Copyright 2013-2016, John McNamara, jmcnamara@cpan.org -# - -import re - -from . import xmlwriter -from .shape import Shape -from .utility import get_rgb_color - - -class Drawing(xmlwriter.XMLwriter): - """ - A class for writing the Excel XLSX Drawing file. - - - """ - - ########################################################################### - # - # Public API. - # - ########################################################################### - - def __init__(self): - """ - Constructor. - - """ - - super(Drawing, self).__init__() - - self.drawings = [] - self.embedded = 0 - self.orientation = 0 - - ########################################################################### - # - # Private API. - # - ########################################################################### - - def _assemble_xml_file(self): - # Assemble and write the XML file. - - # Write the XML declaration. - self._xml_declaration() - - # Write the xdr:wsDr element. - self._write_drawing_workspace() - - if self.embedded: - index = 1 - for drawing in self.drawings: - # Write the xdr:twoCellAnchor element. - self._write_two_cell_anchor(index, drawing) - index += 1 - - if drawing['url']: - index += 1 - - else: - # Write the xdr:absoluteAnchor element. - self._write_absolute_anchor(1) - - self._xml_end_tag('xdr:wsDr') - - # Close the file. - self._xml_close() - - def _add_drawing_object(self, drawing_object): - # Add a chart, image or shape sub object to the drawing. - - obj = { - 'anchor_type': drawing_object[0], - 'col_from': drawing_object[1], - 'row_from': drawing_object[2], - 'col_from_offset': drawing_object[3], - 'row_from_offset': drawing_object[4], - 'col_to': drawing_object[5], - 'row_to': drawing_object[6], - 'col_to_offset': drawing_object[7], - 'row_to_offset': drawing_object[8], - 'col_absolute': drawing_object[9], - 'row_absolute': drawing_object[10], - 'width': drawing_object[11], - 'height': drawing_object[12], - 'description': drawing_object[13], - 'shape': drawing_object[14], - 'url': None, - 'tip': None, - 'anchor': None - } - - if len(drawing_object) > 15: - obj['url'] = drawing_object[15] - obj['tip'] = drawing_object[16] - obj['anchor'] = drawing_object[17] - - self.drawings.append(obj) - - ########################################################################### - # - # XML methods. - # - ########################################################################### - - def _write_drawing_workspace(self): - # Write the <xdr:wsDr> element. - schema = 'http://schemas.openxmlformats.org/drawingml/' - xmlns_xdr = schema + '2006/spreadsheetDrawing' - xmlns_a = schema + '2006/main' - - attributes = [ - ('xmlns:xdr', xmlns_xdr), - ('xmlns:a', xmlns_a), - ] - - self._xml_start_tag('xdr:wsDr', attributes) - - def _write_two_cell_anchor(self, index, drawing): - # Write the <xdr:twoCellAnchor> element. - shape = drawing['shape'] - - options = { - 'description': drawing['description'], - 'url': drawing['url'], - 'tip': drawing['tip'] - } - - attributes = [] - - # Add attribute for images. - if drawing['anchor_type'] == 2: - if drawing['anchor'] == 3: - attributes.append(('editAs', 'absolute')) - elif drawing['anchor'] == 1: - pass - else: - attributes.append(('editAs', 'oneCell')) - - # Add editAs attribute for shapes. - if shape and shape.edit_as: - attributes.append(('editAs', shape.edit_as)) - - self._xml_start_tag('xdr:twoCellAnchor', attributes) - - # Write the xdr:from element. - self._write_from( - drawing['col_from'], - drawing['row_from'], - drawing['col_from_offset'], - drawing['row_from_offset']) - - # Write the xdr:from element. - self._write_to( - drawing['col_to'], - drawing['row_to'], - drawing['col_to_offset'], - drawing['row_to_offset']) - - if drawing['anchor_type'] == 1: - # Graphic frame. - # Write the xdr:graphicFrame element for charts. - self._write_graphic_frame(index, drawing['description']) - elif drawing['anchor_type'] == 2: - # Write the xdr:pic element. - self._write_pic(index, - drawing['col_absolute'], - drawing['row_absolute'], - drawing['width'], - drawing['height'], - shape, - options) - else: - # Write the xdr:sp element for shapes. - self._write_sp(index, - drawing['col_absolute'], - drawing['row_absolute'], - drawing['width'], - drawing['height'], - shape) - - # Write the xdr:clientData element. - self._write_client_data() - - self._xml_end_tag('xdr:twoCellAnchor') - - def _write_absolute_anchor(self, frame_index): - self._xml_start_tag('xdr:absoluteAnchor') - # Write the <xdr:absoluteAnchor> element. - - # Different co-ordinates for horizontal (= 0) and vertical (= 1). - if self.orientation == 0: - # Write the xdr:pos element. - self._write_pos(0, 0) - - # Write the xdr:ext element. - self._write_ext(9308969, 6078325) - - else: - # Write the xdr:pos element. - self._write_pos(0, -47625) - - # Write the xdr:ext element. - self._write_ext(6162675, 6124575) - - # Write the xdr:graphicFrame element. - self._write_graphic_frame(frame_index) - - # Write the xdr:clientData element. - self._write_client_data() - - self._xml_end_tag('xdr:absoluteAnchor') - - def _write_from(self, col, row, col_offset, row_offset): - # Write the <xdr:from> element. - self._xml_start_tag('xdr:from') - - # Write the xdr:col element. - self._write_col(col) - - # Write the xdr:colOff element. - self._write_col_off(col_offset) - - # Write the xdr:row element. - self._write_row(row) - - # Write the xdr:rowOff element. - self._write_row_off(row_offset) - - self._xml_end_tag('xdr:from') - - def _write_to(self, col, row, col_offset, row_offset): - # Write the <xdr:to> element. - self._xml_start_tag('xdr:to') - - # Write the xdr:col element. - self._write_col(col) - - # Write the xdr:colOff element. - self._write_col_off(col_offset) - - # Write the xdr:row element. - self._write_row(row) - - # Write the xdr:rowOff element. - self._write_row_off(row_offset) - - self._xml_end_tag('xdr:to') - - def _write_col(self, data): - # Write the <xdr:col> element. - self._xml_data_element('xdr:col', data) - - def _write_col_off(self, data): - # Write the <xdr:colOff> element. - self._xml_data_element('xdr:colOff', data) - - def _write_row(self, data): - # Write the <xdr:row> element. - self._xml_data_element('xdr:row', data) - - def _write_row_off(self, data): - # Write the <xdr:rowOff> element. - self._xml_data_element('xdr:rowOff', data) - - def _write_pos(self, x, y): - # Write the <xdr:pos> element. - - attributes = [('x', x), ('y', y)] - - self._xml_empty_tag('xdr:pos', attributes) - - def _write_ext(self, cx, cy): - # Write the <xdr:ext> element. - - attributes = [('cx', cx), ('cy', cy)] - - self._xml_empty_tag('xdr:ext', attributes) - - def _write_graphic_frame(self, index, name=None): - # Write the <xdr:graphicFrame> element. - attributes = [('macro', '')] - - self._xml_start_tag('xdr:graphicFrame', attributes) - - # Write the xdr:nvGraphicFramePr element. - self._write_nv_graphic_frame_pr(index, name) - - # Write the xdr:xfrm element. - self._write_xfrm() - - # Write the a:graphic element. - self._write_atag_graphic(index) - - self._xml_end_tag('xdr:graphicFrame') - - def _write_nv_graphic_frame_pr(self, index, name): - # Write the <xdr:nvGraphicFramePr> element. - - if not name: - name = 'Chart ' + str(index) - - self._xml_start_tag('xdr:nvGraphicFramePr') - - # Write the xdr:cNvPr element. - self._write_c_nv_pr(index + 1, name) - - # Write the xdr:cNvGraphicFramePr element. - self._write_c_nv_graphic_frame_pr() - - self._xml_end_tag('xdr:nvGraphicFramePr') - - def _write_c_nv_pr(self, index, name, options={}): - # Write the <xdr:cNvPr> element. - descr = options.get('description', None) - url = options.get('url', None) - tip = options.get('tip', None) - - attributes = [('id', index), ('name', name)] - - # Add description attribute for images. - if descr is not None: - attributes.append(('descr', descr)) - - if url: - self._xml_start_tag('xdr:cNvPr', attributes) - schema = "http://schemas.openxmlformats.org" - att = [ - ('xmlns:r', schema + "/officeDocument/2006/relationships"), - ('r:id', "rId" + str(index - 1)) - ] - - if tip: - att.append(('tooltip', tip)) - - self._xml_empty_tag('a:hlinkClick', att) - self._xml_end_tag('xdr:cNvPr') - else: - self._xml_empty_tag('xdr:cNvPr', attributes) - - def _write_c_nv_graphic_frame_pr(self): - # Write the <xdr:cNvGraphicFramePr> element. - if self.embedded: - self._xml_empty_tag('xdr:cNvGraphicFramePr') - else: - self._xml_start_tag('xdr:cNvGraphicFramePr') - - # Write the a:graphicFrameLocks element. - self._write_a_graphic_frame_locks() - - self._xml_end_tag('xdr:cNvGraphicFramePr') - - def _write_a_graphic_frame_locks(self): - # Write the <a:graphicFrameLocks> element. - attributes = [('noGrp', 1)] - - self._xml_empty_tag('a:graphicFrameLocks', attributes) - - def _write_xfrm(self): - # Write the <xdr:xfrm> element. - self._xml_start_tag('xdr:xfrm') - - # Write the xfrmOffset element. - self._write_xfrm_offset() - - # Write the xfrmOffset element. - self._write_xfrm_extension() - - self._xml_end_tag('xdr:xfrm') - - def _write_xfrm_offset(self): - # Write the <a:off> xfrm sub-element. - - attributes = [ - ('x', 0), - ('y', 0), - ] - - self._xml_empty_tag('a:off', attributes) - - def _write_xfrm_extension(self): - # Write the <a:ext> xfrm sub-element. - - attributes = [ - ('cx', 0), - ('cy', 0), - ] - - self._xml_empty_tag('a:ext', attributes) - - def _write_atag_graphic(self, index): - # Write the <a:graphic> element. - self._xml_start_tag('a:graphic') - - # Write the a:graphicData element. - self._write_atag_graphic_data(index) - - self._xml_end_tag('a:graphic') - - def _write_atag_graphic_data(self, index): - # Write the <a:graphicData> element. - uri = 'http://schemas.openxmlformats.org/drawingml/2006/chart' - - attributes = [('uri', uri,)] - - self._xml_start_tag('a:graphicData', attributes) - - # Write the c:chart element. - self._write_c_chart('rId' + str(index)) - - self._xml_end_tag('a:graphicData') - - def _write_c_chart(self, r_id): - # Write the <c:chart> element. - - schema = 'http://schemas.openxmlformats.org/' - xmlns_c = schema + 'drawingml/2006/chart' - xmlns_r = schema + 'officeDocument/2006/relationships' - - attributes = [ - ('xmlns:c', xmlns_c), - ('xmlns:r', xmlns_r), - ('r:id', r_id), - ] - - self._xml_empty_tag('c:chart', attributes) - - def _write_client_data(self): - # Write the <xdr:clientData> element. - self._xml_empty_tag('xdr:clientData') - - def _write_sp(self, index, col_absolute, row_absolute, - width, height, shape): - # Write the <xdr:sp> element. - - if shape and shape.connect: - attributes = [('macro', '')] - self._xml_start_tag('xdr:cxnSp', attributes) - - # Write the xdr:nvCxnSpPr element. - self._write_nv_cxn_sp_pr(index, shape) - - # Write the xdr:spPr element. - self._write_xdr_sp_pr(index, col_absolute, row_absolute, width, - height, shape) - - self._xml_end_tag('xdr:cxnSp') - else: - # Add attribute for shapes. - attributes = [('macro', ''), - ('textlink', '')] - - self._xml_start_tag('xdr:sp', attributes) - - # Write the xdr:nvSpPr element. - self._write_nv_sp_pr(index, shape) - - # Write the xdr:spPr element. - self._write_xdr_sp_pr(index, col_absolute, row_absolute, width, - height, shape) - - # Write the xdr:style element. - self._write_style() - - # Write the xdr:txBody element. - if shape.text is not None: - self._write_tx_body(col_absolute, row_absolute, width, height, - shape) - - self._xml_end_tag('xdr:sp') - - def _write_nv_cxn_sp_pr(self, index, shape): - # Write the <xdr:nvCxnSpPr> element. - self._xml_start_tag('xdr:nvCxnSpPr') - - name = shape.name + ' ' + str(index) - if name is not None: - self._write_c_nv_pr(index, name) - - self._xml_start_tag('xdr:cNvCxnSpPr') - - attributes = [('noChangeShapeType', '1')] - self._xml_empty_tag('a:cxnSpLocks', attributes) - - if shape.start: - attributes = [('id', shape.start), ('idx', shape.start_index)] - self._xml_empty_tag('a:stCxn', attributes) - - if shape.end: - attributes = [('id', shape.end), ('idx', shape.end_index)] - self._xml_empty_tag('a:endCxn', attributes) - - self._xml_end_tag('xdr:cNvCxnSpPr') - self._xml_end_tag('xdr:nvCxnSpPr') - - def _write_nv_sp_pr(self, index, shape): - # Write the <xdr:NvSpPr> element. - attributes = [] - - self._xml_start_tag('xdr:nvSpPr') - - name = shape.name + ' ' + str(index) - - self._write_c_nv_pr(index + 1, name) - - if shape.name == 'TextBox': - attributes = [('txBox', 1)] - - self._xml_empty_tag('xdr:cNvSpPr', attributes) - - # attributes = [('noChangeArrowheads', '1')] - # self._xml_empty_tag('a:spLocks', attributes) - # self._xml_end_tag('xdr:cNvSpPr') - - self._xml_end_tag('xdr:nvSpPr') - - def _write_pic(self, index, col_absolute, row_absolute, - width, height, shape, options): - # Write the <xdr:pic> element. - self._xml_start_tag('xdr:pic') - - # Write the xdr:nvPicPr element. - self._write_nv_pic_pr(index, options) - - # Write the xdr:blipFill element. - if options.get('url', None): - index = index + 1 - - self._write_blip_fill(index) - - # Write the xdr:spPr element. - self._write_sp_pr(col_absolute, row_absolute, width, height, - shape) - - self._xml_end_tag('xdr:pic') - - def _write_nv_pic_pr(self, index, options): - # Write the <xdr:nvPicPr> element. - self._xml_start_tag('xdr:nvPicPr') - - # Write the xdr:cNvPr element. - self._write_c_nv_pr(index + 1, 'Picture ' + str(index), options) - - # Write the xdr:cNvPicPr element. - self._write_c_nv_pic_pr() - - self._xml_end_tag('xdr:nvPicPr') - - def _write_c_nv_pic_pr(self): - # Write the <xdr:cNvPicPr> element. - self._xml_start_tag('xdr:cNvPicPr') - - # Write the a:picLocks element. - self._write_a_pic_locks() - - self._xml_end_tag('xdr:cNvPicPr') - - def _write_a_pic_locks(self): - # Write the <a:picLocks> element. - attributes = [('noChangeAspect', 1)] - - self._xml_empty_tag('a:picLocks', attributes) - - def _write_blip_fill(self, index): - # Write the <xdr:blipFill> element. - self._xml_start_tag('xdr:blipFill') - - # Write the a:blip element. - self._write_a_blip(index) - - # Write the a:stretch element. - self._write_a_stretch() - - self._xml_end_tag('xdr:blipFill') - - def _write_a_blip(self, index): - # Write the <a:blip> element. - schema = 'http://schemas.openxmlformats.org/officeDocument/' - xmlns_r = schema + '2006/relationships' - r_embed = 'rId' + str(index) - - attributes = [ - ('xmlns:r', xmlns_r), - ('r:embed', r_embed)] - - self._xml_empty_tag('a:blip', attributes) - - def _write_a_stretch(self): - # Write the <a:stretch> element. - self._xml_start_tag('a:stretch') - - # Write the a:fillRect element. - self._write_a_fill_rect() - - self._xml_end_tag('a:stretch') - - def _write_a_fill_rect(self): - # Write the <a:fillRect> element. - self._xml_empty_tag('a:fillRect') - - def _write_sp_pr(self, col_absolute, row_absolute, width, height, - shape=None): - # Write the <xdr:spPr> element, for charts. - - self._xml_start_tag('xdr:spPr') - - # Write the a:xfrm element. - self._write_a_xfrm(col_absolute, row_absolute, width, height) - - # Write the a:prstGeom element. - self._write_a_prst_geom(shape) - - self._xml_end_tag('xdr:spPr') - - def _write_xdr_sp_pr(self, index, col_absolute, row_absolute, width, - height, shape): - # Write the <xdr:spPr> element for shapes. - - attributes = [] - # attributes = [('bwMode', 'auto')] - - self._xml_start_tag('xdr:spPr', attributes) - - # Write the a:xfrm element. - self._write_a_xfrm(col_absolute, row_absolute, width, height, shape) - - # Write the a:prstGeom element. - self._write_a_prst_geom(shape) - - if shape.fill: - if not shape.fill['defined']: - # Write the a:solidFill element. - self._write_a_solid_fill_scheme('lt1') - elif 'none' in shape.fill: - # Write the a:noFill element. - self._xml_empty_tag('a:noFill') - elif 'color' in shape.fill: - # Write the a:solidFill element. - self._write_a_solid_fill(get_rgb_color(shape.fill['color'])) - - if shape.gradient: - # Write the a:gradFill element. - self._write_a_grad_fill(shape.gradient) - - # Write the a:ln element. - self._write_a_ln(shape.line) - - self._xml_end_tag('xdr:spPr') - - def _write_a_xfrm(self, col_absolute, row_absolute, width, height, - shape=None): - # Write the <a:xfrm> element. - attributes = [] - - if shape: - if shape.rotation: - rotation = shape.rotation - rotation *= 60000 - attributes.append(('rot', rotation)) - - if shape.flip_h: - attributes.append(('flipH', 1)) - if shape.flip_v: - attributes.append(('flipV', 1)) - - self._xml_start_tag('a:xfrm', attributes) - - # Write the a:off element. - self._write_a_off(col_absolute, row_absolute) - - # Write the a:ext element. - self._write_a_ext(width, height) - - self._xml_end_tag('a:xfrm') - - def _write_a_off(self, x, y): - # Write the <a:off> element. - attributes = [ - ('x', x), - ('y', y), - ] - - self._xml_empty_tag('a:off', attributes) - - def _write_a_ext(self, cx, cy): - # Write the <a:ext> element. - attributes = [ - ('cx', cx), - ('cy', cy), - ] - - self._xml_empty_tag('a:ext', attributes) - - def _write_a_prst_geom(self, shape=None): - # Write the <a:prstGeom> element. - attributes = [('prst', 'rect')] - - self._xml_start_tag('a:prstGeom', attributes) - - # Write the a:avLst element. - self._write_a_av_lst(shape) - - self._xml_end_tag('a:prstGeom') - - def _write_a_av_lst(self, shape=None): - # Write the <a:avLst> element. - adjustments = [] - - if shape and shape.adjustments: - adjustments = shape.adjustments - - if adjustments: - self._xml_start_tag('a:avLst') - - i = 0 - for adj in adjustments: - i += 1 - # Only connectors have multiple adjustments. - if shape.connect: - suffix = i - else: - suffix = '' - - # Scale Adjustments: 100,000 = 100%. - adj_int = str(int(adj * 1000)) - - attributes = [('name', 'adj' + suffix), - ('fmla', 'val' + adj_int)] - - self._xml_empty_tag('a:gd', attributes) - - self._xml_end_tag('a:avLst') - else: - self._xml_empty_tag('a:avLst') - - def _write_a_solid_fill(self, rgb): - # Write the <a:solidFill> element. - if rgb is None: - rgb = 'FFFFFF' - - self._xml_start_tag('a:solidFill') - - # Write the a:srgbClr element. - self._write_a_srgb_clr(rgb) - - self._xml_end_tag('a:solidFill') - - def _write_a_solid_fill_scheme(self, color, shade=None): - - attributes = [('val', color)] - - self._xml_start_tag('a:solidFill') - - if shade: - self._xml_start_tag('a:schemeClr', attributes) - self._write_a_shade(shade) - self._xml_end_tag('a:schemeClr') - else: - self._xml_empty_tag('a:schemeClr', attributes) - - self._xml_end_tag('a:solidFill') - - def _write_a_ln(self, line): - # Write the <a:ln> element. - width = line.get('width', 0.75) - - # Round width to nearest 0.25, like Excel. - width = int((width + 0.125) * 4) / 4.0 - - # Convert to internal units. - width = int(0.5 + (12700 * width)) - - attributes = [ - ('w', width), - ('cmpd', 'sng') - ] - - self._xml_start_tag('a:ln', attributes) - - if 'none' in line: - # Write the a:noFill element. - self._xml_empty_tag('a:noFill') - - elif 'color' in line: - # Write the a:solidFill element. - self._write_a_solid_fill(get_rgb_color(line['color'])) - - else: - # Write the a:solidFill element. - self._write_a_solid_fill_scheme('lt1', '50000') - - # Write the line/dash type. - line_type = line.get('dash_type') - if line_type: - # Write the a:prstDash element. - self._write_a_prst_dash(line_type) - - self._xml_end_tag('a:ln') - - def _write_tx_body(self, col_absolute, row_absolute, width, height, shape): - # Write the <xdr:txBody> element. - attributes = [ - ('wrap', "square"), - ('rtlCol', "0"), - ] - - if not shape.align['defined']: - attributes.append(('anchor', 't')) - else: - - if 'vertical' in shape.align: - align = shape.align['vertical'] - if align == 'top': - attributes.append(('anchor', 't')) - elif align == 'middle': - attributes.append(('anchor', 'ctr')) - elif align == 'bottom': - attributes.append(('anchor', 'b')) - else: - attributes.append(('anchor', 't')) - - if 'horizontal' in shape.align: - align = shape.align['horizontal'] - if align == 'center': - attributes.append(('anchorCtr', '1')) - else: - attributes.append(('anchorCtr', '0')) - - self._xml_start_tag('xdr:txBody') - self._xml_empty_tag('a:bodyPr', attributes) - self._xml_empty_tag('a:lstStyle') - - lines = shape.text.split('\n') - - # Set the font attributes. - font = shape.font - style_attrs = Shape._get_font_style_attributes(font) - latin_attrs = Shape._get_font_latin_attributes(font) - style_attrs.insert(0, ('lang', font['lang'])) - - for line in lines: - self._xml_start_tag('a:p') - - if line == '': - self._write_font_run(font, style_attrs, latin_attrs, - 'a:endParaRPr') - self._xml_end_tag('a:p') - continue - - self._xml_start_tag('a:r') - - self._write_font_run(font, style_attrs, latin_attrs, 'a:rPr') - - self._xml_data_element('a:t', line) - - self._xml_end_tag('a:r') - self._xml_end_tag('a:p') - - self._xml_end_tag('xdr:txBody') - - def _write_font_run(self, font, style_attrs, latin_attrs, run_type): - # Write a:rPr or a:endParaRPr. - if font.get('color') is not None: - has_color = True - else: - has_color = False - - if latin_attrs or has_color: - self._xml_start_tag(run_type, style_attrs) - - if has_color: - self._write_a_solid_fill(get_rgb_color(font['color'])) - - if latin_attrs: - self._write_a_latin(latin_attrs) - self._write_a_cs(latin_attrs) - - self._xml_end_tag(run_type) - else: - self._xml_empty_tag(run_type, style_attrs) - - def _write_style(self): - # Write the <xdr:style> element. - self._xml_start_tag('xdr:style') - - # Write the a:lnRef element. - self._write_a_ln_ref() - - # Write the a:fillRef element. - self._write_a_fill_ref() - - # Write the a:effectRef element. - self._write_a_effect_ref() - - # Write the a:fontRef element. - self._write_a_font_ref() - - self._xml_end_tag('xdr:style') - - def _write_a_ln_ref(self): - # Write the <a:lnRef> element. - attributes = [('idx', '0')] - - self._xml_start_tag('a:lnRef', attributes) - - # Write the a:scrgbClr element. - self._write_a_scrgb_clr() - - self._xml_end_tag('a:lnRef') - - def _write_a_fill_ref(self): - # Write the <a:fillRef> element. - attributes = [('idx', '0')] - - self._xml_start_tag('a:fillRef', attributes) - - # Write the a:scrgbClr element. - self._write_a_scrgb_clr() - - self._xml_end_tag('a:fillRef') - - def _write_a_effect_ref(self): - # Write the <a:effectRef> element. - attributes = [('idx', '0')] - - self._xml_start_tag('a:effectRef', attributes) - - # Write the a:scrgbClr element. - self._write_a_scrgb_clr() - - self._xml_end_tag('a:effectRef') - - def _write_a_scrgb_clr(self): - # Write the <a:scrgbClr> element. - - attributes = [ - ('r', '0'), - ('g', '0'), - ('b', '0'), - ] - - self._xml_empty_tag('a:scrgbClr', attributes) - - def _write_a_font_ref(self): - # Write the <a:fontRef> element. - attributes = [('idx', 'minor')] - - self._xml_start_tag('a:fontRef', attributes) - - # Write the a:schemeClr element. - self._write_a_scheme_clr('dk1') - - self._xml_end_tag('a:fontRef') - - def _write_a_scheme_clr(self, val): - # Write the <a:schemeClr> element. - attributes = [('val', val)] - - self._xml_empty_tag('a:schemeClr', attributes) - - def _write_a_shade(self, shade): - # Write the <a:shade> element. - attributes = [('val', shade)] - - self._xml_empty_tag('a:shade', attributes) - - def _write_a_prst_dash(self, val): - # Write the <a:prstDash> element. - - attributes = [('val', val)] - - self._xml_empty_tag('a:prstDash', attributes) - - def _write_a_grad_fill(self, gradient): - # Write the <a:gradFill> element. - - attributes = [('flip', 'none'), ('rotWithShape', '1')] - - if gradient['type'] == 'linear': - attributes = [] - - self._xml_start_tag('a:gradFill', attributes) - - # Write the a:gsLst element. - self._write_a_gs_lst(gradient) - - if gradient['type'] == 'linear': - # Write the a:lin element. - self._write_a_lin(gradient['angle']) - else: - # Write the a:path element. - self._write_a_path(gradient['type']) - - # Write the a:tileRect element. - self._write_a_tile_rect(gradient['type']) - - self._xml_end_tag('a:gradFill') - - def _write_a_gs_lst(self, gradient): - # Write the <a:gsLst> element. - positions = gradient['positions'] - colors = gradient['colors'] - - self._xml_start_tag('a:gsLst') - - for i in range(len(colors)): - pos = int(positions[i] * 1000) - attributes = [('pos', pos)] - self._xml_start_tag('a:gs', attributes) - - # Write the a:srgbClr element. - # TODO: Wait for a feature request to support transparency. - color = get_rgb_color(colors[i]) - self._write_a_srgb_clr(color) - - self._xml_end_tag('a:gs') - - self._xml_end_tag('a:gsLst') - - def _write_a_lin(self, angle): - # Write the <a:lin> element. - - angle = int(60000 * angle) - - attributes = [ - ('ang', angle), - ('scaled', '0'), - ] - - self._xml_empty_tag('a:lin', attributes) - - def _write_a_path(self, gradient_type): - # Write the <a:path> element. - - attributes = [('path', gradient_type)] - - self._xml_start_tag('a:path', attributes) - - # Write the a:fillToRect element. - self._write_a_fill_to_rect(gradient_type) - - self._xml_end_tag('a:path') - - def _write_a_fill_to_rect(self, gradient_type): - # Write the <a:fillToRect> element. - - l = '100000' - t = '100000' - - if gradient_type == 'shape': - attributes = [ - ('l', '50000'), - ('t', '50000'), - ('r', '50000'), - ('b', '50000'), - ] - else: - attributes = [ - ('l', '100000'), - ('t', '100000'), - ] - - self._xml_empty_tag('a:fillToRect', attributes) - - def _write_a_tile_rect(self, gradient_type): - # Write the <a:tileRect> element. - - if gradient_type == 'shape': - attributes = [] - else: - attributes = [ - ('r', '-100000'), - ('b', '-100000'), - ] - - self._xml_empty_tag('a:tileRect', attributes) - - def _write_a_srgb_clr(self, val): - # Write the <a:srgbClr> element. - - attributes = [('val', val)] - - self._xml_empty_tag('a:srgbClr', attributes) - - def _write_a_latin(self, attributes): - # Write the <a:latin> element. - self._xml_empty_tag('a:latin', attributes) - - def _write_a_cs(self, attributes): - # Write the <a:latin> element. - self._xml_empty_tag('a:cs', attributes)
Binary file test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/drawing.pyc has changed
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/format.py Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,995 +0,0 @@ -############################################################################### -# -# Format - A class for writing the Excel XLSX Worksheet file. -# -# Copyright 2013-2016, John McNamara, jmcnamara@cpan.org -# - -# Package imports. -from . import xmlwriter - - -class Format(xmlwriter.XMLwriter): - """ - A class for writing the Excel XLSX Format file. - - - """ - - ########################################################################### - # - # Public API. - # - ########################################################################### - - def __init__(self, properties={}, xf_indices=None, dxf_indices=None): - """ - Constructor. - - """ - - super(Format, self).__init__() - - self.xf_format_indices = xf_indices - self.dxf_format_indices = dxf_indices - self.xf_index = None - self.dxf_index = None - - self.num_format = 0 - self.num_format_index = 0 - self.font_index = 0 - self.has_font = 0 - self.has_dxf_font = 0 - - self.bold = 0 - self.underline = 0 - self.italic = 0 - self.font_name = 'Calibri' - self.font_size = 11 - self.font_color = 0x0 - self.font_strikeout = 0 - self.font_outline = 0 - self.font_shadow = 0 - self.font_script = 0 - self.font_family = 2 - self.font_charset = 0 - self.font_scheme = 'minor' - self.font_condense = 0 - self.font_extend = 0 - self.theme = 0 - self.hyperlink = 0 - - self.hidden = 0 - self.locked = 1 - - self.text_h_align = 0 - self.text_wrap = 0 - self.text_v_align = 0 - self.text_justlast = 0 - self.rotation = 0 - self.center_across = 0 - - self.fg_color = 0 - self.bg_color = 0 - self.pattern = 0 - self.has_fill = 0 - self.has_dxf_fill = 0 - self.fill_index = 0 - self.fill_count = 0 - - self.border_index = 0 - self.has_border = 0 - self.has_dxf_border = 0 - self.border_count = 0 - - self.bottom = 0 - self.bottom_color = 0 - self.diag_border = 0 - self.diag_color = 0 - self.diag_type = 0 - self.left = 0 - self.left_color = 0 - self.right = 0 - self.right_color = 0 - self.top = 0 - self.top_color = 0 - - self.indent = 0 - self.shrink = 0 - self.merge_range = 0 - self.reading_order = 0 - self.just_distrib = 0 - self.color_indexed = 0 - self.font_only = 0 - - # Convert properties in the constructor to method calls. - for key, value in properties.items(): - getattr(self, 'set_' + key)(value) - - ########################################################################### - # - # Format properties. - # - ########################################################################### - - def set_font_name(self, font_name): - """ - Set the Format font_name property such as 'Time New Roman'. The - default Excel font is 'Calibri'. - - Args: - font_name: String with the font name. No default. - - Returns: - Nothing. - - """ - self.font_name = font_name - - def set_font_size(self, font_size=11): - """ - Set the Format font_size property. The default Excel font size is 11. - - Args: - font_size: Int with font size. No default. - - Returns: - Nothing. - - """ - self.font_size = font_size - - def set_font_color(self, font_color): - """ - Set the Format font_color property. The Excel default is black. - - Args: - font_color: String with the font color. No default. - - Returns: - Nothing. - - """ - self.font_color = self._get_color(font_color) - - def set_bold(self, bold=1): - """ - Set the Format bold property. - - Args: - bold: Default is 1, turns property on. - - Returns: - Nothing. - - """ - self.bold = bold - - def set_italic(self, italic=1): - """ - Set the Format italic property. - - Args: - italic: Default is 1, turns property on. - - Returns: - Nothing. - - """ - self.italic = italic - - def set_underline(self, underline=1): - """ - Set the Format underline property. - - Args: - underline: Default is 1, single underline. - - Returns: - Nothing. - - """ - self.underline = underline - - def set_font_strikeout(self, font_strikeout=1): - """ - Set the Format font_strikeout property. - - Args: - font_strikeout: Default is 1, turns property on. - - Returns: - Nothing. - - """ - self.font_strikeout = font_strikeout - - def set_font_script(self, font_script=1): - """ - Set the Format font_script property. - - Args: - font_script: Default is 1, superscript. - - Returns: - Nothing. - - """ - self.font_script = font_script - - def set_font_outline(self, font_outline=1): - """ - Set the Format font_outline property. - - Args: - font_outline: Default is 1, turns property on. - - Returns: - Nothing. - - """ - self.font_outline = font_outline - - def set_font_shadow(self, font_shadow=1): - """ - Set the Format font_shadow property. - - Args: - font_shadow: Default is 1, turns property on. - - Returns: - Nothing. - - """ - self.font_shadow = font_shadow - - def set_num_format(self, num_format): - """ - Set the Format num_format property such as '#,##0'. - - Args: - num_format: String representing the number format. No default. - - Returns: - Nothing. - - """ - self.num_format = num_format - - def set_locked(self, locked=1): - """ - Set the Format locked property. - - Args: - locked: Default is 1, turns property on. - - Returns: - Nothing. - - """ - self.locked = locked - - def set_hidden(self, hidden=1): - """ - Set the Format hidden property. - - Args: - hidden: Default is 1, turns property on. - - Returns: - Nothing. - - """ - self.hidden = hidden - - def set_align(self, alignment): - """ - Set the Format cell alignment. - - Args: - alignment: String representing alignment. No default. - - Returns: - Nothing. - """ - alignment = alignment.lower() - - # Set horizontal alignment properties. - if alignment == 'left': - self.set_text_h_align(1) - if alignment == 'centre': - self.set_text_h_align(2) - if alignment == 'center': - self.set_text_h_align(2) - if alignment == 'right': - self.set_text_h_align(3) - if alignment == 'fill': - self.set_text_h_align(4) - if alignment == 'justify': - self.set_text_h_align(5) - if alignment == 'center_across': - self.set_text_h_align(6) - if alignment == 'centre_across': - self.set_text_h_align(6) - if alignment == 'distributed': - self.set_text_h_align(7) - if alignment == 'justify_distributed': - self.set_text_h_align(7) - - if alignment == 'justify_distributed': - self.just_distrib = 1 - - # Set vertical alignment properties. - if alignment == 'top': - self.set_text_v_align(1) - if alignment == 'vcentre': - self.set_text_v_align(2) - if alignment == 'vcenter': - self.set_text_v_align(2) - if alignment == 'bottom': - self.set_text_v_align(3) - if alignment == 'vjustify': - self.set_text_v_align(4) - if alignment == 'vdistributed': - self.set_text_v_align(5) - - def set_center_across(self, center_across=1): - """ - Set the Format center_across property. - - Args: - center_across: Default is 1, turns property on. - - Returns: - Nothing. - - """ - self.center_across = center_across - - def set_text_wrap(self, text_wrap=1): - """ - Set the Format text_wrap property. - - Args: - text_wrap: Default is 1, turns property on. - - Returns: - Nothing. - - """ - self.text_wrap = text_wrap - - def set_rotation(self, rotation): - """ - Set the Format rotation property. - - Args: - rotation: Rotation angle. No default. - - Returns: - Nothing. - - """ - rotation = int(rotation) - - # Map user angle to Excel angle. - if rotation == 270: - rotation = 255 - elif -90 <= rotation <= 90: - if rotation < 0: - rotation = -rotation + 90 - else: - raise Exception( - "Rotation rotation outside range: -90 <= angle <= 90") - - self.rotation = rotation - - def set_indent(self, indent=1): - """ - Set the Format indent property. - - Args: - indent: Default is 1, turns property on. - - Returns: - Nothing. - - """ - self.indent = indent - - def set_shrink(self, shrink=1): - """ - Set the Format shrink property. - - Args: - shrink: Default is 1, turns property on. - - Returns: - Nothing. - - """ - self.shrink = shrink - - def set_text_justlast(self, text_justlast=1): - """ - Set the Format text_justlast property. - - Args: - text_justlast: Default is 1, turns property on. - - Returns: - Nothing. - - """ - self.text_justlast = text_justlast - - def set_pattern(self, pattern=1): - """ - Set the Format pattern property. - - Args: - pattern: Default is 1, solid fill. - - Returns: - Nothing. - - """ - self.pattern = pattern - - def set_bg_color(self, bg_color): - """ - Set the Format bg_color property. - - Args: - bg_color: Background color. No default. - - Returns: - Nothing. - - """ - self.bg_color = self._get_color(bg_color) - - def set_fg_color(self, fg_color): - """ - Set the Format fg_color property. - - Args: - fg_color: Foreground color. No default. - - Returns: - Nothing. - - """ - self.fg_color = self._get_color(fg_color) - - # set_border(style) Set cells borders to the same style - def set_border(self, style=1): - """ - Set the Format bottom property. - - Args: - bottom: Default is 1, border type 1. - - Returns: - Nothing. - - """ - self.set_bottom(style) - self.set_top(style) - self.set_left(style) - self.set_right(style) - - # set_border_color(color) Set cells border to the same color - def set_border_color(self, color): - """ - Set the Format bottom property. - - Args: - color: Color string. No default. - - Returns: - Nothing. - - """ - self.set_bottom_color(color) - self.set_top_color(color) - self.set_left_color(color) - self.set_right_color(color) - - def set_bottom(self, bottom=1): - """ - Set the Format bottom property. - - Args: - bottom: Default is 1, border type 1. - - Returns: - Nothing. - - """ - self.bottom = bottom - - def set_bottom_color(self, bottom_color): - """ - Set the Format bottom_color property. - - Args: - bottom_color: Color string. No default. - - Returns: - Nothing. - - """ - self.bottom_color = self._get_color(bottom_color) - - def set_diag_type(self, diag_type=1): - """ - Set the Format diag_type property. - - Args: - diag_type: Default is 1, border type 1. - - Returns: - Nothing. - - """ - self.diag_type = diag_type - - def set_left(self, left=1): - """ - Set the Format left property. - - Args: - left: Default is 1, border type 1. - - Returns: - Nothing. - - """ - self.left = left - - def set_left_color(self, left_color): - """ - Set the Format left_color property. - - Args: - left_color: Color string. No default. - - Returns: - Nothing. - - """ - self.left_color = self._get_color(left_color) - - def set_right(self, right=1): - """ - Set the Format right property. - - Args: - right: Default is 1, border type 1. - - Returns: - Nothing. - - """ - self.right = right - - def set_right_color(self, right_color): - """ - Set the Format right_color property. - - Args: - right_color: Color string. No default. - - Returns: - Nothing. - - """ - self.right_color = self._get_color(right_color) - - def set_top(self, top=1): - """ - Set the Format top property. - - Args: - top: Default is 1, border type 1. - - Returns: - Nothing. - - """ - self.top = top - - def set_top_color(self, top_color): - """ - Set the Format top_color property. - - Args: - top_color: Color string. No default. - - Returns: - Nothing. - - """ - self.top_color = self._get_color(top_color) - - def set_diag_color(self, diag_color): - """ - Set the Format diag_color property. - - Args: - diag_color: Color string. No default. - - Returns: - Nothing. - - """ - self.diag_color = self._get_color(diag_color) - - def set_diag_border(self, diag_border=1): - """ - Set the Format diag_border property. - - Args: - diag_border: Default is 1, border type 1. - - Returns: - Nothing. - - """ - self.diag_border = diag_border - - ########################################################################### - # - # Internal Format properties. These aren't documented since they are - # either only used internally or else are unlikely to be set by the user. - # - ########################################################################### - - def set_has_font(self, has_font=1): - # Set the has_font property. - self.has_font = has_font - - def set_has_fill(self, has_fill=1): - # Set the has_fill property. - self.has_fill = has_fill - - def set_font_index(self, font_index): - # Set the font_index property. - self.font_index = font_index - - def set_xf_index(self, xf_index): - # Set the xf_index property. - self.xf_index = xf_index - - def set_dxf_index(self, dxf_index): - # Set the xf_index property. - self.dxf_index = dxf_index - - def set_num_format_index(self, num_format_index): - # Set the num_format_index property. - self.num_format_index = num_format_index - - def set_text_h_align(self, text_h_align): - # Set the text_h_align property. - self.text_h_align = text_h_align - - def set_text_v_align(self, text_v_align): - # Set the text_v_align property. - self.text_v_align = text_v_align - - def set_reading_order(self, reading_order=1): - # Set the reading_order property. - self.reading_order = reading_order - - def set_valign(self, align): - # Set vertical cell alignment. This is required by the constructor - # properties dict to differentiate between the vertical and horizontal - # properties. - self.set_align(align) - - def set_font_family(self, font_family): - # Set the Format font_family property. - self.font_family = font_family - - def set_font_charset(self, font_charset): - # Set the Format font_charset property. - self.font_charset = font_charset - - def set_font_scheme(self, font_scheme): - # Set the Format font_scheme property. - self.font_scheme = font_scheme - - def set_font_condense(self, font_condense): - # Set the Format font_condense property. - self.font_condense = font_condense - - def set_font_extend(self, font_extend): - # Set the Format font_extend property. - self.font_extend = font_extend - - def set_theme(self, theme): - # Set the Format theme property. - self.theme = theme - - def set_hyperlink(self, hyperlink=1): - # Set the properties for the hyperlink style. This doesn't - # currently work. To be fixed when styles are supported. - - self.set_underline(1) - self.set_theme(10) - self.set_align('top') - self.hyperlink = hyperlink - - def set_color_indexed(self, color_index): - # Used in the cell comment format. - self.color_indexed = color_index - - def set_font_only(self, font_only=True): - # Used in the cell comment format. - self.font_only = font_only - - # Compatibility methods. - def set_font(self, font_name): - # For compatibility with Excel::Writer::XLSX. - self.font_name = font_name - - def set_size(self, font_size): - # For compatibility with Excel::Writer::XLSX. - self.font_size = font_size - - def set_color(self, font_color): - # For compatibility with Excel::Writer::XLSX. - self.font_color = self._get_color(font_color) - - ########################################################################### - # - # Private API. - # - ########################################################################### - - def _get_align_properties(self): - # Return properties for an Style xf <alignment> sub-element. - changed = 0 - align = [] - - # Check if any alignment options in the format have been changed. - if (self.text_h_align or self.text_v_align or self.indent - or self.rotation or self.text_wrap or self.shrink - or self.reading_order): - changed = 1 - else: - return changed, align - - # Indent is only allowed for horizontal left, right and distributed. - # If it is defined for any other alignment or no alignment has - # been set then default to left alignment. - if (self.indent - and self.text_h_align != 1 - and self.text_h_align != 3 - and self.text_h_align != 7): - self.text_h_align = 1 - - # Check for properties that are mutually exclusive. - if self.text_wrap: - self.shrink = 0 - if self.text_h_align == 4: - self.shrink = 0 - if self.text_h_align == 5: - self.shrink = 0 - if self.text_h_align == 7: - self.shrink = 0 - if self.text_h_align != 7: - self.just_distrib = 0 - if self.indent: - self.just_distrib = 0 - - continuous = 'centerContinuous' - - if self.text_h_align == 1: - align.append(('horizontal', 'left')) - if self.text_h_align == 2: - align.append(('horizontal', 'center')) - if self.text_h_align == 3: - align.append(('horizontal', 'right')) - if self.text_h_align == 4: - align.append(('horizontal', 'fill')) - if self.text_h_align == 5: - align.append(('horizontal', 'justify')) - if self.text_h_align == 6: - align.append(('horizontal', continuous)) - if self.text_h_align == 7: - align.append(('horizontal', 'distributed')) - - if self.just_distrib: - align.append(('justifyLastLine', 1)) - - # Property 'vertical' => 'bottom' is a default. It sets applyAlignment - # without an alignment sub-element. - if self.text_v_align == 1: - align.append(('vertical', 'top')) - if self.text_v_align == 2: - align.append(('vertical', 'center')) - if self.text_v_align == 4: - align.append(('vertical', 'justify')) - if self.text_v_align == 5: - align.append(('vertical', 'distributed')) - - if self.indent: - align.append(('indent', self.indent)) - if self.rotation: - align.append(('textRotation', self.rotation)) - - if self.text_wrap: - align.append(('wrapText', 1)) - if self.shrink: - align.append(('shrinkToFit', 1)) - - if self.reading_order == 1: - align.append(('readingOrder', 1)) - if self.reading_order == 2: - align.append(('readingOrder', 2)) - - return changed, align - - def _get_protection_properties(self): - # Return properties for an Excel XML <Protection> element. - attribs = [] - - if not self.locked: - attribs.append(('locked', 0)) - if self.hidden: - attribs.append(('hidden', 1)) - - return attribs - - def _get_format_key(self): - # Returns a unique hash key for a font. Used by Workbook. - key = ':'.join(self._to_string(x) for x in ( - self._get_font_key(), - self._get_border_key(), - self._get_fill_key(), - self._get_alignment_key(), - self.num_format, - self.locked, - self.hidden)) - - return key - - def _get_font_key(self): - # Returns a unique hash key for a font. Used by Workbook. - key = ':'.join(self._to_string(x) for x in ( - self.bold, - self.font_color, - self.font_charset, - self.font_family, - self.font_outline, - self.font_script, - self.font_shadow, - self.font_strikeout, - self.font_name, - self.italic, - self.font_size, - self.underline)) - - return key - - def _get_border_key(self): - # Returns a unique hash key for a border style. Used by Workbook. - key = ':'.join(self._to_string(x) for x in ( - self.bottom, - self.bottom_color, - self.diag_border, - self.diag_color, - self.diag_type, - self.left, - self.left_color, - self.right, - self.right_color, - self.top, - self.top_color)) - - return key - - def _get_fill_key(self): - # Returns a unique hash key for a fill style. Used by Workbook. - key = ':'.join(self._to_string(x) for x in ( - self.pattern, - self.bg_color, - self.fg_color)) - - return key - - def _get_alignment_key(self): - # Returns a unique hash key for alignment formats. - - key = ':'.join(self._to_string(x) for x in ( - self.text_h_align, - self.text_v_align, - self.indent, - self.rotation, - self.text_wrap, - self.shrink, - self.reading_order)) - - return key - - def _get_xf_index(self): - # Returns the XF index number used by Excel to identify a format. - if self.xf_index is not None: - # Format already has an index number so return it. - return self.xf_index - else: - # Format doesn't have an index number so assign one. - key = self._get_format_key() - - if key in self.xf_format_indices: - # Format matches existing format with an index. - return self.xf_format_indices[key] - else: - # New format requiring an index. Note. +1 since Excel - # has an implicit "General" format at index 0. - index = 1 + len(self.xf_format_indices) - self.xf_format_indices[key] = index - self.xf_index = index - return index - - def _get_dxf_index(self): - # Returns the DXF index number used by Excel to identify a format. - if self.dxf_index is not None: - # Format already has an index number so return it. - return self.dxf_index - else: - # Format doesn't have an index number so assign one. - key = self._get_format_key() - - if key in self.dxf_format_indices: - # Format matches existing format with an index. - return self.dxf_format_indices[key] - else: - # New format requiring an index. - index = len(self.dxf_format_indices) - self.dxf_format_indices[key] = index - self.dxf_index = index - return index - - def _get_color(self, color): - # Used in conjunction with the set_xxx_color methods to convert a - # color name into an RGB formatted string. These colors are for - # backward compatibility with older versions of Excel. - named_colors = { - 'black': '#000000', - 'blue': '#0000FF', - 'brown': '#800000', - 'cyan': '#00FFFF', - 'gray': '#808080', - 'green': '#008000', - 'lime': '#00FF00', - 'magenta': '#FF00FF', - 'navy': '#000080', - 'orange': '#FF6600', - 'pink': '#FF00FF', - 'purple': '#800080', - 'red': '#FF0000', - 'silver': '#C0C0C0', - 'white': '#FFFFFF', - 'yellow': '#FFFF00', - } - - if color in named_colors: - color = named_colors[color] - - return color - - def _to_string(self, value): - # Convert number to a string but allow for utf-8 strings in Python 2. - try: - return str(value) - except UnicodeEncodeError: - return value.encode('utf-8') - - ########################################################################### - # - # XML methods. - # - ###########################################################################
Binary file test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/format.pyc has changed
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/packager.py Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,636 +0,0 @@ -############################################################################### -# -# Packager - A class for writing the Excel XLSX Worksheet file. -# -# Copyright 2013-2016, John McNamara, jmcnamara@cpan.org -# - -# Standard packages. -import os -import sys -import tempfile -from shutil import copy - -from .compatibility import StringIO -from .compatibility import BytesIO - -# Package imports. -from xlsxwriter.app import App -from xlsxwriter.contenttypes import ContentTypes -from xlsxwriter.core import Core -from xlsxwriter.relationships import Relationships -from xlsxwriter.sharedstrings import SharedStrings -from xlsxwriter.styles import Styles -from xlsxwriter.theme import Theme -from xlsxwriter.vml import Vml -from xlsxwriter.table import Table -from xlsxwriter.comments import Comments - - -class Packager(object): - """ - A class for writing the Excel XLSX Packager file. - - This module is used in conjunction with XlsxWriter to create an - Excel XLSX container file. - - From Wikipedia: The Open Packaging Conventions (OPC) is a - container-file technology initially created by Microsoft to store - a combination of XML and non-XML files that together form a single - entity such as an Open XML Paper Specification (OpenXPS) - document. http://en.wikipedia.org/wiki/Open_Packaging_Conventions. - - At its simplest an Excel XLSX file contains the following elements:: - - ____ [Content_Types].xml - | - |____ docProps - | |____ app.xml - | |____ core.xml - | - |____ xl - | |____ workbook.xml - | |____ worksheets - | | |____ sheet1.xml - | | - | |____ styles.xml - | | - | |____ theme - | | |____ theme1.xml - | | - | |_____rels - | |____ workbook.xml.rels - | - |_____rels - |____ .rels - - The Packager class coordinates the classes that represent the - elements of the package and writes them into the XLSX file. - - """ - - ########################################################################### - # - # Public API. - # - ########################################################################### - - def __init__(self): - """ - Constructor. - - """ - - super(Packager, self).__init__() - - self.tmpdir = '' - self.in_memory = False - self.workbook = None - self.sheet_names = [] - self.worksheet_count = 0 - self.chartsheet_count = 0 - self.chart_count = 0 - self.drawing_count = 0 - self.table_count = 0 - self.num_vml_files = 0 - self.num_comment_files = 0 - self.named_ranges = [] - self.filenames = [] - - ########################################################################### - # - # Private API. - # - ########################################################################### - - def _set_tmpdir(self, tmpdir): - # Set an optional user defined temp directory. - self.tmpdir = tmpdir - - def _set_in_memory(self, in_memory): - # Set the optional 'in_memory' mode. - self.in_memory = in_memory - - def _add_workbook(self, workbook): - # Add the Excel::Writer::XLSX::Workbook object to the package. - self.workbook = workbook - self.sheet_names = workbook.sheetnames - self.chart_count = len(workbook.charts) - self.drawing_count = len(workbook.drawings) - self.num_vml_files = workbook.num_vml_files - self.num_comment_files = workbook.num_comment_files - self.named_ranges = workbook.named_ranges - - for worksheet in self.workbook.worksheets(): - if worksheet.is_chartsheet: - self.chartsheet_count += 1 - else: - self.worksheet_count += 1 - - def _create_package(self): - # Write the xml files that make up the XLSX OPC package. - self._write_worksheet_files() - self._write_chartsheet_files() - self._write_workbook_file() - self._write_chart_files() - self._write_drawing_files() - self._write_vml_files() - self._write_comment_files() - self._write_table_files() - self._write_shared_strings_file() - self._write_app_file() - self._write_core_file() - self._write_content_types_file() - self._write_styles_file() - self._write_theme_file() - self._write_root_rels_file() - self._write_workbook_rels_file() - self._write_worksheet_rels_files() - self._write_chartsheet_rels_files() - self._write_drawing_rels_files() - self._add_image_files() - self._add_vba_project() - - return self.filenames - - def _filename(self, xml_filename): - # Create a temp filename to write the XML data to and store the Excel - # filename to use as the name in the Zip container. - if self.in_memory: - os_filename = StringIO() - else: - (fd, os_filename) = tempfile.mkstemp(dir=self.tmpdir) - os.close(fd) - - self.filenames.append((os_filename, xml_filename, False)) - - return os_filename - - def _write_workbook_file(self): - # Write the workbook.xml file. - workbook = self.workbook - - workbook._set_xml_writer(self._filename('xl/workbook.xml')) - workbook._assemble_xml_file() - - def _write_worksheet_files(self): - # Write the worksheet files. - index = 1 - for worksheet in self.workbook.worksheets(): - if worksheet.is_chartsheet: - continue - - if worksheet.optimization == 1: - worksheet._opt_reopen() - worksheet._write_single_row() - - worksheet._set_xml_writer(self._filename('xl/worksheets/sheet' - + str(index) + '.xml')) - worksheet._assemble_xml_file() - index += 1 - - def _write_chartsheet_files(self): - # Write the chartsheet files. - index = 1 - for worksheet in self.workbook.worksheets(): - if not worksheet.is_chartsheet: - continue - - worksheet._set_xml_writer(self._filename('xl/chartsheets/sheet' - + str(index) + '.xml')) - worksheet._assemble_xml_file() - index += 1 - - def _write_chart_files(self): - # Write the chart files. - if not self.workbook.charts: - return - - index = 1 - for chart in self.workbook.charts: - # Check that the chart has at least one data series. - if not chart.series: - raise Exception("Chart%d must contain at least one " - "data series. See chart.add_series()." - % index) - - chart._set_xml_writer(self._filename('xl/charts/chart' - + str(index) + '.xml')) - chart._assemble_xml_file() - index += 1 - - def _write_drawing_files(self): - # Write the drawing files. - if not self.drawing_count: - return - - index = 1 - for drawing in self.workbook.drawings: - drawing._set_xml_writer(self._filename('xl/drawings/drawing' - + str(index) + '.xml')) - drawing._assemble_xml_file() - index += 1 - - def _write_vml_files(self): - # Write the comment VML files. - index = 1 - for worksheet in self.workbook.worksheets(): - if not worksheet.has_vml and not worksheet.has_header_vml: - continue - if worksheet.has_vml: - vml = Vml() - vml._set_xml_writer(self._filename('xl/drawings/vmlDrawing' - + str(index) + '.vml')) - vml._assemble_xml_file(worksheet.vml_data_id, - worksheet.vml_shape_id, - worksheet.comments_list, - worksheet.buttons_list) - index += 1 - - if worksheet.has_header_vml: - vml = Vml() - - vml._set_xml_writer(self._filename('xl/drawings/vmlDrawing' - + str(index) + '.vml')) - vml._assemble_xml_file(worksheet.vml_header_id, - worksheet.vml_header_id * 1024, - None, - None, - worksheet.header_images_list) - - self._write_vml_drawing_rels_file(worksheet, index) - index += 1 - - def _write_comment_files(self): - # Write the comment files. - index = 1 - for worksheet in self.workbook.worksheets(): - if not worksheet.has_comments: - continue - - comment = Comments() - comment._set_xml_writer(self._filename('xl/comments' - + str(index) + '.xml')) - comment._assemble_xml_file(worksheet.comments_list) - index += 1 - - def _write_shared_strings_file(self): - # Write the sharedStrings.xml file. - sst = SharedStrings() - sst.string_table = self.workbook.str_table - - if not self.workbook.str_table.count: - return - - sst._set_xml_writer(self._filename('xl/sharedStrings.xml')) - sst._assemble_xml_file() - - def _write_app_file(self): - # Write the app.xml file. - properties = self.workbook.doc_properties - app = App() - - # Add the Worksheet heading pairs. - app._add_heading_pair(['Worksheets', self.worksheet_count]) - - # Add the Chartsheet heading pairs. - app._add_heading_pair(['Charts', self.chartsheet_count]) - - # Add the Worksheet parts. - for worksheet in self.workbook.worksheets(): - if worksheet.is_chartsheet: - continue - app._add_part_name(worksheet.name) - - # Add the Chartsheet parts. - for worksheet in self.workbook.worksheets(): - if not worksheet.is_chartsheet: - continue - app._add_part_name(worksheet.name) - - # Add the Named Range heading pairs. - if self.named_ranges: - app._add_heading_pair(['Named Ranges', len(self.named_ranges)]) - - # Add the Named Ranges parts. - for named_range in self.named_ranges: - app._add_part_name(named_range) - - app._set_properties(properties) - - app._set_xml_writer(self._filename('docProps/app.xml')) - app._assemble_xml_file() - - def _write_core_file(self): - # Write the core.xml file. - properties = self.workbook.doc_properties - core = Core() - - core._set_properties(properties) - core._set_xml_writer(self._filename('docProps/core.xml')) - core._assemble_xml_file() - - def _write_content_types_file(self): - # Write the ContentTypes.xml file. - content = ContentTypes() - content._add_image_types(self.workbook.image_types) - - worksheet_index = 1 - chartsheet_index = 1 - for worksheet in self.workbook.worksheets(): - if worksheet.is_chartsheet: - content._add_chartsheet_name('sheet' + str(chartsheet_index)) - chartsheet_index += 1 - else: - content._add_worksheet_name('sheet' + str(worksheet_index)) - worksheet_index += 1 - - for i in range(1, self.chart_count + 1): - content._add_chart_name('chart' + str(i)) - - for i in range(1, self.drawing_count + 1): - content._add_drawing_name('drawing' + str(i)) - - if self.num_vml_files: - content._add_vml_name() - - for i in range(1, self.table_count + 1): - content._add_table_name('table' + str(i)) - - for i in range(1, self.num_comment_files + 1): - content._add_comment_name('comments' + str(i)) - - # Add the sharedString rel if there is string data in the workbook. - if self.workbook.str_table.count: - content._add_shared_strings() - - # Add vbaProject if present. - if self.workbook.vba_project: - content._add_vba_project() - - content._set_xml_writer(self._filename('[Content_Types].xml')) - content._assemble_xml_file() - - def _write_styles_file(self): - # Write the style xml file. - xf_formats = self.workbook.xf_formats - palette = self.workbook.palette - font_count = self.workbook.font_count - num_format_count = self.workbook.num_format_count - border_count = self.workbook.border_count - fill_count = self.workbook.fill_count - custom_colors = self.workbook.custom_colors - dxf_formats = self.workbook.dxf_formats - - styles = Styles() - styles._set_style_properties([ - xf_formats, - palette, - font_count, - num_format_count, - border_count, - fill_count, - custom_colors, - dxf_formats]) - - styles._set_xml_writer(self._filename('xl/styles.xml')) - styles._assemble_xml_file() - - def _write_theme_file(self): - # Write the theme xml file. - theme = Theme() - - theme._set_xml_writer(self._filename('xl/theme/theme1.xml')) - theme._assemble_xml_file() - - def _write_table_files(self): - # Write the table files. - index = 1 - for worksheet in self.workbook.worksheets(): - table_props = worksheet.tables - - if not table_props: - continue - - for table_props in table_props: - table = Table() - table._set_xml_writer(self._filename('xl/tables/table' - + str(index) + '.xml')) - table._set_properties(table_props) - table._assemble_xml_file() - self.table_count += 1 - index += 1 - - def _write_root_rels_file(self): - # Write the _rels/.rels xml file. - rels = Relationships() - - rels._add_document_relationship('/officeDocument', 'xl/workbook.xml') - rels._add_package_relationship('/metadata/core-properties', - 'docProps/core.xml') - rels._add_document_relationship('/extended-properties', - 'docProps/app.xml') - - rels._set_xml_writer(self._filename('_rels/.rels')) - rels._assemble_xml_file() - - def _write_workbook_rels_file(self): - # Write the _rels/.rels xml file. - rels = Relationships() - - worksheet_index = 1 - chartsheet_index = 1 - - for worksheet in self.workbook.worksheets(): - if worksheet.is_chartsheet: - rels._add_document_relationship('/chartsheet', - 'chartsheets/sheet' - + str(chartsheet_index) - + '.xml') - chartsheet_index += 1 - else: - rels._add_document_relationship('/worksheet', - 'worksheets/sheet' - + str(worksheet_index) - + '.xml') - worksheet_index += 1 - - rels._add_document_relationship('/theme', 'theme/theme1.xml') - rels._add_document_relationship('/styles', 'styles.xml') - - # Add the sharedString rel if there is string data in the workbook. - if self.workbook.str_table.count: - rels._add_document_relationship('/sharedStrings', - 'sharedStrings.xml') - - # Add vbaProject if present. - if self.workbook.vba_project: - rels._add_ms_package_relationship('/vbaProject', 'vbaProject.bin') - - rels._set_xml_writer(self._filename('xl/_rels/workbook.xml.rels')) - rels._assemble_xml_file() - - def _write_worksheet_rels_files(self): - # Write data such as hyperlinks or drawings. - index = 0 - for worksheet in self.workbook.worksheets(): - - if worksheet.is_chartsheet: - continue - - index += 1 - - external_links = (worksheet.external_hyper_links + - worksheet.external_drawing_links + - worksheet.external_vml_links + - worksheet.external_table_links + - worksheet.external_comment_links) - - if not external_links: - continue - - # Create the worksheet .rels dirs. - rels = Relationships() - - for link_data in external_links: - rels._add_worksheet_relationship(*link_data) - - # Create .rels file such as /xl/worksheets/_rels/sheet1.xml.rels. - rels._set_xml_writer(self._filename('xl/worksheets/_rels/sheet' - + str(index) + '.xml.rels')) - rels._assemble_xml_file() - - def _write_chartsheet_rels_files(self): - # Write the chartsheet .rels files for links to drawing files. - index = 0 - for worksheet in self.workbook.worksheets(): - - if not worksheet.is_chartsheet: - continue - - index += 1 - - external_links = worksheet.external_drawing_links - - if not external_links: - continue - - # Create the chartsheet .rels xlsx_dir. - rels = Relationships() - - for link_data in external_links: - rels._add_worksheet_relationship(*link_data) - - # Create .rels file such as /xl/chartsheets/_rels/sheet1.xml.rels. - rels._set_xml_writer(self._filename('xl/chartsheets/_rels/sheet' - + str(index) + '.xml.rels')) - rels._assemble_xml_file() - - def _write_drawing_rels_files(self): - # Write the drawing .rels files for worksheets with charts or drawings. - index = 0 - for worksheet in self.workbook.worksheets(): - if not worksheet.drawing_links: - continue - index += 1 - - # Create the drawing .rels xlsx_dir. - rels = Relationships() - - for drawing_data in worksheet.drawing_links: - rels._add_document_relationship(*drawing_data) - - # Create .rels file such as /xl/drawings/_rels/sheet1.xml.rels. - rels._set_xml_writer(self._filename('xl/drawings/_rels/drawing' - + str(index) + '.xml.rels')) - rels._assemble_xml_file() - - def _write_vml_drawing_rels_file(self, worksheet, index): - # Write the vmlDdrawing .rels files for worksheets with images in - # headers or footers. - - # Create the drawing .rels dir. - rels = Relationships() - - for drawing_data in worksheet.vml_drawing_links: - rels._add_document_relationship(*drawing_data) - - # Create .rels file such as /xl/drawings/_rels/vmlDrawing1.vml.rels. - rels._set_xml_writer(self._filename('xl/drawings/_rels/vmlDrawing' - + str(index) - + '.vml.rels')) - rels._assemble_xml_file() - - def _add_image_files(self): - # Write the /xl/media/image?.xml files. - workbook = self.workbook - index = 1 - - for image in workbook.images: - filename = image[0] - ext = '.' + image[1] - image_data = image[2] - - xml_image_name = 'xl/media/image' + str(index) + ext - - if not self.in_memory: - # In file mode we just write or copy the image file. - os_filename = self._filename(xml_image_name) - - if image_data: - # The data is in a byte stream. Write it to the target. - os_file = open(os_filename, mode='wb') - os_file.write(image_data.getvalue()) - os_file.close() - else: - copy(filename, os_filename) - - else: - # For in-memory mode we read the image into a stream. - if image_data: - # The data is already in a byte stream. - os_filename = image_data - else: - image_file = open(filename, mode='rb') - image_data = image_file.read() - os_filename = BytesIO(image_data) - image_file.close() - - self.filenames.append((os_filename, xml_image_name, True)) - - index += 1 - - def _add_vba_project(self): - # Copy in a vbaProject.bin file. - vba_project = self.workbook.vba_project - vba_is_stream = self.workbook.vba_is_stream - - if not vba_project: - return - - xml_vba_name = 'xl/vbaProject.bin' - - if not self.in_memory: - # In file mode we just write or copy the VBA file. - os_filename = self._filename(xml_vba_name) - - if vba_is_stream: - # The data is in a byte stream. Write it to the target. - os_file = open(os_filename, mode='wb') - os_file.write(vba_project.getvalue()) - os_file.close() - else: - copy(vba_project, os_filename) - - else: - # For in-memory mode we read the vba into a stream. - if vba_is_stream: - # The data is already in a byte stream. - os_filename = vba_project - else: - vba_file = open(vba_project, mode='rb') - vba_data = vba_file.read() - os_filename = BytesIO(vba_data) - vba_file.close() - - self.filenames.append((os_filename, xml_vba_name, True))
Binary file test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/packager.pyc has changed
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/relationships.py Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,115 +0,0 @@ -############################################################################### -# -# Relationships - A class for writing the Excel XLSX Worksheet file. -# -# Copyright 2013-2016, John McNamara, jmcnamara@cpan.org -# - -# Package imports. -from . import xmlwriter - -# Long namespace strings used in the class. -schema_root = 'http://schemas.openxmlformats.org' -package_schema = schema_root + '/package/2006/relationships' -document_schema = schema_root + '/officeDocument/2006/relationships' - - -class Relationships(xmlwriter.XMLwriter): - """ - A class for writing the Excel XLSX Relationships file. - - - """ - - ########################################################################### - # - # Public API. - # - ########################################################################### - - def __init__(self): - """ - Constructor. - - """ - - super(Relationships, self).__init__() - - self.relationships = [] - self.id = 1 - - ########################################################################### - # - # Private API. - # - ########################################################################### - - def _assemble_xml_file(self): - # Assemble and write the XML file. - - # Write the XML declaration. - self._xml_declaration() - - self._write_relationships() - - # Close the file. - self._xml_close() - - def _add_document_relationship(self, rel_type, target, target_mode=None): - # Add container relationship to XLSX .rels xml files. - rel_type = document_schema + rel_type - - self.relationships.append((rel_type, target, target_mode)) - - def _add_package_relationship(self, rel_type, target): - # Add container relationship to XLSX .rels xml files. - rel_type = package_schema + rel_type - - self.relationships.append((rel_type, target, None)) - - def _add_ms_package_relationship(self, rel_type, target): - # Add container relationship to XLSX .rels xml files. Uses MS schema. - schema = 'http://schemas.microsoft.com/office/2006/relationships' - rel_type = schema + rel_type - - self.relationships.append((rel_type, target, None)) - - def _add_worksheet_relationship(self, rel_type, target, target_mode=None): - # Add worksheet relationship to sheet.rels xml files. - rel_type = document_schema + rel_type - - self.relationships.append((rel_type, target, target_mode)) - - ########################################################################### - # - # XML methods. - # - ########################################################################### - - def _write_relationships(self): - # Write the <Relationships> element. - attributes = [('xmlns', package_schema,)] - - self._xml_start_tag('Relationships', attributes) - - for relationship in self.relationships: - self._write_relationship(relationship) - - self._xml_end_tag('Relationships') - - def _write_relationship(self, relationship): - # Write the <Relationship> element. - rel_type, target, target_mode = relationship - - attributes = [ - ('Id', 'rId' + str(self.id)), - ('Type', rel_type), - ('Target', target), - ] - - self.id += 1 - - if target_mode: - attributes.append(('TargetMode', target_mode)) - - self._xml_empty_tag('Relationship', attributes)
Binary file test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/relationships.pyc has changed
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/shape.py Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,413 +0,0 @@ -############################################################################### -# -# Shape - A class for to represent Excel XLSX shape objects. -# -# Copyright 2013-2016, John McNamara, jmcnamara@cpan.org -# -import copy -from warnings import warn - - -class Shape(object): - """ - A class for to represent Excel XLSX shape objects. - - - """ - - ########################################################################### - # - # Public API. - # - ########################################################################### - - def __init__(self, shape_type, name, options): - """ - Constructor. - - """ - super(Shape, self).__init__() - self.name = name - self.shape_type = shape_type - self.connect = 0 - self.drawing = 0 - self.edit_as = '' - self.id = 0 - self.text = '' - self.stencil = 1 - self.element = -1 - self.start = None - self.start_index = None - self.end = None - self.end_index = None - self.adjustments = [] - self.start_side = '' - self.end_side = '' - self.flip_h = 0 - self.flip_v = 0 - self.rotation = 0 - self.textbox = False - - self.align = None - self.fill = None - self.font = None - self.format = None - self.line = None - - self._set_options(options) - - ########################################################################### - # - # Private API. - # - ########################################################################### - - def _set_options(self, options): - - self.align = self._get_align_properties(options.get('align')) - self.fill = self._get_fill_properties(options.get('fill')) - self.font = self._get_font_properties(options.get('font')) - self.gradient = self._get_gradient_properties(options.get('gradient')) - self.line = self._get_line_properties(options.get('line')) - - if options.get('border'): - self.line = self._get_line_properties(options['border']) - - # Gradient fill overrides solid fill. - if self.gradient: - self.fill = None - - ########################################################################### - # - # Static methods for processing chart/shape style properties. - # - ########################################################################### - - @staticmethod - def _get_line_properties(line): - # Convert user line properties to the structure required internally. - - if not line: - return {'defined': False} - - # Copy the user defined properties since they will be modified. - line = copy.deepcopy(line) - - dash_types = { - 'solid': 'solid', - 'round_dot': 'sysDot', - 'square_dot': 'sysDash', - 'dash': 'dash', - 'dash_dot': 'dashDot', - 'long_dash': 'lgDash', - 'long_dash_dot': 'lgDashDot', - 'long_dash_dot_dot': 'lgDashDotDot', - 'dot': 'dot', - 'system_dash_dot': 'sysDashDot', - 'system_dash_dot_dot': 'sysDashDotDot', - } - - # Check the dash type. - dash_type = line.get('dash_type') - - if dash_type is not None: - if dash_type in dash_types: - line['dash_type'] = dash_types[dash_type] - else: - warn("Unknown dash type '%s'" % dash_type) - return - - line['defined'] = True - - return line - - @staticmethod - def _get_fill_properties(fill): - # Convert user fill properties to the structure required internally. - - if not fill: - return {'defined': False} - - # Copy the user defined properties since they will be modified. - fill = copy.deepcopy(fill) - - fill['defined'] = True - - return fill - - @staticmethod - def _get_pattern_properties(pattern): - # Convert user defined pattern to the structure required internally. - - if not pattern: - return - - # Copy the user defined properties since they will be modified. - pattern = copy.deepcopy(pattern) - - if not pattern.get('pattern'): - warn("Pattern must include 'pattern'") - return - - if not pattern.get('fg_color'): - warn("Pattern must include 'fg_color'") - return - - types = { - 'percent_5': 'pct5', - 'percent_10': 'pct10', - 'percent_20': 'pct20', - 'percent_25': 'pct25', - 'percent_30': 'pct30', - 'percent_40': 'pct40', - 'percent_50': 'pct50', - 'percent_60': 'pct60', - 'percent_70': 'pct70', - 'percent_75': 'pct75', - 'percent_80': 'pct80', - 'percent_90': 'pct90', - 'light_downward_diagonal': 'ltDnDiag', - 'light_upward_diagonal': 'ltUpDiag', - 'dark_downward_diagonal': 'dkDnDiag', - 'dark_upward_diagonal': 'dkUpDiag', - 'wide_downward_diagonal': 'wdDnDiag', - 'wide_upward_diagonal': 'wdUpDiag', - 'light_vertical': 'ltVert', - 'light_horizontal': 'ltHorz', - 'narrow_vertical': 'narVert', - 'narrow_horizontal': 'narHorz', - 'dark_vertical': 'dkVert', - 'dark_horizontal': 'dkHorz', - 'dashed_downward_diagonal': 'dashDnDiag', - 'dashed_upward_diagonal': 'dashUpDiag', - 'dashed_horizontal': 'dashHorz', - 'dashed_vertical': 'dashVert', - 'small_confetti': 'smConfetti', - 'large_confetti': 'lgConfetti', - 'zigzag': 'zigZag', - 'wave': 'wave', - 'diagonal_brick': 'diagBrick', - 'horizontal_brick': 'horzBrick', - 'weave': 'weave', - 'plaid': 'plaid', - 'divot': 'divot', - 'dotted_grid': 'dotGrid', - 'dotted_diamond': 'dotDmnd', - 'shingle': 'shingle', - 'trellis': 'trellis', - 'sphere': 'sphere', - 'small_grid': 'smGrid', - 'large_grid': 'lgGrid', - 'small_check': 'smCheck', - 'large_check': 'lgCheck', - 'outlined_diamond': 'openDmnd', - 'solid_diamond': 'solidDmnd', - } - - # Check for valid types. - if not pattern['pattern'] in types: - warn("unknown pattern type '%s'" % pattern['pattern']) - return - else: - pattern['pattern'] = types[pattern['pattern']] - - # Specify a default background color. - pattern['bg_color'] = pattern.get('bg_color', '#FFFFFF') - - return pattern - - @staticmethod - def _get_gradient_properties(gradient): - # Convert user defined gradient to the structure required internally. - - if not gradient: - return - - # Copy the user defined properties since they will be modified. - gradient = copy.deepcopy(gradient) - - types = { - 'linear': 'linear', - 'radial': 'circle', - 'rectangular': 'rect', - 'path': 'shape' - } - - # Check the colors array exists and is valid. - if 'colors' not in gradient or type(gradient['colors']) != list: - warn("Gradient must include colors list") - return - - # Check the colors array has the required number of entries. - if not 2 <= len(gradient['colors']) <= 10: - warn("Gradient colors list must at least 2 values " - "and not more than 10") - return - - if 'positions' in gradient: - # Check the positions array has the right number of entries. - if len(gradient['positions']) != len(gradient['colors']): - warn("Gradient positions not equal to number of colors") - return - - # Check the positions are in the correct range. - for pos in gradient['positions']: - if not 0 <= pos <= 100: - warn("Gradient position must be in the range " - "0 <= position <= 100") - return - else: - # Use the default gradient positions. - if len(gradient['colors']) == 2: - gradient['positions'] = [0, 100] - - elif len(gradient['colors']) == 3: - gradient['positions'] = [0, 50, 100] - - elif len(gradient['colors']) == 4: - gradient['positions'] = [0, 33, 66, 100] - - else: - warn("Must specify gradient positions") - return - - angle = gradient.get('angle') - if angle: - if not 0 <= angle < 360: - warn("Gradient angle must be in the range " - "0 <= angle < 360") - return - else: - gradient['angle'] = 90 - - # Check for valid types. - gradient_type = gradient.get('type') - - if gradient_type is not None: - - if gradient_type in types: - gradient['type'] = types[gradient_type] - else: - warn("Unknown gradient type '%s" % gradient_type) - return - else: - gradient['type'] = 'linear' - - return gradient - - @staticmethod - def _get_font_properties(options): - # Convert user defined font values into private dict values. - if options is None: - options = {} - - font = { - 'name': options.get('name'), - 'color': options.get('color'), - 'size': options.get('size', 11), - 'bold': options.get('bold'), - 'italic': options.get('italic'), - 'underline': options.get('underline'), - 'pitch_family': options.get('pitch_family'), - 'charset': options.get('charset'), - 'baseline': options.get('baseline', -1), - 'rotation': options.get('rotation'), - 'lang': options.get('lang', 'en-US'), - } - - # Convert font size units. - if font['size']: - font['size'] = int(font['size'] * 100) - - # Convert rotation into 60,000ths of a degree. - if font['rotation']: - font['rotation'] = 60000 * int(font['rotation']) - - return font - - @staticmethod - def _get_font_style_attributes(font): - # _get_font_style_attributes. - attributes = [] - - if not font: - return attributes - - if font.get('size'): - attributes.append(('sz', font['size'])) - - if font.get('bold') is not None: - attributes.append(('b', 0 + font['bold'])) - - if font.get('italic') is not None: - attributes.append(('i', 0 + font['italic'])) - - if font.get('underline') is not None: - attributes.append(('u', 'sng')) - - if font.get('baseline') != -1: - attributes.append(('baseline', font['baseline'])) - - return attributes - - @staticmethod - def _get_font_latin_attributes(font): - # _get_font_latin_attributes. - attributes = [] - - if not font: - return attributes - - if font['name'] is not None: - attributes.append(('typeface', font['name'])) - - if font['pitch_family'] is not None: - attributes.append(('pitchFamily', font['pitch_family'])) - - if font['charset'] is not None: - attributes.append(('charset', font['charset'])) - - return attributes - - @staticmethod - def _get_align_properties(align): - # Convert user defined align to the structure required internally. - if not align: - return {'defined': False} - - # Copy the user defined properties since they will be modified. - align = copy.deepcopy(align) - - if 'vertical' in align: - align_type = align['vertical'] - - align_types = { - 'top': 'top', - 'middle': 'middle', - 'bottom': 'bottom', - } - - if align_type in align_types: - align['vertical'] = align_types[align_type] - else: - warn("Unknown alignment type '%s'" % align_type) - return {'defined': False} - - if 'horizontal' in align: - align_type = align['horizontal'] - - align_types = { - 'left': 'left', - 'center': 'center', - 'right': 'right', - } - - if align_type in align_types: - align['horizontal'] = align_types[align_type] - else: - warn("Unknown alignment type '%s'" % align_type) - return {'defined': False} - - align['defined'] = True - - return align
Binary file test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/shape.pyc has changed
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/sharedstrings.py Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,153 +0,0 @@ -############################################################################### -# -# SharedStrings - A class for writing the Excel XLSX sharedStrings file. -# -# Copyright 2013-2016, John McNamara, jmcnamara@cpan.org -# - -# Standard packages. -import re - -# Package imports. -from . import xmlwriter - - -class SharedStrings(xmlwriter.XMLwriter): - """ - A class for writing the Excel XLSX sharedStrings file. - - """ - - ########################################################################### - # - # Public API. - # - ########################################################################### - - def __init__(self): - """ - Constructor. - - """ - - super(SharedStrings, self).__init__() - - self.string_table = None - - ########################################################################### - # - # Private API. - # - ########################################################################### - - def _assemble_xml_file(self): - # Assemble and write the XML file. - - # Write the XML declaration. - self._xml_declaration() - - # Write the sst element. - self._write_sst() - - # Write the sst strings. - self._write_sst_strings() - - # Close the sst tag. - self._xml_end_tag('sst') - - # Close the file. - self._xml_close() - - ########################################################################### - # - # XML methods. - # - ########################################################################### - - def _write_sst(self): - # Write the <sst> element. - xmlns = 'http://schemas.openxmlformats.org/spreadsheetml/2006/main' - - attributes = [ - ('xmlns', xmlns), - ('count', self.string_table.count), - ('uniqueCount', self.string_table.unique_count), - ] - - self._xml_start_tag('sst', attributes) - - def _write_sst_strings(self): - # Write the sst string elements. - - for string in (self.string_table._get_strings()): - self._write_si(string) - - def _write_si(self, string): - # Write the <si> element. - attributes = [] - - # Excel escapes control characters with _xHHHH_ and also escapes any - # literal strings of that type by encoding the leading underscore. - # So "\0" -> _x0000_ and "_x0000_" -> _x005F_x0000_. - # The following substitutions deal with those cases. - - # Escape the escape. - string = re.sub('(_x[0-9a-fA-F]{4}_)', r'_x005F\1', string) - - # Convert control character to the _xHHHH_ escape. - string = re.sub(r'([\x00-\x08\x0B-\x1F])', - lambda match: "_x%04X_" % - ord(match.group(1)), string) - - # Add attribute to preserve leading or trailing whitespace. - if re.search('^\s', string) or re.search('\s$', string): - attributes.append(('xml:space', 'preserve')) - - # Write any rich strings without further tags. - if re.search('^<r>', string) and re.search('</r>$', string): - self._xml_rich_si_element(string) - else: - self._xml_si_element(string, attributes) - - -# A metadata class to store Excel strings between worksheets. -class SharedStringTable(object): - """ - A class to track Excel shared strings between worksheets. - - """ - - def __init__(self): - self.count = 0 - self.unique_count = 0 - self.string_table = {} - self.string_array = [] - - def _get_shared_string_index(self, string): - """" Get the index of the string in the Shared String table. """ - if string not in self.string_table: - # String isn't already stored in the table so add it. - index = self.unique_count - self.string_table[string] = index - self.count += 1 - self.unique_count += 1 - return index - else: - # String exists in the table. - index = self.string_table[string] - self.count += 1 - return index - - def _get_shared_string(self, index): - """" Get a shared string from the index. """ - return self.string_array[index] - - def _sort_string_data(self): - """" Sort the shared string data and convert from dict to list. """ - self.string_array = sorted(self.string_table, - key=self.string_table.__getitem__) - self.string_table = {} - - def _get_strings(self): - """" Return the sorted string list. """ - return self.string_array
Binary file test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/sharedstrings.pyc has changed
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/styles.py Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,700 +0,0 @@ -############################################################################### -# -# Styles - A class for writing the Excel XLSX Worksheet file. -# -# Copyright 2013-2016, John McNamara, jmcnamara@cpan.org -# - -# Package imports. -from . import xmlwriter - - -class Styles(xmlwriter.XMLwriter): - """ - A class for writing the Excel XLSX Styles file. - - - """ - - ########################################################################### - # - # Public API. - # - ########################################################################### - - def __init__(self): - """ - Constructor. - - """ - - super(Styles, self).__init__() - - self.xf_formats = [] - self.palette = [] - self.font_count = 0 - self.num_format_count = 0 - self.border_count = 0 - self.fill_count = 0 - self.custom_colors = [] - self.dxf_formats = [] - - ########################################################################### - # - # Private API. - # - ########################################################################### - - def _assemble_xml_file(self): - # Assemble and write the XML file. - - # Write the XML declaration. - self._xml_declaration() - - # Add the style sheet. - self._write_style_sheet() - - # Write the number formats. - self._write_num_fmts() - - # Write the fonts. - self._write_fonts() - - # Write the fills. - self._write_fills() - - # Write the borders element. - self._write_borders() - - # Write the cellStyleXfs element. - self._write_cell_style_xfs() - - # Write the cellXfs element. - self._write_cell_xfs() - - # Write the cellStyles element. - self._write_cell_styles() - - # Write the dxfs element. - self._write_dxfs() - - # Write the tableStyles element. - self._write_table_styles() - - # Write the colors element. - self._write_colors() - - # Close the style sheet tag. - self._xml_end_tag('styleSheet') - - # Close the file. - self._xml_close() - - def _set_style_properties(self, properties): - # Pass in the Format objects and other properties used in the styles. - - self.xf_formats = properties[0] - self.palette = properties[1] - self.font_count = properties[2] - self.num_format_count = properties[3] - self.border_count = properties[4] - self.fill_count = properties[5] - self.custom_colors = properties[6] - self.dxf_formats = properties[7] - - def _get_palette_color(self, color): - # Convert the RGB color. - if color[0] == '#': - color = color[1:] - - return "FF" + color.upper() - - ########################################################################### - # - # XML methods. - # - ########################################################################### - - def _write_style_sheet(self): - # Write the <styleSheet> element. - xmlns = 'http://schemas.openxmlformats.org/spreadsheetml/2006/main' - - attributes = [('xmlns', xmlns)] - self._xml_start_tag('styleSheet', attributes) - - def _write_num_fmts(self): - # Write the <numFmts> element. - if not self.num_format_count: - return - - attributes = [('count', self.num_format_count)] - self._xml_start_tag('numFmts', attributes) - - # Write the numFmts elements. - for xf_format in self.xf_formats: - # Ignore built-in number formats, i.e., < 164. - if xf_format.num_format_index >= 164: - self._write_num_fmt(xf_format.num_format_index, - xf_format.num_format) - - self._xml_end_tag('numFmts') - - def _write_num_fmt(self, num_fmt_id, format_code): - # Write the <numFmt> element. - format_codes = { - 0: 'General', - 1: '0', - 2: '0.00', - 3: '#,##0', - 4: '#,##0.00', - 5: '($#,##0_);($#,##0)', - 6: '($#,##0_);[Red]($#,##0)', - 7: '($#,##0.00_);($#,##0.00)', - 8: '($#,##0.00_);[Red]($#,##0.00)', - 9: '0%', - 10: '0.00%', - 11: '0.00E+00', - 12: '# ?/?', - 13: '# ??/??', - 14: 'm/d/yy', - 15: 'd-mmm-yy', - 16: 'd-mmm', - 17: 'mmm-yy', - 18: 'h:mm AM/PM', - 19: 'h:mm:ss AM/PM', - 20: 'h:mm', - 21: 'h:mm:ss', - 22: 'm/d/yy h:mm', - 37: '(#,##0_);(#,##0)', - 38: '(#,##0_);[Red](#,##0)', - 39: '(#,##0.00_);(#,##0.00)', - 40: '(#,##0.00_);[Red](#,##0.00)', - 41: '_(* #,##0_);_(* (#,##0);_(* "-"_);_(_)', - 42: '_($* #,##0_);_($* (#,##0);_($* "-"_);_(_)', - 43: '_(* #,##0.00_);_(* (#,##0.00);_(* "-"??_);_(_)', - 44: '_($* #,##0.00_);_($* (#,##0.00);_($* "-"??_);_(_)', - 45: 'mm:ss', - 46: '[h]:mm:ss', - 47: 'mm:ss.0', - 48: '##0.0E+0', - 49: '@'} - - # Set the format code for built-in number formats. - if num_fmt_id < 164: - if num_fmt_id in format_codes: - format_code = format_codes[num_fmt_id] - else: - format_code = 'General' - - attributes = [ - ('numFmtId', num_fmt_id), - ('formatCode', format_code), - ] - - self._xml_empty_tag('numFmt', attributes) - - def _write_fonts(self): - # Write the <fonts> element. - attributes = [('count', self.font_count)] - self._xml_start_tag('fonts', attributes) - - # Write the font elements for xf_format objects that have them. - for xf_format in self.xf_formats: - if xf_format.has_font: - self._write_font(xf_format) - - self._xml_end_tag('fonts') - - def _write_font(self, xf_format, is_dxf_format=False): - # Write the <font> element. - self._xml_start_tag('font') - - # The condense and extend elements are mainly used in dxf formats. - if xf_format.font_condense: - self._write_condense() - - if xf_format.font_extend: - self._write_extend() - - if xf_format.bold: - self._xml_empty_tag('b') - - if xf_format.italic: - self._xml_empty_tag('i') - - if xf_format.font_strikeout: - self._xml_empty_tag('strike') - - if xf_format.font_outline: - self._xml_empty_tag('outline') - - if xf_format.font_shadow: - self._xml_empty_tag('shadow') - - # Handle the underline variants. - if xf_format.underline: - self._write_underline(xf_format.underline) - - if xf_format.font_script == 1: - self._write_vert_align('superscript') - - if xf_format.font_script == 2: - self._write_vert_align('subscript') - - if not is_dxf_format: - self._xml_empty_tag('sz', [('val', xf_format.font_size)]) - - if xf_format.theme == -1: - # Ignore for excel2003_style. - pass - elif xf_format.theme: - self._write_color('theme', xf_format.theme) - elif xf_format.color_indexed: - self._write_color('indexed', xf_format.color_indexed) - elif xf_format.font_color: - color = self._get_palette_color(xf_format.font_color) - self._write_color('rgb', color) - elif not is_dxf_format: - self._write_color('theme', 1) - - if not is_dxf_format: - self._xml_empty_tag('name', [('val', xf_format.font_name)]) - - if xf_format.font_family: - self._xml_empty_tag('family', [('val', xf_format.font_family)]) - - if xf_format.font_charset: - self._xml_empty_tag('charset', - [('val', xf_format.font_charset)]) - - if xf_format.font_name == 'Calibri' and not xf_format.hyperlink: - self._xml_empty_tag( - 'scheme', - [('val', xf_format.font_scheme)]) - - self._xml_end_tag('font') - - def _write_underline(self, underline): - # Write the underline font element. - - if underline == 2: - attributes = [('val', 'double')] - elif underline == 33: - attributes = [('val', 'singleAccounting')] - elif underline == 34: - attributes = [('val', 'doubleAccounting')] - else: - # Default to single underline. - attributes = [] - - self._xml_empty_tag('u', attributes) - - def _write_vert_align(self, val): - # Write the <vertAlign> font sub-element. - attributes = [('val', val)] - - self._xml_empty_tag('vertAlign', attributes) - - def _write_color(self, name, value): - # Write the <color> element. - attributes = [(name, value)] - - self._xml_empty_tag('color', attributes) - - def _write_fills(self): - # Write the <fills> element. - attributes = [('count', self.fill_count)] - - self._xml_start_tag('fills', attributes) - - # Write the default fill element. - self._write_default_fill('none') - self._write_default_fill('gray125') - - # Write the fill elements for xf_format objects that have them. - for xf_format in self.xf_formats: - if xf_format.has_fill: - self._write_fill(xf_format) - - self._xml_end_tag('fills') - - def _write_default_fill(self, pattern_type): - # Write the <fill> element for the default fills. - self._xml_start_tag('fill') - self._xml_empty_tag('patternFill', [('patternType', pattern_type)]) - self._xml_end_tag('fill') - - def _write_fill(self, xf_format, is_dxf_format=False): - # Write the <fill> element. - pattern = xf_format.pattern - bg_color = xf_format.bg_color - fg_color = xf_format.fg_color - - # Colors for dxf formats are handled differently from normal formats - # since the normal xf_format reverses the meaning of BG and FG for - # solid fills. - if is_dxf_format: - bg_color = xf_format.dxf_bg_color - fg_color = xf_format.dxf_fg_color - - patterns = ( - 'none', - 'solid', - 'mediumGray', - 'darkGray', - 'lightGray', - 'darkHorizontal', - 'darkVertical', - 'darkDown', - 'darkUp', - 'darkGrid', - 'darkTrellis', - 'lightHorizontal', - 'lightVertical', - 'lightDown', - 'lightUp', - 'lightGrid', - 'lightTrellis', - 'gray125', - 'gray0625', - ) - - self._xml_start_tag('fill') - - # The "none" pattern is handled differently for dxf formats. - if is_dxf_format and pattern <= 1: - self._xml_start_tag('patternFill') - else: - self._xml_start_tag( - 'patternFill', - [('patternType', patterns[pattern])]) - - if fg_color: - fg_color = self._get_palette_color(fg_color) - self._xml_empty_tag('fgColor', [('rgb', fg_color)]) - - if bg_color: - bg_color = self._get_palette_color(bg_color) - self._xml_empty_tag('bgColor', [('rgb', bg_color)]) - else: - if not is_dxf_format: - self._xml_empty_tag('bgColor', [('indexed', 64)]) - - self._xml_end_tag('patternFill') - self._xml_end_tag('fill') - - def _write_borders(self): - # Write the <borders> element. - attributes = [('count', self.border_count)] - - self._xml_start_tag('borders', attributes) - - # Write the border elements for xf_format objects that have them. - for xf_format in self.xf_formats: - if xf_format.has_border: - self._write_border(xf_format) - - self._xml_end_tag('borders') - - def _write_border(self, xf_format, is_dxf_format=False): - # Write the <border> element. - attributes = [] - - # Diagonal borders add attributes to the <border> element. - if xf_format.diag_type == 1: - attributes.append(('diagonalUp', 1)) - elif xf_format.diag_type == 2: - attributes.append(('diagonalDown', 1)) - elif xf_format.diag_type == 3: - attributes.append(('diagonalUp', 1)) - attributes.append(('diagonalDown', 1)) - - # Ensure that a default diag border is set if the diag type is set. - if xf_format.diag_type and not xf_format.diag_border: - xf_format.diag_border = 1 - - # Write the start border tag. - self._xml_start_tag('border', attributes) - - # Write the <border> sub elements. - self._write_sub_border( - 'left', - xf_format.left, - xf_format.left_color) - - self._write_sub_border( - 'right', - xf_format.right, - xf_format.right_color) - - self._write_sub_border( - 'top', - xf_format.top, - xf_format.top_color) - - self._write_sub_border( - 'bottom', - xf_format.bottom, - xf_format.bottom_color) - - # Condition DXF formats don't allow diagonal borders. - if not is_dxf_format: - self._write_sub_border( - 'diagonal', - xf_format.diag_border, - xf_format.diag_color) - - if is_dxf_format: - self._write_sub_border('vertical', None, None) - self._write_sub_border('horizontal', None, None) - - self._xml_end_tag('border') - - def _write_sub_border(self, border_type, style, color): - # Write the <border> sub elements such as <right>, <top>, etc. - attributes = [] - - if not style: - self._xml_empty_tag(border_type) - return - - border_styles = ( - 'none', - 'thin', - 'medium', - 'dashed', - 'dotted', - 'thick', - 'double', - 'hair', - 'mediumDashed', - 'dashDot', - 'mediumDashDot', - 'dashDotDot', - 'mediumDashDotDot', - 'slantDashDot', - ) - - attributes.append(('style', border_styles[style])) - - self._xml_start_tag(border_type, attributes) - - if color: - color = self._get_palette_color(color) - self._xml_empty_tag('color', [('rgb', color)]) - else: - self._xml_empty_tag('color', [('auto', 1)]) - - self._xml_end_tag(border_type) - - def _write_cell_style_xfs(self): - # Write the <cellStyleXfs> element. - attributes = [('count', 1)] - - self._xml_start_tag('cellStyleXfs', attributes) - self._write_style_xf() - self._xml_end_tag('cellStyleXfs') - - def _write_cell_xfs(self): - # Write the <cellXfs> element. - formats = self.xf_formats - - # Workaround for when the last xf_format is used for the comment font - # and shouldn't be used for cellXfs. - last_format = formats[-1] - if last_format.font_only: - formats.pop() - - attributes = [('count', len(formats))] - self._xml_start_tag('cellXfs', attributes) - - # Write the xf elements. - for xf_format in formats: - self._write_xf(xf_format) - - self._xml_end_tag('cellXfs') - - def _write_style_xf(self): - # Write the style <xf> element. - num_fmt_id = 0 - font_id = 0 - fill_id = 0 - border_id = 0 - - attributes = [ - ('numFmtId', num_fmt_id), - ('fontId', font_id), - ('fillId', fill_id), - ('borderId', border_id), - ] - - self._xml_empty_tag('xf', attributes) - - def _write_xf(self, xf_format): - # Write the <xf> element. - num_fmt_id = xf_format.num_format_index - font_id = xf_format.font_index - fill_id = xf_format.fill_index - border_id = xf_format.border_index - xf_id = 0 - has_align = 0 - has_protect = 0 - - attributes = [ - ('numFmtId', num_fmt_id), - ('fontId', font_id), - ('fillId', fill_id), - ('borderId', border_id), - ('xfId', xf_id), - ] - - if xf_format.num_format_index > 0: - attributes.append(('applyNumberFormat', 1)) - - # Add applyFont attribute if XF format uses a font element. - if xf_format.font_index > 0: - attributes.append(('applyFont', 1)) - - # Add applyFill attribute if XF format uses a fill element. - if xf_format.fill_index > 0: - attributes.append(('applyFill', 1)) - - # Add applyBorder attribute if XF format uses a border element. - if xf_format.border_index > 0: - attributes.append(('applyBorder', 1)) - - # Check if XF format has alignment properties set. - (apply_align, align) = xf_format._get_align_properties() - - # Check if an alignment sub-element should be written. - if apply_align and align: - has_align = 1 - - # We can also have applyAlignment without a sub-element. - if apply_align: - attributes.append(('applyAlignment', 1)) - - # Check for cell protection properties. - protection = xf_format._get_protection_properties() - - if protection: - attributes.append(('applyProtection', 1)) - has_protect = 1 - - # Write XF with sub-elements if required. - if has_align or has_protect: - self._xml_start_tag('xf', attributes) - if has_align: - self._xml_empty_tag('alignment', align) - if has_protect: - self._xml_empty_tag('protection', protection) - self._xml_end_tag('xf') - else: - self._xml_empty_tag('xf', attributes) - - def _write_cell_styles(self): - # Write the <cellStyles> element. - attributes = [('count', 1)] - - self._xml_start_tag('cellStyles', attributes) - self._write_cell_style() - self._xml_end_tag('cellStyles') - - def _write_cell_style(self): - # Write the <cellStyle> element. - name = 'Normal' - xf_id = 0 - builtin_id = 0 - - attributes = [ - ('name', name), - ('xfId', xf_id), - ('builtinId', builtin_id), - ] - - self._xml_empty_tag('cellStyle', attributes) - - def _write_dxfs(self): - # Write the <dxfs> element. - formats = self.dxf_formats - count = len(formats) - - attributes = [('count', len(formats))] - - if count: - self._xml_start_tag('dxfs', attributes) - - # Write the font elements for xf_format objects that have them. - for xf_format in self.dxf_formats: - self._xml_start_tag('dxf') - if xf_format.has_dxf_font: - self._write_font(xf_format, True) - - if xf_format.num_format_index: - self._write_num_fmt(xf_format.num_format_index, - xf_format.num_format) - - if xf_format.has_dxf_fill: - self._write_fill(xf_format, True) - if xf_format.has_dxf_border: - self._write_border(xf_format, True) - self._xml_end_tag('dxf') - - self._xml_end_tag('dxfs') - else: - self._xml_empty_tag('dxfs', attributes) - - def _write_table_styles(self): - # Write the <tableStyles> element. - count = 0 - default_table_style = 'TableStyleMedium9' - default_pivot_style = 'PivotStyleLight16' - - attributes = [ - ('count', count), - ('defaultTableStyle', default_table_style), - ('defaultPivotStyle', default_pivot_style), - ] - - self._xml_empty_tag('tableStyles', attributes) - - def _write_colors(self): - # Write the <colors> element. - custom_colors = self.custom_colors - - if not custom_colors: - return - - self._xml_start_tag('colors') - self._write_mru_colors(custom_colors) - self._xml_end_tag('colors') - - def _write_mru_colors(self, custom_colors): - # Write the <mruColors> element for the most recently used colors. - - # Write the custom custom_colors in reverse order. - custom_colors.reverse() - - # Limit the mruColors to the last 10. - if len(custom_colors) > 10: - custom_colors = custom_colors[0:10] - - self._xml_start_tag('mruColors') - - # Write the custom custom_colors in reverse order. - for color in custom_colors: - self._write_color('rgb', color) - - self._xml_end_tag('mruColors') - - def _write_condense(self): - # Write the <condense> element. - attributes = [('val', 0)] - - self._xml_empty_tag('condense', attributes) - - def _write_extend(self): - # Write the <extend> element. - attributes = [('val', 0)] - - self._xml_empty_tag('extend', attributes)
Binary file test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/styles.pyc has changed
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/table.py Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,178 +0,0 @@ -############################################################################### -# -# Table - A class for writing the Excel XLSX Worksheet file. -# -# Copyright 2013-2016, John McNamara, jmcnamara@cpan.org -# - -from . import xmlwriter - - -class Table(xmlwriter.XMLwriter): - """ - A class for writing the Excel XLSX Table file. - - - """ - - ########################################################################### - # - # Public API. - # - ########################################################################### - - def __init__(self): - """ - Constructor. - - """ - - super(Table, self).__init__() - - self.properties = {} - - ########################################################################### - # - # Private API. - # - ########################################################################### - - def _assemble_xml_file(self): - # Assemble and write the XML file. - - # Write the XML declaration. - self._xml_declaration() - - # Write the table element. - self._write_table() - - # Write the autoFilter element. - self._write_auto_filter() - - # Write the tableColumns element. - self._write_table_columns() - - # Write the tableStyleInfo element. - self._write_table_style_info() - - # Close the table tag. - self._xml_end_tag('table') - - # Close the file. - self._xml_close() - - def _set_properties(self, properties): - # Set the document properties. - self.properties = properties - - ########################################################################### - # - # XML methods. - # - ########################################################################### - - def _write_table(self): - # Write the <table> element. - schema = 'http://schemas.openxmlformats.org/' - xmlns = schema + 'spreadsheetml/2006/main' - table_id = self.properties['id'] - name = self.properties['name'] - display_name = self.properties['name'] - ref = self.properties['range'] - totals_row_shown = self.properties['totals_row_shown'] - header_row_count = self.properties['header_row_count'] - - attributes = [ - ('xmlns', xmlns), - ('id', table_id), - ('name', name), - ('displayName', display_name), - ('ref', ref), - ] - - if not header_row_count: - attributes.append(('headerRowCount', 0)) - - if totals_row_shown: - attributes.append(('totalsRowCount', 1)) - else: - attributes.append(('totalsRowShown', 0)) - - self._xml_start_tag('table', attributes) - - def _write_auto_filter(self): - # Write the <autoFilter> element. - autofilter = self.properties.get('autofilter', 0) - - if not autofilter: - return - - attributes = [('ref', autofilter,)] - - self._xml_empty_tag('autoFilter', attributes) - - def _write_table_columns(self): - # Write the <tableColumns> element. - columns = self.properties['columns'] - - count = len(columns) - - attributes = [('count', count)] - - self._xml_start_tag('tableColumns', attributes) - - for col_data in columns: - # Write the tableColumn element. - self._write_table_column(col_data) - - self._xml_end_tag('tableColumns') - - def _write_table_column(self, col_data): - # Write the <tableColumn> element. - attributes = [ - ('id', col_data['id']), - ('name', col_data['name']), - ] - - if col_data.get('total_string'): - attributes.append(('totalsRowLabel', col_data['total_string'])) - elif col_data.get('total_function'): - attributes.append(('totalsRowFunction', - col_data['total_function'])) - - if 'format' in col_data and col_data['format'] is not None: - attributes.append(('dataDxfId', col_data['format'])) - - if col_data.get('formula'): - self._xml_start_tag('tableColumn', attributes) - - # Write the calculatedColumnFormula element. - self._write_calculated_column_formula(col_data['formula']) - - self._xml_end_tag('tableColumn') - else: - self._xml_empty_tag('tableColumn', attributes) - - def _write_table_style_info(self): - # Write the <tableStyleInfo> element. - props = self.properties - - name = props['style'] - show_first_column = 0 + props['show_first_col'] - show_last_column = 0 + props['show_last_col'] - show_row_stripes = 0 + props['show_row_stripes'] - show_column_stripes = 0 + props['show_col_stripes'] - - attributes = [ - ('name', name), - ('showFirstColumn', show_first_column), - ('showLastColumn', show_last_column), - ('showRowStripes', show_row_stripes), - ('showColumnStripes', show_column_stripes), - ] - - self._xml_empty_tag('tableStyleInfo', attributes) - - def _write_calculated_column_formula(self, formula): - # Write the <calculatedColumnFormula> element. - self._xml_data_element('calculatedColumnFormula', formula)
Binary file test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/table.pyc has changed
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/theme.py Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,74 +0,0 @@ -############################################################################### -# -# Theme - A class for writing the Excel XLSX Worksheet file. -# -# Copyright 2013-2016, John McNamara, jmcnamara@cpan.org -# - -# Standard packages. -import codecs -import sys - -# Standard packages in Python 2/3 compatibility mode. -from .compatibility import StringIO - - -class Theme(object): - """ - A class for writing the Excel XLSX Theme file. - - - """ - - ########################################################################### - # - # Public API. - # - ########################################################################### - - def __init__(self): - """ - Constructor. - - """ - super(Theme, self).__init__() - self.fh = None - self.internal_fh = False - - ########################################################################### - # - # Private API. - # - ########################################################################### - - def _assemble_xml_file(self): - # Assemble and write the XML file. - self._write_theme_file() - if self.internal_fh: - self.fh.close() - - def _set_xml_writer(self, filename): - # Set the XML writer filehandle for the object. - if isinstance(filename, StringIO): - self.internal_fh = False - self.fh = filename - else: - self.internal_fh = True - self.fh = codecs.open(filename, 'w', 'utf-8') - - ########################################################################### - # - # XML methods. - # - ########################################################################### - - def _write_theme_file(self): - # Write a default theme.xml file. - - # The theme is encoded to allow Python 2.5/Jython support. - default_theme = """<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="Office Theme"><a:themeElements><a:clrScheme name="Office"><a:dk1><a:sysClr val="windowText" lastClr="000000"/></a:dk1><a:lt1><a:sysClr val="window" lastClr="FFFFFF"/></a:lt1><a:dk2><a:srgbClr val="1F497D"/></a:dk2><a:lt2><a:srgbClr val="EEECE1"/></a:lt2><a:accent1><a:srgbClr val="4F81BD"/></a:accent1><a:accent2><a:srgbClr val="C0504D"/></a:accent2><a:accent3><a:srgbClr val="9BBB59"/></a:accent3><a:accent4><a:srgbClr val="8064A2"/></a:accent4><a:accent5><a:srgbClr val="4BACC6"/></a:accent5><a:accent6><a:srgbClr val="F79646"/></a:accent6><a:hlink><a:srgbClr val="0000FF"/></a:hlink><a:folHlink><a:srgbClr val="800080"/></a:folHlink></a:clrScheme><a:fontScheme name="Office"><a:majorFont><a:latin typeface="Cambria"/><a:ea typeface=""/><a:cs typeface=""/><a:font script="Jpan" typeface="\uff2d\uff33 \uff30\u30b4\u30b7\u30c3\u30af"/><a:font script="Hang" typeface="\ub9d1\uc740 \uace0\ub515"/><a:font script="Hans" typeface="\u5b8b\u4f53"/><a:font script="Hant" typeface="\u65b0\u7d30\u660e\u9ad4"/><a:font script="Arab" typeface="Times New Roman"/><a:font script="Hebr" typeface="Times New Roman"/><a:font script="Thai" typeface="Tahoma"/><a:font script="Ethi" typeface="Nyala"/><a:font script="Beng" typeface="Vrinda"/><a:font script="Gujr" typeface="Shruti"/><a:font script="Khmr" typeface="MoolBoran"/><a:font script="Knda" typeface="Tunga"/><a:font script="Guru" typeface="Raavi"/><a:font script="Cans" typeface="Euphemia"/><a:font script="Cher" typeface="Plantagenet Cherokee"/><a:font script="Yiii" typeface="Microsoft Yi Baiti"/><a:font script="Tibt" typeface="Microsoft Himalaya"/><a:font script="Thaa" typeface="MV Boli"/><a:font script="Deva" typeface="Mangal"/><a:font script="Telu" typeface="Gautami"/><a:font script="Taml" typeface="Latha"/><a:font script="Syrc" typeface="Estrangelo Edessa"/><a:font script="Orya" typeface="Kalinga"/><a:font script="Mlym" typeface="Kartika"/><a:font script="Laoo" typeface="DokChampa"/><a:font script="Sinh" typeface="Iskoola Pota"/><a:font script="Mong" typeface="Mongolian Baiti"/><a:font script="Viet" typeface="Times New Roman"/><a:font script="Uigh" typeface="Microsoft Uighur"/></a:majorFont><a:minorFont><a:latin typeface="Calibri"/><a:ea typeface=""/><a:cs typeface=""/><a:font script="Jpan" typeface="\uff2d\uff33 \uff30\u30b4\u30b7\u30c3\u30af"/><a:font script="Hang" typeface="\ub9d1\uc740 \uace0\ub515"/><a:font script="Hans" typeface="\u5b8b\u4f53"/><a:font script="Hant" typeface="\u65b0\u7d30\u660e\u9ad4"/><a:font script="Arab" typeface="Arial"/><a:font script="Hebr" typeface="Arial"/><a:font script="Thai" typeface="Tahoma"/><a:font script="Ethi" typeface="Nyala"/><a:font script="Beng" typeface="Vrinda"/><a:font script="Gujr" typeface="Shruti"/><a:font script="Khmr" typeface="DaunPenh"/><a:font script="Knda" typeface="Tunga"/><a:font script="Guru" typeface="Raavi"/><a:font script="Cans" typeface="Euphemia"/><a:font script="Cher" typeface="Plantagenet Cherokee"/><a:font script="Yiii" typeface="Microsoft Yi Baiti"/><a:font script="Tibt" typeface="Microsoft Himalaya"/><a:font script="Thaa" typeface="MV Boli"/><a:font script="Deva" typeface="Mangal"/><a:font script="Telu" typeface="Gautami"/><a:font script="Taml" typeface="Latha"/><a:font script="Syrc" typeface="Estrangelo Edessa"/><a:font script="Orya" typeface="Kalinga"/><a:font script="Mlym" typeface="Kartika"/><a:font script="Laoo" typeface="DokChampa"/><a:font script="Sinh" typeface="Iskoola Pota"/><a:font script="Mong" typeface="Mongolian Baiti"/><a:font script="Viet" typeface="Arial"/><a:font script="Uigh" typeface="Microsoft Uighur"/></a:minorFont></a:fontScheme><a:fmtScheme name="Office"><a:fillStyleLst><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="50000"/><a:satMod val="300000"/></a:schemeClr></a:gs><a:gs pos="35000"><a:schemeClr val="phClr"><a:tint val="37000"/><a:satMod val="300000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:tint val="15000"/><a:satMod val="350000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="16200000" scaled="1"/></a:gradFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:shade val="51000"/><a:satMod val="130000"/></a:schemeClr></a:gs><a:gs pos="80000"><a:schemeClr val="phClr"><a:shade val="93000"/><a:satMod val="130000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="94000"/><a:satMod val="135000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="16200000" scaled="0"/></a:gradFill></a:fillStyleLst><a:lnStyleLst><a:ln w="9525" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"><a:shade val="95000"/><a:satMod val="105000"/></a:schemeClr></a:solidFill><a:prstDash val="solid"/></a:ln><a:ln w="25400" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/></a:ln><a:ln w="38100" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/></a:ln></a:lnStyleLst><a:effectStyleLst><a:effectStyle><a:effectLst><a:outerShdw blurRad="40000" dist="20000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="38000"/></a:srgbClr></a:outerShdw></a:effectLst></a:effectStyle><a:effectStyle><a:effectLst><a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="35000"/></a:srgbClr></a:outerShdw></a:effectLst></a:effectStyle><a:effectStyle><a:effectLst><a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="35000"/></a:srgbClr></a:outerShdw></a:effectLst><a:scene3d><a:camera prst="orthographicFront"><a:rot lat="0" lon="0" rev="0"/></a:camera><a:lightRig rig="threePt" dir="t"><a:rot lat="0" lon="0" rev="1200000"/></a:lightRig></a:scene3d><a:sp3d><a:bevelT w="63500" h="25400"/></a:sp3d></a:effectStyle></a:effectStyleLst><a:bgFillStyleLst><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="40000"/><a:satMod val="350000"/></a:schemeClr></a:gs><a:gs pos="40000"><a:schemeClr val="phClr"><a:tint val="45000"/><a:shade val="99000"/><a:satMod val="350000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="20000"/><a:satMod val="255000"/></a:schemeClr></a:gs></a:gsLst><a:path path="circle"><a:fillToRect l="50000" t="-80000" r="50000" b="180000"/></a:path></a:gradFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="80000"/><a:satMod val="300000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="30000"/><a:satMod val="200000"/></a:schemeClr></a:gs></a:gsLst><a:path path="circle"><a:fillToRect l="50000" t="50000" r="50000" b="50000"/></a:path></a:gradFill></a:bgFillStyleLst></a:fmtScheme></a:themeElements><a:objectDefaults/><a:extraClrSchemeLst/></a:theme>""" - - if sys.version_info < (3, 0, 0): - default_theme = default_theme.decode('unicode-escape') - - self.fh.write(default_theme)
Binary file test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/theme.pyc has changed
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/utility.py Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,655 +0,0 @@ -############################################################################### -# -# Worksheet - A class for writing Excel Worksheets. -# -# Copyright 2013-2016, John McNamara, jmcnamara@cpan.org -# -import re -import datetime -from warnings import warn - -COL_NAMES = {} -range_parts = re.compile(r'(\$?)([A-Z]{1,3})(\$?)(\d+)') - - -def xl_rowcol_to_cell(row, col, row_abs=False, col_abs=False): - """ - Convert a zero indexed row and column cell reference to a A1 style string. - - Args: - row: The cell row. Int. - col: The cell column. Int. - row_abs: Optional flag to make the row absolute. Bool. - col_abs: Optional flag to make the column absolute. Bool. - - Returns: - A1 style string. - - """ - row += 1 # Change to 1-index. - row_abs = '$' if row_abs else '' - - col_str = xl_col_to_name(col, col_abs) - - return col_str + row_abs + str(row) - - -def xl_rowcol_to_cell_fast(row, col): - """ - Optimised version of the xl_rowcol_to_cell function. Only used internally. - - Args: - row: The cell row. Int. - col: The cell column. Int. - - Returns: - A1 style string. - - """ - if col in COL_NAMES: - col_str = COL_NAMES[col] - else: - col_str = xl_col_to_name(col) - COL_NAMES[col] = col_str - - return col_str + str(row + 1) - - -def xl_col_to_name(col_num, col_abs=False): - """ - Convert a zero indexed column cell reference to a string. - - Args: - col: The cell column. Int. - col_abs: Optional flag to make the column absolute. Bool. - - Returns: - Column style string. - - """ - col_num += 1 # Change to 1-index. - col_str = '' - col_abs = '$' if col_abs else '' - - while col_num: - # Set remainder from 1 .. 26 - remainder = col_num % 26 - - if remainder == 0: - remainder = 26 - - # Convert the remainder to a character. - col_letter = chr(ord('A') + remainder - 1) - - # Accumulate the column letters, right to left. - col_str = col_letter + col_str - - # Get the next order of magnitude. - col_num = int((col_num - 1) / 26) - - return col_abs + col_str - - -def xl_cell_to_rowcol(cell_str): - """ - Convert a cell reference in A1 notation to a zero indexed row and column. - - Args: - cell_str: A1 style string. - - Returns: - row, col: Zero indexed cell row and column indices. - - """ - if not cell_str: - return 0, 0 - - match = range_parts.match(cell_str) - col_str = match.group(2) - row_str = match.group(4) - - # Convert base26 column string to number. - expn = 0 - col = 0 - for char in reversed(col_str): - col += (ord(char) - ord('A') + 1) * (26 ** expn) - expn += 1 - - # Convert 1-index to zero-index - row = int(row_str) - 1 - col -= 1 - - return row, col - - -def xl_cell_to_rowcol_abs(cell_str): - """ - Convert an absolute cell reference in A1 notation to a zero indexed - row and column, with True/False values for absolute rows or columns. - - Args: - cell_str: A1 style string. - - Returns: - row, col, row_abs, col_abs: Zero indexed cell row and column indices. - - """ - if not cell_str: - return 0, 0, False, False - - match = range_parts.match(cell_str) - - col_abs = match.group(1) - col_str = match.group(2) - row_abs = match.group(3) - row_str = match.group(4) - - if col_abs: - col_abs = True - else: - col_abs = False - - if row_abs: - row_abs = True - else: - row_abs = False - - # Convert base26 column string to number. - expn = 0 - col = 0 - for char in reversed(col_str): - col += (ord(char) - ord('A') + 1) * (26 ** expn) - expn += 1 - - # Convert 1-index to zero-index - row = int(row_str) - 1 - col -= 1 - - return row, col, row_abs, col_abs - - -def xl_range(first_row, first_col, last_row, last_col): - """ - Convert zero indexed row and col cell references to a A1:B1 range string. - - Args: - first_row: The first cell row. Int. - first_col: The first cell column. Int. - last_row: The last cell row. Int. - last_col: The last cell column. Int. - - Returns: - A1:B1 style range string. - - """ - range1 = xl_rowcol_to_cell(first_row, first_col) - range2 = xl_rowcol_to_cell(last_row, last_col) - - return range1 + ':' + range2 - - -def xl_range_abs(first_row, first_col, last_row, last_col): - """ - Convert zero indexed row and col cell references to a $A$1:$B$1 absolute - range string. - - Args: - first_row: The first cell row. Int. - first_col: The first cell column. Int. - last_row: The last cell row. Int. - last_col: The last cell column. Int. - - Returns: - $A$1:$B$1 style range string. - - """ - range1 = xl_rowcol_to_cell(first_row, first_col, True, True) - range2 = xl_rowcol_to_cell(last_row, last_col, True, True) - - return range1 + ':' + range2 - - -def xl_range_formula(sheetname, first_row, first_col, last_row, last_col): - """ - Convert worksheet name and zero indexed row and col cell references to - a Sheet1!A1:B1 range formula string. - - Args: - sheetname: The worksheet name. String. - first_row: The first cell row. Int. - first_col: The first cell column. Int. - last_row: The last cell row. Int. - last_col: The last cell column. Int. - - Returns: - A1:B1 style range string. - - """ - cell_range = xl_range_abs(first_row, first_col, last_row, last_col) - sheetname = quote_sheetname(sheetname) - - return sheetname + '!' + cell_range - - -def quote_sheetname(sheetname): - """ - Convert a worksheet name to a quoted name if it contains spaces or - special characters. - - Args: - sheetname: The worksheet name. String. - - Returns: - A quoted worksheet string. - - """ - - # TODO. Possibly extend this to quote sheetnames that look like ranges. - if not sheetname.isalnum() and not sheetname.startswith("'"): - # Double quote any single quotes. - sheetname = sheetname.replace("'", "''") - - # Singe quote the sheet name. - sheetname = "'%s'" % sheetname - - return sheetname - - -def xl_color(color): - # Used in conjunction with the XlsxWriter *color() methods to convert - # a color name into an RGB formatted string. These colors are for - # backward compatibility with older versions of Excel. - named_colors = { - 'black': '#000000', - 'blue': '#0000FF', - 'brown': '#800000', - 'cyan': '#00FFFF', - 'gray': '#808080', - 'green': '#008000', - 'lime': '#00FF00', - 'magenta': '#FF00FF', - 'navy': '#000080', - 'orange': '#FF6600', - 'pink': '#FF00FF', - 'purple': '#800080', - 'red': '#FF0000', - 'silver': '#C0C0C0', - 'white': '#FFFFFF', - 'yellow': '#FFFF00', - } - - if color in named_colors: - color = named_colors[color] - - if not re.match('#[0-9a-fA-F]{6}', color): - warn("Color '%s' isn't a valid Excel color" % color) - - # Convert the RGB color to the Excel ARGB format. - return "FF" + color.lstrip('#').upper() - - -def get_rgb_color(color): - # Convert the user specified color to an RGB color. - rgb_color = xl_color(color) - - # Remove leading FF from RGB color for charts. - rgb_color = re.sub(r'^FF', '', rgb_color) - - return rgb_color - - -def get_sparkline_style(style_id): - styles = [ - {'series': {'theme': "4", 'tint': "-0.499984740745262"}, - 'negative': {'theme': "5"}, - 'markers': {'theme': "4", 'tint': "-0.499984740745262"}, - 'first': {'theme': "4", 'tint': "0.39997558519241921"}, - 'last': {'theme': "4", 'tint': "0.39997558519241921"}, - 'high': {'theme': "4"}, - 'low': {'theme': "4"}, - }, # 0 - {'series': {'theme': "4", 'tint': "-0.499984740745262"}, - 'negative': {'theme': "5"}, - 'markers': {'theme': "4", 'tint': "-0.499984740745262"}, - 'first': {'theme': "4", 'tint': "0.39997558519241921"}, - 'last': {'theme': "4", 'tint': "0.39997558519241921"}, - 'high': {'theme': "4"}, - 'low': {'theme': "4"}, - }, # 1 - {'series': {'theme': "5", 'tint': "-0.499984740745262"}, - 'negative': {'theme': "6"}, - 'markers': {'theme': "5", 'tint': "-0.499984740745262"}, - 'first': {'theme': "5", 'tint': "0.39997558519241921"}, - 'last': {'theme': "5", 'tint': "0.39997558519241921"}, - 'high': {'theme': "5"}, - 'low': {'theme': "5"}, - }, # 2 - {'series': {'theme': "6", 'tint': "-0.499984740745262"}, - 'negative': {'theme': "7"}, - 'markers': {'theme': "6", 'tint': "-0.499984740745262"}, - 'first': {'theme': "6", 'tint': "0.39997558519241921"}, - 'last': {'theme': "6", 'tint': "0.39997558519241921"}, - 'high': {'theme': "6"}, - 'low': {'theme': "6"}, - }, # 3 - {'series': {'theme': "7", 'tint': "-0.499984740745262"}, - 'negative': {'theme': "8"}, - 'markers': {'theme': "7", 'tint': "-0.499984740745262"}, - 'first': {'theme': "7", 'tint': "0.39997558519241921"}, - 'last': {'theme': "7", 'tint': "0.39997558519241921"}, - 'high': {'theme': "7"}, - 'low': {'theme': "7"}, - }, # 4 - {'series': {'theme': "8", 'tint': "-0.499984740745262"}, - 'negative': {'theme': "9"}, - 'markers': {'theme': "8", 'tint': "-0.499984740745262"}, - 'first': {'theme': "8", 'tint': "0.39997558519241921"}, - 'last': {'theme': "8", 'tint': "0.39997558519241921"}, - 'high': {'theme': "8"}, - 'low': {'theme': "8"}, - }, # 5 - {'series': {'theme': "9", 'tint': "-0.499984740745262"}, - 'negative': {'theme': "4"}, - 'markers': {'theme': "9", 'tint': "-0.499984740745262"}, - 'first': {'theme': "9", 'tint': "0.39997558519241921"}, - 'last': {'theme': "9", 'tint': "0.39997558519241921"}, - 'high': {'theme': "9"}, - 'low': {'theme': "9"}, - }, # 6 - {'series': {'theme': "4", 'tint': "-0.249977111117893"}, - 'negative': {'theme': "5"}, - 'markers': {'theme': "5", 'tint': "-0.249977111117893"}, - 'first': {'theme': "5", 'tint': "-0.249977111117893"}, - 'last': {'theme': "5", 'tint': "-0.249977111117893"}, - 'high': {'theme': "5", 'tint': "-0.249977111117893"}, - 'low': {'theme': "5", 'tint': "-0.249977111117893"}, - }, # 7 - {'series': {'theme': "5", 'tint': "-0.249977111117893"}, - 'negative': {'theme': "6"}, - 'markers': {'theme': "6", 'tint': "-0.249977111117893"}, - 'first': {'theme': "6", 'tint': "-0.249977111117893"}, - 'last': {'theme': "6", 'tint': "-0.249977111117893"}, - 'high': {'theme': "6", 'tint': "-0.249977111117893"}, - 'low': {'theme': "6", 'tint': "-0.249977111117893"}, - }, # 8 - {'series': {'theme': "6", 'tint': "-0.249977111117893"}, - 'negative': {'theme': "7"}, - 'markers': {'theme': "7", 'tint': "-0.249977111117893"}, - 'first': {'theme': "7", 'tint': "-0.249977111117893"}, - 'last': {'theme': "7", 'tint': "-0.249977111117893"}, - 'high': {'theme': "7", 'tint': "-0.249977111117893"}, - 'low': {'theme': "7", 'tint': "-0.249977111117893"}, - }, # 9 - {'series': {'theme': "7", 'tint': "-0.249977111117893"}, - 'negative': {'theme': "8"}, - 'markers': {'theme': "8", 'tint': "-0.249977111117893"}, - 'first': {'theme': "8", 'tint': "-0.249977111117893"}, - 'last': {'theme': "8", 'tint': "-0.249977111117893"}, - 'high': {'theme': "8", 'tint': "-0.249977111117893"}, - 'low': {'theme': "8", 'tint': "-0.249977111117893"}, - }, # 10 - {'series': {'theme': "8", 'tint': "-0.249977111117893"}, - 'negative': {'theme': "9"}, - 'markers': {'theme': "9", 'tint': "-0.249977111117893"}, - 'first': {'theme': "9", 'tint': "-0.249977111117893"}, - 'last': {'theme': "9", 'tint': "-0.249977111117893"}, - 'high': {'theme': "9", 'tint': "-0.249977111117893"}, - 'low': {'theme': "9", 'tint': "-0.249977111117893"}, - }, # 11 - {'series': {'theme': "9", 'tint': "-0.249977111117893"}, - 'negative': {'theme': "4"}, - 'markers': {'theme': "4", 'tint': "-0.249977111117893"}, - 'first': {'theme': "4", 'tint': "-0.249977111117893"}, - 'last': {'theme': "4", 'tint': "-0.249977111117893"}, - 'high': {'theme': "4", 'tint': "-0.249977111117893"}, - 'low': {'theme': "4", 'tint': "-0.249977111117893"}, - }, # 12 - {'series': {'theme': "4"}, - 'negative': {'theme': "5"}, - 'markers': {'theme': "4", 'tint': "-0.249977111117893"}, - 'first': {'theme': "4", 'tint': "-0.249977111117893"}, - 'last': {'theme': "4", 'tint': "-0.249977111117893"}, - 'high': {'theme': "4", 'tint': "-0.249977111117893"}, - 'low': {'theme': "4", 'tint': "-0.249977111117893"}, - }, # 13 - {'series': {'theme': "5"}, - 'negative': {'theme': "6"}, - 'markers': {'theme': "5", 'tint': "-0.249977111117893"}, - 'first': {'theme': "5", 'tint': "-0.249977111117893"}, - 'last': {'theme': "5", 'tint': "-0.249977111117893"}, - 'high': {'theme': "5", 'tint': "-0.249977111117893"}, - 'low': {'theme': "5", 'tint': "-0.249977111117893"}, - }, # 14 - {'series': {'theme': "6"}, - 'negative': {'theme': "7"}, - 'markers': {'theme': "6", 'tint': "-0.249977111117893"}, - 'first': {'theme': "6", 'tint': "-0.249977111117893"}, - 'last': {'theme': "6", 'tint': "-0.249977111117893"}, - 'high': {'theme': "6", 'tint': "-0.249977111117893"}, - 'low': {'theme': "6", 'tint': "-0.249977111117893"}, - }, # 15 - {'series': {'theme': "7"}, - 'negative': {'theme': "8"}, - 'markers': {'theme': "7", 'tint': "-0.249977111117893"}, - 'first': {'theme': "7", 'tint': "-0.249977111117893"}, - 'last': {'theme': "7", 'tint': "-0.249977111117893"}, - 'high': {'theme': "7", 'tint': "-0.249977111117893"}, - 'low': {'theme': "7", 'tint': "-0.249977111117893"}, - }, # 16 - {'series': {'theme': "8"}, - 'negative': {'theme': "9"}, - 'markers': {'theme': "8", 'tint': "-0.249977111117893"}, - 'first': {'theme': "8", 'tint': "-0.249977111117893"}, - 'last': {'theme': "8", 'tint': "-0.249977111117893"}, - 'high': {'theme': "8", 'tint': "-0.249977111117893"}, - 'low': {'theme': "8", 'tint': "-0.249977111117893"}, - }, # 17 - {'series': {'theme': "9"}, - 'negative': {'theme': "4"}, - 'markers': {'theme': "9", 'tint': "-0.249977111117893"}, - 'first': {'theme': "9", 'tint': "-0.249977111117893"}, - 'last': {'theme': "9", 'tint': "-0.249977111117893"}, - 'high': {'theme': "9", 'tint': "-0.249977111117893"}, - 'low': {'theme': "9", 'tint': "-0.249977111117893"}, - }, # 18 - {'series': {'theme': "4", 'tint': "0.39997558519241921"}, - 'negative': {'theme': "0", 'tint': "-0.499984740745262"}, - 'markers': {'theme': "4", 'tint': "0.79998168889431442"}, - 'first': {'theme': "4", 'tint': "-0.249977111117893"}, - 'last': {'theme': "4", 'tint': "-0.249977111117893"}, - 'high': {'theme': "4", 'tint': "-0.499984740745262"}, - 'low': {'theme': "4", 'tint': "-0.499984740745262"}, - }, # 19 - {'series': {'theme': "5", 'tint': "0.39997558519241921"}, - 'negative': {'theme': "0", 'tint': "-0.499984740745262"}, - 'markers': {'theme': "5", 'tint': "0.79998168889431442"}, - 'first': {'theme': "5", 'tint': "-0.249977111117893"}, - 'last': {'theme': "5", 'tint': "-0.249977111117893"}, - 'high': {'theme': "5", 'tint': "-0.499984740745262"}, - 'low': {'theme': "5", 'tint': "-0.499984740745262"}, - }, # 20 - {'series': {'theme': "6", 'tint': "0.39997558519241921"}, - 'negative': {'theme': "0", 'tint': "-0.499984740745262"}, - 'markers': {'theme': "6", 'tint': "0.79998168889431442"}, - 'first': {'theme': "6", 'tint': "-0.249977111117893"}, - 'last': {'theme': "6", 'tint': "-0.249977111117893"}, - 'high': {'theme': "6", 'tint': "-0.499984740745262"}, - 'low': {'theme': "6", 'tint': "-0.499984740745262"}, - }, # 21 - {'series': {'theme': "7", 'tint': "0.39997558519241921"}, - 'negative': {'theme': "0", 'tint': "-0.499984740745262"}, - 'markers': {'theme': "7", 'tint': "0.79998168889431442"}, - 'first': {'theme': "7", 'tint': "-0.249977111117893"}, - 'last': {'theme': "7", 'tint': "-0.249977111117893"}, - 'high': {'theme': "7", 'tint': "-0.499984740745262"}, - 'low': {'theme': "7", 'tint': "-0.499984740745262"}, - }, # 22 - {'series': {'theme': "8", 'tint': "0.39997558519241921"}, - 'negative': {'theme': "0", 'tint': "-0.499984740745262"}, - 'markers': {'theme': "8", 'tint': "0.79998168889431442"}, - 'first': {'theme': "8", 'tint': "-0.249977111117893"}, - 'last': {'theme': "8", 'tint': "-0.249977111117893"}, - 'high': {'theme': "8", 'tint': "-0.499984740745262"}, - 'low': {'theme': "8", 'tint': "-0.499984740745262"}, - }, # 23 - {'series': {'theme': "9", 'tint': "0.39997558519241921"}, - 'negative': {'theme': "0", 'tint': "-0.499984740745262"}, - 'markers': {'theme': "9", 'tint': "0.79998168889431442"}, - 'first': {'theme': "9", 'tint': "-0.249977111117893"}, - 'last': {'theme': "9", 'tint': "-0.249977111117893"}, - 'high': {'theme': "9", 'tint': "-0.499984740745262"}, - 'low': {'theme': "9", 'tint': "-0.499984740745262"}, - }, # 24 - {'series': {'theme': "1", 'tint': "0.499984740745262"}, - 'negative': {'theme': "1", 'tint': "0.249977111117893"}, - 'markers': {'theme': "1", 'tint': "0.249977111117893"}, - 'first': {'theme': "1", 'tint': "0.249977111117893"}, - 'last': {'theme': "1", 'tint': "0.249977111117893"}, - 'high': {'theme': "1", 'tint': "0.249977111117893"}, - 'low': {'theme': "1", 'tint': "0.249977111117893"}, - }, # 25 - {'series': {'theme': "1", 'tint': "0.34998626667073579"}, - 'negative': {'theme': "0", 'tint': "-0.249977111117893"}, - 'markers': {'theme': "0", 'tint': "-0.249977111117893"}, - 'first': {'theme': "0", 'tint': "-0.249977111117893"}, - 'last': {'theme': "0", 'tint': "-0.249977111117893"}, - 'high': {'theme': "0", 'tint': "-0.249977111117893"}, - 'low': {'theme': "0", 'tint': "-0.249977111117893"}, - }, # 26 - {'series': {'rgb': "FF323232"}, - 'negative': {'rgb': "FFD00000"}, - 'markers': {'rgb': "FFD00000"}, - 'first': {'rgb': "FFD00000"}, - 'last': {'rgb': "FFD00000"}, - 'high': {'rgb': "FFD00000"}, - 'low': {'rgb': "FFD00000"}, - }, # 27 - {'series': {'rgb': "FF000000"}, - 'negative': {'rgb': "FF0070C0"}, - 'markers': {'rgb': "FF0070C0"}, - 'first': {'rgb': "FF0070C0"}, - 'last': {'rgb': "FF0070C0"}, - 'high': {'rgb': "FF0070C0"}, - 'low': {'rgb': "FF0070C0"}, - }, # 28 - {'series': {'rgb': "FF376092"}, - 'negative': {'rgb': "FFD00000"}, - 'markers': {'rgb': "FFD00000"}, - 'first': {'rgb': "FFD00000"}, - 'last': {'rgb': "FFD00000"}, - 'high': {'rgb': "FFD00000"}, - 'low': {'rgb': "FFD00000"}, - }, # 29 - {'series': {'rgb': "FF0070C0"}, - 'negative': {'rgb': "FF000000"}, - 'markers': {'rgb': "FF000000"}, - 'first': {'rgb': "FF000000"}, - 'last': {'rgb': "FF000000"}, - 'high': {'rgb': "FF000000"}, - 'low': {'rgb': "FF000000"}, - }, # 30 - {'series': {'rgb': "FF5F5F5F"}, - 'negative': {'rgb': "FFFFB620"}, - 'markers': {'rgb': "FFD70077"}, - 'first': {'rgb': "FF5687C2"}, - 'last': {'rgb': "FF359CEB"}, - 'high': {'rgb': "FF56BE79"}, - 'low': {'rgb': "FFFF5055"}, - }, # 31 - {'series': {'rgb': "FF5687C2"}, - 'negative': {'rgb': "FFFFB620"}, - 'markers': {'rgb': "FFD70077"}, - 'first': {'rgb': "FF777777"}, - 'last': {'rgb': "FF359CEB"}, - 'high': {'rgb': "FF56BE79"}, - 'low': {'rgb': "FFFF5055"}, - }, # 32 - {'series': {'rgb': "FFC6EFCE"}, - 'negative': {'rgb': "FFFFC7CE"}, - 'markers': {'rgb': "FF8CADD6"}, - 'first': {'rgb': "FFFFDC47"}, - 'last': {'rgb': "FFFFEB9C"}, - 'high': {'rgb': "FF60D276"}, - 'low': {'rgb': "FFFF5367"}, - }, # 33 - {'series': {'rgb': "FF00B050"}, - 'negative': {'rgb': "FFFF0000"}, - 'markers': {'rgb': "FF0070C0"}, - 'first': {'rgb': "FFFFC000"}, - 'last': {'rgb': "FFFFC000"}, - 'high': {'rgb': "FF00B050"}, - 'low': {'rgb': "FFFF0000"}, - }, # 34 - {'series': {'theme': "3"}, - 'negative': {'theme': "9"}, - 'markers': {'theme': "8"}, - 'first': {'theme': "4"}, - 'last': {'theme': "5"}, - 'high': {'theme': "6"}, - 'low': {'theme': "7"}, - }, # 35 - {'series': {'theme': "1"}, - 'negative': {'theme': "9"}, - 'markers': {'theme': "8"}, - 'first': {'theme': "4"}, - 'last': {'theme': "5"}, - 'high': {'theme': "6"}, - 'low': {'theme': "7"}, - }, # 36 - ] - - return styles[style_id] - - -def supported_datetime(dt): - # Determine is an argument is a supported datetime object. - return(isinstance(dt, (datetime.datetime, - datetime.date, - datetime.time, - datetime.timedelta))) - - -def datetime_to_excel_datetime(dt_obj, date_1904): - # Convert a datetime object to an Excel serial date and time. The integer - # part of the number stores the number of days since the epoch and the - # fractional part stores the percentage of the day. - - if date_1904: - # Excel for Mac date epoch. - epoch = datetime.datetime(1904, 1, 1) - else: - # Default Excel epoch. - epoch = datetime.datetime(1899, 12, 31) - - # We handle datetime .datetime, .date and .time objects but convert - # them to datetime.datetime objects and process them in the same way. - if isinstance(dt_obj, datetime.datetime): - delta = dt_obj - epoch - elif isinstance(dt_obj, datetime.date): - dt_obj = datetime.datetime.fromordinal(dt_obj.toordinal()) - delta = dt_obj - epoch - elif isinstance(dt_obj, datetime.time): - dt_obj = datetime.datetime.combine(epoch, dt_obj) - delta = dt_obj - epoch - elif isinstance(dt_obj, datetime.timedelta): - delta = dt_obj - else: - raise TypeError("Unknown or unsupported datetime type") - - # Convert a Python datetime.datetime value to an Excel date number. - excel_time = (delta.days - + (float(delta.seconds) - + float(delta.microseconds) / 1E6) - / (60 * 60 * 24)) - - # Special case for datetime where time only has been specified and - # the default date of 1900-01-01 is used. - if (not isinstance(dt_obj, datetime.timedelta) - and dt_obj.isocalendar() == (1900, 1, 1)): - excel_time -= 1 - - # Account for Excel erroneously treating 1900 as a leap year. - if not date_1904 and excel_time > 59: - excel_time += 1 - - return excel_time
Binary file test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/utility.pyc has changed
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/vml.py Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,706 +0,0 @@ -############################################################################### -# -# Vml - A class for writing the Excel XLSX Vml file. -# -# Copyright 2013-2016, John McNamara, jmcnamara@cpan.org -# - -# Package imports. -from . import xmlwriter - - -class Vml(xmlwriter.XMLwriter): - """ - A class for writing the Excel XLSX Vml file. - - - """ - - ########################################################################### - # - # Public API. - # - ########################################################################### - - def __init__(self): - """ - Constructor. - - """ - - super(Vml, self).__init__() - - ########################################################################### - # - # Private API. - # - ########################################################################### - def _assemble_xml_file(self, data_id, vml_shape_id, comments_data=None, - buttons_data=None, header_images_data=None): - # Assemble and write the XML file. - z_index = 1 - - self._write_xml_namespace() - - # Write the o:shapelayout element. - self._write_shapelayout(data_id) - - if buttons_data: - # Write the v:shapetype element. - self._write_button_shapetype() - - for button in buttons_data: - # Write the v:shape element. - vml_shape_id += 1 - self._write_button_shape(vml_shape_id, z_index, button) - z_index += 1 - - if comments_data: - # Write the v:shapetype element. - self._write_comment_shapetype() - - for comment in comments_data: - # Write the v:shape element. - vml_shape_id += 1 - self._write_comment_shape(vml_shape_id, z_index, comment) - z_index += 1 - - if header_images_data: - - # Write the v:shapetype element. - self._write_image_shapetype() - - index = 1 - for image in header_images_data: - # Write the v:shape element. - vml_shape_id += 1 - self._write_image_shape(vml_shape_id, index, image) - index += 1 - - self._xml_end_tag('xml') - - # Close the XML writer filehandle. - self._xml_close() - - def _pixels_to_points(self, vertices): - # Convert comment vertices from pixels to points. - - left, top, width, height = vertices[8:12] - - # Scale to pixels. - left *= 0.75 - top *= 0.75 - width *= 0.75 - height *= 0.75 - - return left, top, width, height - - ########################################################################### - # - # XML methods. - # - ########################################################################### - def _write_xml_namespace(self): - # Write the <xml> element. This is the root element of VML. - schema = 'urn:schemas-microsoft-com:' - xmlns = schema + 'vml' - xmlns_o = schema + 'office:office' - xmlns_x = schema + 'office:excel' - - attributes = [ - ('xmlns:v', xmlns), - ('xmlns:o', xmlns_o), - ('xmlns:x', xmlns_x), - ] - - self._xml_start_tag('xml', attributes) - - def _write_shapelayout(self, data_id): - # Write the <o:shapelayout> element. - attributes = [('v:ext', 'edit')] - - self._xml_start_tag('o:shapelayout', attributes) - - # Write the o:idmap element. - self._write_idmap(data_id) - - self._xml_end_tag('o:shapelayout') - - def _write_idmap(self, data_id): - # Write the <o:idmap> element. - attributes = [ - ('v:ext', 'edit'), - ('data', data_id), - ] - - self._xml_empty_tag('o:idmap', attributes) - - def _write_comment_shapetype(self): - # Write the <v:shapetype> element. - shape_id = '_x0000_t202' - coordsize = '21600,21600' - spt = 202 - path = 'm,l,21600r21600,l21600,xe' - - attributes = [ - ('id', shape_id), - ('coordsize', coordsize), - ('o:spt', spt), - ('path', path), - ] - - self._xml_start_tag('v:shapetype', attributes) - - # Write the v:stroke element. - self._write_stroke() - - # Write the v:path element. - self._write_comment_path('t', 'rect') - - self._xml_end_tag('v:shapetype') - - def _write_button_shapetype(self): - # Write the <v:shapetype> element. - shape_id = '_x0000_t201' - coordsize = '21600,21600' - spt = 201 - path = 'm,l,21600r21600,l21600,xe' - - attributes = [ - ('id', shape_id), - ('coordsize', coordsize), - ('o:spt', spt), - ('path', path), - ] - - self._xml_start_tag('v:shapetype', attributes) - - # Write the v:stroke element. - self._write_stroke() - - # Write the v:path element. - self._write_button_path() - - # Write the o:lock element. - self._write_shapetype_lock() - - self._xml_end_tag('v:shapetype') - - def _write_image_shapetype(self): - # Write the <v:shapetype> element. - shape_id = '_x0000_t75' - coordsize = '21600,21600' - spt = 75 - o_preferrelative = 't' - path = 'm@4@5l@4@11@9@11@9@5xe' - filled = 'f' - stroked = 'f' - - attributes = [ - ('id', shape_id), - ('coordsize', coordsize), - ('o:spt', spt), - ('o:preferrelative', o_preferrelative), - ('path', path), - ('filled', filled), - ('stroked', stroked), - ] - - self._xml_start_tag('v:shapetype', attributes) - - # Write the v:stroke element. - self._write_stroke() - - # Write the v:formulas element. - self._write_formulas() - - # Write the v:path element. - self._write_image_path() - - # Write the o:lock element. - self._write_aspect_ratio_lock() - - self._xml_end_tag('v:shapetype') - - def _write_stroke(self): - # Write the <v:stroke> element. - joinstyle = 'miter' - - attributes = [('joinstyle', joinstyle)] - - self._xml_empty_tag('v:stroke', attributes) - - def _write_comment_path(self, gradientshapeok, connecttype): - # Write the <v:path> element. - attributes = [] - - if gradientshapeok: - attributes.append(('gradientshapeok', 't')) - - attributes.append(('o:connecttype', connecttype)) - - self._xml_empty_tag('v:path', attributes) - - def _write_button_path(self): - # Write the <v:path> element. - shadowok = 'f' - extrusionok = 'f' - strokeok = 'f' - fillok = 'f' - connecttype = 'rect' - - attributes = [ - ('shadowok', shadowok), - ('o:extrusionok', extrusionok), - ('strokeok', strokeok), - ('fillok', fillok), - ('o:connecttype', connecttype), - ] - - self._xml_empty_tag('v:path', attributes) - - def _write_image_path(self): - # Write the <v:path> element. - extrusionok = 'f' - gradientshapeok = 't' - connecttype = 'rect' - - attributes = [ - ('o:extrusionok', extrusionok), - ('gradientshapeok', gradientshapeok), - ('o:connecttype', connecttype), - ] - - self._xml_empty_tag('v:path', attributes) - - def _write_shapetype_lock(self): - # Write the <o:lock> element. - ext = 'edit' - shapetype = 't' - - attributes = [ - ('v:ext', ext), - ('shapetype', shapetype), - ] - - self._xml_empty_tag('o:lock', attributes) - - def _write_rotation_lock(self): - # Write the <o:lock> element. - ext = 'edit' - rotation = 't' - - attributes = [ - ('v:ext', ext), - ('rotation', rotation), - ] - - self._xml_empty_tag('o:lock', attributes) - - def _write_aspect_ratio_lock(self): - # Write the <o:lock> element. - ext = 'edit' - aspectratio = 't' - - attributes = [ - ('v:ext', ext), - ('aspectratio', aspectratio), - ] - - self._xml_empty_tag('o:lock', attributes) - - def _write_comment_shape(self, shape_id, z_index, comment): - # Write the <v:shape> element. - shape_type = '#_x0000_t202' - insetmode = 'auto' - visibility = 'hidden' - - # Set the shape index. - shape_id = '_x0000_s' + str(shape_id) - - # Get the comment parameters - row = comment[0] - col = comment[1] - visible = comment[4] - fillcolor = comment[5] - vertices = comment[6] - - (left, top, width, height) = self._pixels_to_points(vertices) - - # Set the visibility. - if visible: - visibility = 'visible' - - style = ( - 'position:absolute;' - 'margin-left:%.15gpt;' - 'margin-top:%.15gpt;' - 'width:%.15gpt;' - 'height:%.15gpt;' - 'z-index:%d;' - 'visibility:%s' % (left, top, width, height, z_index, visibility)) - - attributes = [ - ('id', shape_id), - ('type', shape_type), - ('style', style), - ('fillcolor', fillcolor), - ('o:insetmode', insetmode), - ] - - self._xml_start_tag('v:shape', attributes) - - # Write the v:fill element. - self._write_comment_fill() - - # Write the v:shadow element. - self._write_shadow() - - # Write the v:path element. - self._write_comment_path(None, 'none') - - # Write the v:textbox element. - self._write_comment_textbox() - - # Write the x:ClientData element. - self._write_comment_client_data(row, col, visible, vertices) - - self._xml_end_tag('v:shape') - - def _write_button_shape(self, shape_id, z_index, button): - # Write the <v:shape> element. - shape_type = '#_x0000_t201' - - # Set the shape index. - shape_id = '_x0000_s' + str(shape_id) - - # Get the button parameters. - # row = button["_row"] - # col = button["_col"] - vertices = button["vertices"] - - (left, top, width, height) = self._pixels_to_points(vertices) - - style = ( - 'position:absolute;' - 'margin-left:%.15gpt;' - 'margin-top:%.15gpt;' - 'width:%.15gpt;' - 'height:%.15gpt;' - 'z-index:%d;' - 'mso-wrap-style:tight' % (left, top, width, height, z_index)) - - attributes = [ - ('id', shape_id), - ('type', shape_type), - ('style', style), - ('o:button', 't'), - ('fillcolor', 'buttonFace [67]'), - ('strokecolor', 'windowText [64]'), - ('o:insetmode', 'auto'), - ] - - self._xml_start_tag('v:shape', attributes) - - # Write the v:fill element. - self._write_button_fill() - - # Write the o:lock element. - self._write_rotation_lock() - - # Write the v:textbox element. - self._write_button_textbox(button["font"]) - - # Write the x:ClientData element. - self._write_button_client_data(button) - - self._xml_end_tag('v:shape') - - def _write_image_shape(self, shape_id, z_index, image_data): - # Write the <v:shape> element. - shape_type = '#_x0000_t75' - - # Set the shape index. - shape_id = '_x0000_s' + str(shape_id) - - # Get the image parameters - width = image_data[0] - height = image_data[1] - name = image_data[2] - position = image_data[3] - x_dpi = image_data[4] - y_dpi = image_data[5] - - # Scale the height/width by the resolution, relative to 72dpi. - width = width * 72.0 / x_dpi - height = height * 72.0 / y_dpi - - # Excel uses a rounding based around 72 and 96 dpi. - width = 72.0 / 96 * int(width * 96.0 / 72 + 0.25) - height = 72.0 / 96 * int(height * 96.0 / 72 + 0.25) - - style = ( - 'position:absolute;' - 'margin-left:0;' - 'margin-top:0;' - 'width:%.15gpt;' - 'height:%.15gpt;' - 'z-index:%d' % (width, height, z_index)) - - attributes = [ - ('id', position), - ('o:spid', shape_id), - ('type', shape_type), - ('style', style), - ] - - self._xml_start_tag('v:shape', attributes) - - # Write the v:imagedata element. - self._write_imagedata(z_index, name) - - # Write the o:lock element. - self._write_rotation_lock() - - self._xml_end_tag('v:shape') - - def _write_comment_fill(self): - # Write the <v:fill> element. - color_2 = '#ffffe1' - - attributes = [('color2', color_2)] - - self._xml_empty_tag('v:fill', attributes) - - def _write_button_fill(self): - # Write the <v:fill> element. - color_2 = 'buttonFace [67]' - detectmouseclick = 't' - - attributes = [ - ('color2', color_2), - ('o:detectmouseclick', detectmouseclick), - ] - - self._xml_empty_tag('v:fill', attributes) - - def _write_shadow(self): - # Write the <v:shadow> element. - on = 't' - color = 'black' - obscured = 't' - - attributes = [ - ('on', on), - ('color', color), - ('obscured', obscured), - ] - - self._xml_empty_tag('v:shadow', attributes) - - def _write_comment_textbox(self): - # Write the <v:textbox> element. - style = 'mso-direction-alt:auto' - - attributes = [('style', style)] - - self._xml_start_tag('v:textbox', attributes) - - # Write the div element. - self._write_div('left') - - self._xml_end_tag('v:textbox') - - def _write_button_textbox(self, font): - # Write the <v:textbox> element. - style = 'mso-direction-alt:auto' - - attributes = [('style', style), ('o:singleclick', 'f')] - - self._xml_start_tag('v:textbox', attributes) - - # Write the div element. - self._write_div('center', font) - - self._xml_end_tag('v:textbox') - - def _write_div(self, align, font=None): - # Write the <div> element. - - style = 'text-align:' + align - - attributes = [('style', style)] - - self._xml_start_tag('div', attributes) - - if font: - # Write the font element. - self._write_font(font) - - self._xml_end_tag('div') - - def _write_font(self, font): - # Write the <font> element. - caption = font["caption"] - face = 'Calibri' - size = 220 - color = '#000000' - - attributes = [ - ('face', face), - ('size', size), - ('color', color), - ] - - self._xml_data_element('font', caption, attributes) - - def _write_comment_client_data(self, row, col, visible, vertices): - # Write the <x:ClientData> element. - object_type = 'Note' - - attributes = [('ObjectType', object_type)] - - self._xml_start_tag('x:ClientData', attributes) - - # Write the x:MoveWithCells element. - self._write_move_with_cells() - - # Write the x:SizeWithCells element. - self._write_size_with_cells() - - # Write the x:Anchor element. - self._write_anchor(vertices) - - # Write the x:AutoFill element. - self._write_auto_fill() - - # Write the x:Row element. - self._write_row(row) - - # Write the x:Column element. - self._write_column(col) - - # Write the x:Visible element. - if visible: - self._write_visible() - - self._xml_end_tag('x:ClientData') - - def _write_button_client_data(self, button): - # Write the <x:ClientData> element. - macro = button["macro"] - vertices = button["vertices"] - - object_type = 'Button' - - attributes = [('ObjectType', object_type)] - - self._xml_start_tag('x:ClientData', attributes) - - # Write the x:Anchor element. - self._write_anchor(vertices) - - # Write the x:PrintObject element. - self._write_print_object() - - # Write the x:AutoFill element. - self._write_auto_fill() - - # Write the x:FmlaMacro element. - self._write_fmla_macro(macro) - - # Write the x:TextHAlign element. - self._write_text_halign() - - # Write the x:TextVAlign element. - self._write_text_valign() - - self._xml_end_tag('x:ClientData') - - def _write_move_with_cells(self): - # Write the <x:MoveWithCells> element. - self._xml_empty_tag('x:MoveWithCells') - - def _write_size_with_cells(self): - # Write the <x:SizeWithCells> element. - self._xml_empty_tag('x:SizeWithCells') - - def _write_visible(self): - # Write the <x:Visible> element. - self._xml_empty_tag('x:Visible') - - def _write_anchor(self, vertices): - # Write the <x:Anchor> element. - (col_start, row_start, x1, y1, col_end, row_end, x2, y2) = vertices[:8] - - strings = [col_start, x1, row_start, y1, col_end, x2, row_end, y2] - strings = [str(i) for i in strings] - - data = ", ".join(strings) - - self._xml_data_element('x:Anchor', data) - - def _write_auto_fill(self): - # Write the <x:AutoFill> element. - data = 'False' - - self._xml_data_element('x:AutoFill', data) - - def _write_row(self, data): - # Write the <x:Row> element. - self._xml_data_element('x:Row', data) - - def _write_column(self, data): - # Write the <x:Column> element. - self._xml_data_element('x:Column', data) - - def _write_print_object(self): - # Write the <x:PrintObject> element. - self._xml_data_element('x:PrintObject', 'False') - - def _write_text_halign(self): - # Write the <x:TextHAlign> element. - self._xml_data_element('x:TextHAlign', 'Center') - - def _write_text_valign(self): - # Write the <x:TextVAlign> element. - self._xml_data_element('x:TextVAlign', 'Center') - - def _write_fmla_macro(self, data): - # Write the <x:FmlaMacro> element. - self._xml_data_element('x:FmlaMacro', data) - - def _write_imagedata(self, image_index, o_title): - # Write the <v:imagedata> element. - attributes = [ - ('o:relid', 'rId' + str(image_index)), - ('o:title', o_title), - ] - - self._xml_empty_tag('v:imagedata', attributes) - - def _write_formulas(self): - # Write the <v:formulas> element. - self._xml_start_tag('v:formulas') - - # Write the v:f elements. - self._write_formula('if lineDrawn pixelLineWidth 0') - self._write_formula('sum @0 1 0') - self._write_formula('sum 0 0 @1') - self._write_formula('prod @2 1 2') - self._write_formula('prod @3 21600 pixelWidth') - self._write_formula('prod @3 21600 pixelHeight') - self._write_formula('sum @0 0 1') - self._write_formula('prod @6 1 2') - self._write_formula('prod @7 21600 pixelWidth') - self._write_formula('sum @8 21600 0') - self._write_formula('prod @7 21600 pixelHeight') - self._write_formula('sum @10 21600 0') - - self._xml_end_tag('v:formulas') - - def _write_formula(self, eqn): - # Write the <v:f> element. - attributes = [('eqn', eqn)] - - self._xml_empty_tag('v:f', attributes)
Binary file test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/vml.pyc has changed
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/workbook.py Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1545 +0,0 @@ -############################################################################### -# -# Workbook - A class for writing the Excel XLSX Workbook file. -# -# Copyright 2013-2016, John McNamara, jmcnamara@cpan.org -# - -# Standard packages. -import sys -import re -import os -import operator -from warnings import warn -from datetime import datetime -from zipfile import ZipFile, ZIP_DEFLATED -from struct import unpack - -from .compatibility import str_types, force_unicode - -# Package imports. -from . import xmlwriter -from xlsxwriter.worksheet import Worksheet -from xlsxwriter.chartsheet import Chartsheet -from xlsxwriter.sharedstrings import SharedStringTable -from xlsxwriter.format import Format -from xlsxwriter.packager import Packager -from .utility import xl_cell_to_rowcol -from xlsxwriter.chart_area import ChartArea -from xlsxwriter.chart_bar import ChartBar -from xlsxwriter.chart_column import ChartColumn -from xlsxwriter.chart_doughnut import ChartDoughnut -from xlsxwriter.chart_line import ChartLine -from xlsxwriter.chart_pie import ChartPie -from xlsxwriter.chart_radar import ChartRadar -from xlsxwriter.chart_scatter import ChartScatter -from xlsxwriter.chart_stock import ChartStock - - -class Workbook(xmlwriter.XMLwriter): - """ - A class for writing the Excel XLSX Workbook file. - - - """ - - ########################################################################### - # - # Public API. - # - ########################################################################### - - def __init__(self, filename=None, options={}): - """ - Constructor. - - """ - - super(Workbook, self).__init__() - - self.filename = filename - - self.tmpdir = options.get('tmpdir', None) - self.date_1904 = options.get('date_1904', False) - self.strings_to_numbers = options.get('strings_to_numbers', False) - self.strings_to_formulas = options.get('strings_to_formulas', True) - self.strings_to_urls = options.get('strings_to_urls', True) - self.nan_inf_to_errors = options.get('nan_inf_to_errors', False) - self.default_date_format = options.get('default_date_format', None) - self.optimization = options.get('constant_memory', False) - self.in_memory = options.get('in_memory', False) - self.excel2003_style = options.get('excel2003_style', False) - self.default_format_properties = \ - options.get('default_format_properties', {}) - - self.worksheet_meta = WorksheetMeta() - self.selected = 0 - self.fileclosed = 0 - self.filehandle = None - self.internal_fh = 0 - self.sheet_name = 'Sheet' - self.chart_name = 'Chart' - self.sheetname_count = 0 - self.chartname_count = 0 - self.worksheets_objs = [] - self.charts = [] - self.drawings = [] - self.sheetnames = [] - self.formats = [] - self.xf_formats = [] - self.xf_format_indices = {} - self.dxf_formats = [] - self.dxf_format_indices = {} - self.palette = [] - self.font_count = 0 - self.num_format_count = 0 - self.defined_names = [] - self.named_ranges = [] - self.custom_colors = [] - self.doc_properties = {} - self.localtime = datetime.now() - self.num_vml_files = 0 - self.num_comment_files = 0 - self.x_window = 240 - self.y_window = 15 - self.window_width = 16095 - self.window_height = 9660 - self.tab_ratio = 500 - self.str_table = SharedStringTable() - self.vba_project = None - self.vba_is_stream = False - self.vba_codename = None - self.image_types = {} - self.images = [] - self.border_count = 0 - self.fill_count = 0 - self.drawing_count = 0 - self.calc_mode = "auto" - self.calc_on_load = True - self.allow_zip64 = False - self.calc_id = 124519 - - # We can't do 'constant_memory' mode while doing 'in_memory' mode. - if self.in_memory: - self.optimization = False - - # Add the default cell format. - if self.excel2003_style: - self.add_format({'xf_index': 0, 'font_family': 0}) - else: - self.add_format({'xf_index': 0}) - - # Add a default URL format. - self.default_url_format = self.add_format({'color': 'blue', - 'underline': 1}) - - # Add the default date format. - if self.default_date_format is not None: - self.default_date_format = \ - self.add_format({'num_format': self.default_date_format}) - - def __del__(self): - """Close file in destructor if it hasn't been closed explicitly.""" - try: - if not self.fileclosed: - self.close() - except: - raise Exception("Exception caught in workbook destructor. " - "Explicit close() may be required for workbook.") - - def __enter__(self): - """Return self object to use with "with" statement.""" - return self - - def __exit__(self, type, value, traceback): - """Close workbook when exiting "with" statement.""" - self.close() - - def add_worksheet(self, name=None): - """ - Add a new worksheet to the Excel workbook. - - Args: - name: The worksheet name. Defaults to 'Sheet1', etc. - - Returns: - Reference to a worksheet object. - - """ - return self._add_sheet(name, is_chartsheet=False) - - def add_chartsheet(self, name=None): - """ - Add a new chartsheet to the Excel workbook. - - Args: - name: The chartsheet name. Defaults to 'Sheet1', etc. - - Returns: - Reference to a chartsheet object. - - """ - return self._add_sheet(name, is_chartsheet=True) - - def add_format(self, properties={}): - """ - Add a new Format to the Excel Workbook. - - Args: - properties: The format properties. - - Returns: - Reference to a Format object. - - """ - format_properties = self.default_format_properties.copy() - - if self.excel2003_style: - format_properties = {'font_name': 'Arial', 'font_size': 10, - 'theme': 1 * -1} - - format_properties.update(properties) - - xf_format = Format(format_properties, - self.xf_format_indices, - self.dxf_format_indices) - - # Store the format reference. - self.formats.append(xf_format) - - return xf_format - - def add_chart(self, options): - """ - Create a chart object. - - Args: - options: The chart type and subtype options. - - Returns: - Reference to a Chart object. - - """ - - # Type must be specified so we can create the required chart instance. - chart_type = options.get('type') - if chart_type is None: - warn("Chart type must be defined in add_chart()") - return - - if chart_type == 'area': - chart = ChartArea(options) - elif chart_type == 'bar': - chart = ChartBar(options) - elif chart_type == 'column': - chart = ChartColumn(options) - elif chart_type == 'doughnut': - chart = ChartDoughnut(options) - elif chart_type == 'line': - chart = ChartLine(options) - elif chart_type == 'pie': - chart = ChartPie(options) - elif chart_type == 'radar': - chart = ChartRadar(options) - elif chart_type == 'scatter': - chart = ChartScatter(options) - elif chart_type == 'stock': - chart = ChartStock(options) - else: - warn("Unknown chart type '%s' in add_chart()" % chart_type) - return - - # Set the embedded chart name if present. - if 'name' in options: - chart.chart_name = options['name'] - - chart.embedded = True - chart.date_1904 = self.date_1904 - - self.charts.append(chart) - - return chart - - def add_vba_project(self, vba_project, is_stream=False): - """ - Add a vbaProject binary to the Excel workbook. - - Args: - vba_project: The vbaProject binary file name. - is_stream: vba_project is an in memory byte stream. - - Returns: - Nothing. - - """ - if not is_stream and not os.path.exists(vba_project): - warn("VBA project binary file '%s' not found." - % force_unicode(vba_project)) - return -1 - - self.vba_project = vba_project - self.vba_is_stream = is_stream - - def close(self): - """ - Call finalization code and close file. - - Args: - None. - - Returns: - Nothing. - - """ - if not self.fileclosed: - self.fileclosed = 1 - self._store_workbook() - - def set_properties(self, properties): - """ - Set the document properties such as Title, Author etc. - - Args: - properties: Dictionary of document properties. - - Returns: - Nothing. - - """ - self.doc_properties = properties - - def set_calc_mode(self, mode, calc_id=None): - """ - Set the Excel calculation mode for the workbook. - - Args: - mode: String containing one of: - * manual - * auto_except_tables - * auto - - Returns: - Nothing. - - """ - self.calc_mode = mode - - if mode == 'manual': - self.calc_on_load = False - elif mode == 'auto_except_tables': - self.calc_mode = 'autoNoTable' - - # Leave undocumented for now. Rarely required. - if calc_id: - self.calc_id = calc_id - - def define_name(self, name, formula): - # Create a defined name in Excel. We handle global/workbook level - # names and local/worksheet names. - """ - Create a defined name in the workbook. - - Args: - name: The defined name. - formula: The cell or range that the defined name refers to. - - Returns: - Nothing. - - """ - sheet_index = None - sheetname = '' - - # Remove the = sign from the formula if it exists. - if formula.startswith('='): - formula = formula.lstrip('=') - - # Local defined names are formatted like "Sheet1!name". - sheet_parts = re.compile(r'^(.*)!(.*)$') - match = sheet_parts.match(name) - - if match: - sheetname = match.group(1) - name = match.group(2) - sheet_index = self._get_sheet_index(sheetname) - - # Warn if the sheet index wasn't found. - if sheet_index is None: - warn("Unknown sheet name '%s' in defined_name()" - % force_unicode(sheetname)) - return -1 - else: - # Use -1 to indicate global names. - sheet_index = -1 - - # Warn if the defined name contains invalid chars as defined by Excel. - if (not re.match(r'^[\w\\][\w\\.]*$', name, re.UNICODE) - or re.match(r'^\d', name)): - warn("Invalid Excel characters in defined_name(): '%s'" - % force_unicode(name)) - return -1 - - # Warn if the defined name looks like a cell name. - if re.match(r'^[a-zA-Z][a-zA-Z]?[a-dA-D]?[0-9]+$', name): - warn("Name looks like a cell name in defined_name(): '%s'" - % force_unicode(name)) - return -1 - - # Warn if the name looks like a R1C1 cell reference. - if (re.match(r'^[rcRC]$', name) - or re.match(r'^[rcRC]\d+[rcRC]\d+$', name)): - warn("Invalid name '%s' like a RC cell ref in defined_name()" - % force_unicode(name)) - return -1 - - self.defined_names.append([name, sheet_index, formula, False]) - - def worksheets(self): - """ - Return a list of the worksheet objects in the workbook. - - Args: - None. - - Returns: - A list of worksheet objects. - - """ - return self.worksheets_objs - - def use_zip64(self): - """ - Allow ZIP64 extensions when writing xlsx file zip container. - - Args: - None. - - Returns: - Nothing. - - """ - self.allow_zip64 = True - - def set_vba_name(self, name=None): - """ - Set the VBA name for the workbook. By default the workbook is referred - to as ThisWorkbook in VBA. - - Args: - name: The VBA name for the workbook. - - Returns: - Nothing. - - """ - if name is not None: - self.vba_codename = name - else: - self.vba_codename = 'ThisWorkbook' - - ########################################################################### - # - # Private API. - # - ########################################################################### - - def _assemble_xml_file(self): - # Assemble and write the XML file. - - # Prepare format object for passing to Style.pm. - self._prepare_format_properties() - - # Write the XML declaration. - self._xml_declaration() - - # Write the workbook element. - self._write_workbook() - - # Write the fileVersion element. - self._write_file_version() - - # Write the workbookPr element. - self._write_workbook_pr() - - # Write the bookViews element. - self._write_book_views() - - # Write the sheets element. - self._write_sheets() - - # Write the workbook defined names. - self._write_defined_names() - - # Write the calcPr element. - self._write_calc_pr() - - # Close the workbook tag. - self._xml_end_tag('workbook') - - # Close the file. - self._xml_close() - - def _store_workbook(self): - # Assemble worksheets into a workbook. - packager = Packager() - - # Add a default worksheet if non have been added. - if not self.worksheets(): - self.add_worksheet() - - # Ensure that at least one worksheet has been selected. - if self.worksheet_meta.activesheet == 0: - self.worksheets_objs[0].selected = 1 - self.worksheets_objs[0].hidden = 0 - - # Set the active sheet. - for sheet in self.worksheets(): - if sheet.index == self.worksheet_meta.activesheet: - sheet.active = 1 - - # Convert the SST strings data structure. - self._prepare_sst_string_data() - - # Prepare the worksheet VML elements such as comments and buttons. - self._prepare_vml() - - # Set the defined names for the worksheets such as Print Titles. - self._prepare_defined_names() - - # Prepare the drawings, charts and images. - self._prepare_drawings() - - # Add cached data to charts. - self._add_chart_data() - - # Prepare the worksheet tables. - self._prepare_tables() - - # Package the workbook. - packager._add_workbook(self) - packager._set_tmpdir(self.tmpdir) - packager._set_in_memory(self.in_memory) - xml_files = packager._create_package() - - # Free up the Packager object. - packager = None - - xlsx_file = ZipFile(self.filename, "w", compression=ZIP_DEFLATED, - allowZip64=self.allow_zip64) - - # Add XML sub-files to the Zip file with their Excel filename. - for os_filename, xml_filename, is_binary in xml_files: - if self.in_memory: - # The files are in-memory StringIOs. - if is_binary: - xlsx_file.writestr(xml_filename, os_filename.getvalue()) - else: - xlsx_file.writestr(xml_filename, - os_filename.getvalue().encode('utf-8')) - else: - # The files are tempfiles. - xlsx_file.write(os_filename, xml_filename) - os.remove(os_filename) - - xlsx_file.close() - - def _add_sheet(self, name, is_chartsheet): - # Utility for shared code in add_worksheet() and add_chartsheet(). - - sheet_index = len(self.worksheets_objs) - name = self._check_sheetname(name, is_chartsheet) - - # Initialisation data to pass to the worksheet. - init_data = { - 'name': name, - 'index': sheet_index, - 'str_table': self.str_table, - 'worksheet_meta': self.worksheet_meta, - 'optimization': self.optimization, - 'tmpdir': self.tmpdir, - 'date_1904': self.date_1904, - 'strings_to_numbers': self.strings_to_numbers, - 'strings_to_formulas': self.strings_to_formulas, - 'strings_to_urls': self.strings_to_urls, - 'nan_inf_to_errors': self.nan_inf_to_errors, - 'default_date_format': self.default_date_format, - 'default_url_format': self.default_url_format, - 'excel2003_style': self.excel2003_style, - } - - if is_chartsheet: - worksheet = Chartsheet() - else: - worksheet = Worksheet() - - worksheet._initialize(init_data) - - self.worksheets_objs.append(worksheet) - self.sheetnames.append(name) - - return worksheet - - def _check_sheetname(self, sheetname, is_chartsheet=False): - # Check for valid worksheet names. We check the length, if it contains - # any invalid chars and if the sheetname is unique in the workbook. - invalid_char = re.compile(r'[\[\]:*?/\\]') - - # Increment the Sheet/Chart number used for default sheet names below. - if is_chartsheet: - self.chartname_count += 1 - else: - self.sheetname_count += 1 - - # Supply default Sheet/Chart sheetname if none has been defined. - if sheetname is None: - if is_chartsheet: - sheetname = self.chart_name + str(self.chartname_count) - else: - sheetname = self.sheet_name + str(self.sheetname_count) - - # Check that sheet sheetname is <= 31. Excel limit. - if len(sheetname) > 31: - raise Exception("Excel worksheet name '%s' must be <= 31 chars." % - sheetname) - - # Check that sheetname doesn't contain any invalid characters - if invalid_char.search(sheetname): - raise Exception( - "Invalid Excel character '[]:*?/\\' in sheetname '%s'" % - sheetname) - - # Check that the worksheet name doesn't already exist since this is a - # fatal Excel error. The check must be case insensitive like Excel. - for worksheet in self.worksheets(): - if sheetname.lower() == worksheet.name.lower(): - raise Exception( - "Sheetname '%s', with case ignored, is already in use." % - sheetname) - - return sheetname - - def _prepare_format_properties(self): - # Prepare all Format properties prior to passing them to styles.py. - - # Separate format objects into XF and DXF formats. - self._prepare_formats() - - # Set the font index for the format objects. - self._prepare_fonts() - - # Set the number format index for the format objects. - self._prepare_num_formats() - - # Set the border index for the format objects. - self._prepare_borders() - - # Set the fill index for the format objects. - self._prepare_fills() - - def _prepare_formats(self): - # Iterate through the XF Format objects and separate them into - # XF and DXF formats. The XF and DF formats then need to be sorted - # back into index order rather than creation order. - xf_formats = [] - dxf_formats = [] - - # Sort into XF and DXF formats. - for xf_format in self.formats: - if xf_format.xf_index is not None: - xf_formats.append(xf_format) - - if xf_format.dxf_index is not None: - dxf_formats.append(xf_format) - - # Pre-extend the format lists. - self.xf_formats = [None] * len(xf_formats) - self.dxf_formats = [None] * len(dxf_formats) - - # Rearrange formats into index order. - for xf_format in xf_formats: - index = xf_format.xf_index - self.xf_formats[index] = xf_format - - for dxf_format in dxf_formats: - index = dxf_format.dxf_index - self.dxf_formats[index] = dxf_format - - def _set_default_xf_indices(self): - # Set the default index for each format. Only used for testing. - - formats = list(self.formats) - - # Delete the default url format. - del formats[1] - - # Skip the default date format if set. - if self.default_date_format is not None: - del formats[1] - - # Set the remaining formats. - for xf_format in formats: - xf_format._get_xf_index() - - def _prepare_fonts(self): - # Iterate through the XF Format objects and give them an index to - # non-default font elements. - fonts = {} - index = 0 - - for xf_format in self.xf_formats: - key = xf_format._get_font_key() - if key in fonts: - # Font has already been used. - xf_format.font_index = fonts[key] - xf_format.has_font = 0 - else: - # This is a new font. - fonts[key] = index - xf_format.font_index = index - xf_format.has_font = 1 - index += 1 - - self.font_count = index - - # For DXF formats we only need to check if the properties have changed. - for xf_format in self.dxf_formats: - # The only font properties that can change for a DXF format are: - # color, bold, italic, underline and strikethrough. - if (xf_format.font_color or xf_format.bold or xf_format.italic - or xf_format.underline or xf_format.font_strikeout): - xf_format.has_dxf_font = 1 - - def _prepare_num_formats(self): - # User defined records in Excel start from index 0xA4. - num_formats = {} - index = 164 - num_format_count = 0 - - for xf_format in (self.xf_formats + self.dxf_formats): - num_format = xf_format.num_format - - # Check if num_format is an index to a built-in number format. - if not isinstance(num_format, str_types): - xf_format.num_format_index = int(num_format) - continue - - if num_format in num_formats: - # Number xf_format has already been used. - xf_format.num_format_index = num_formats[num_format] - else: - # Add a new number xf_format. - num_formats[num_format] = index - xf_format.num_format_index = index - index += 1 - - # Only increase font count for XF formats (not DXF formats). - if xf_format.xf_index: - num_format_count += 1 - - self.num_format_count = num_format_count - - def _prepare_borders(self): - # Iterate through the XF Format objects and give them an index to - # non-default border elements. - borders = {} - index = 0 - - for xf_format in self.xf_formats: - key = xf_format._get_border_key() - - if key in borders: - # Border has already been used. - xf_format.border_index = borders[key] - xf_format.has_border = 0 - else: - # This is a new border. - borders[key] = index - xf_format.border_index = index - xf_format.has_border = 1 - index += 1 - - self.border_count = index - - # For DXF formats we only need to check if the properties have changed. - has_border = re.compile(r'[^0:]') - - for xf_format in self.dxf_formats: - key = xf_format._get_border_key() - - if has_border.search(key): - xf_format.has_dxf_border = 1 - - def _prepare_fills(self): - # Iterate through the XF Format objects and give them an index to - # non-default fill elements. - # The user defined fill properties start from 2 since there are 2 - # default fills: patternType="none" and patternType="gray125". - fills = {} - index = 2 # Start from 2. See above. - - # Add the default fills. - fills['0:0:0'] = 0 - fills['17:0:0'] = 1 - - # Store the DXF colors separately since them may be reversed below. - for xf_format in self.dxf_formats: - if xf_format.pattern or xf_format.bg_color or xf_format.fg_color: - xf_format.has_dxf_fill = 1 - xf_format.dxf_bg_color = xf_format.bg_color - xf_format.dxf_fg_color = xf_format.fg_color - - for xf_format in self.xf_formats: - # The following logical statements jointly take care of special - # cases in relation to cell colors and patterns: - # 1. For a solid fill (_pattern == 1) Excel reverses the role of - # foreground and background colors, and - # 2. If the user specifies a foreground or background color - # without a pattern they probably wanted a solid fill, so we fill - # in the defaults. - if (xf_format.pattern == 1 and xf_format.bg_color != 0 - and xf_format.fg_color != 0): - tmp = xf_format.fg_color - xf_format.fg_color = xf_format.bg_color - xf_format.bg_color = tmp - - if (xf_format.pattern <= 1 and xf_format.bg_color != 0 - and xf_format.fg_color == 0): - xf_format.fg_color = xf_format.bg_color - xf_format.bg_color = 0 - xf_format.pattern = 1 - - if (xf_format.pattern <= 1 and xf_format.bg_color == 0 - and xf_format.fg_color != 0): - xf_format.bg_color = 0 - xf_format.pattern = 1 - - key = xf_format._get_fill_key() - - if key in fills: - # Fill has already been used. - xf_format.fill_index = fills[key] - xf_format.has_fill = 0 - else: - # This is a new fill. - fills[key] = index - xf_format.fill_index = index - xf_format.has_fill = 1 - index += 1 - - self.fill_count = index - - def _prepare_defined_names(self): - # Iterate through the worksheets and store any defined names in - # addition to any user defined names. Stores the defined names - # for the Workbook.xml and the named ranges for App.xml. - defined_names = self.defined_names - - for sheet in self.worksheets(): - # Check for Print Area settings. - if sheet.autofilter_area: - hidden = 1 - sheet_range = sheet.autofilter_area - # Store the defined names. - defined_names.append(['_xlnm._FilterDatabase', - sheet.index, sheet_range, hidden]) - - # Check for Print Area settings. - if sheet.print_area_range: - hidden = 0 - sheet_range = sheet.print_area_range - # Store the defined names. - defined_names.append(['_xlnm.Print_Area', - sheet.index, sheet_range, hidden]) - - # Check for repeat rows/cols referred to as Print Titles. - if sheet.repeat_col_range or sheet.repeat_row_range: - hidden = 0 - sheet_range = '' - if sheet.repeat_col_range and sheet.repeat_row_range: - sheet_range = (sheet.repeat_col_range + ',' + - sheet.repeat_row_range) - else: - sheet_range = (sheet.repeat_col_range + - sheet.repeat_row_range) - # Store the defined names. - defined_names.append(['_xlnm.Print_Titles', - sheet.index, sheet_range, hidden]) - - defined_names = self._sort_defined_names(defined_names) - self.defined_names = defined_names - self.named_ranges = self._extract_named_ranges(defined_names) - - def _sort_defined_names(self, names): - # Sort the list of list of internal and user defined names in - # the same order as used by Excel. - - # Add a normalize name string to each list for sorting. - for name_list in names: - (defined_name, _, sheet_name, _) = name_list - - # Normalize the defined name by removing any leading '_xmln.' - # from internal names and lowercasing the string. - defined_name = defined_name.replace('_xlnm.', '').lower() - - # Normalize the sheetname by removing the leading quote and - # lowercasing the string. - sheet_name = sheet_name.lstrip("'").lower() - - name_list.append(defined_name + "::" + sheet_name) - - # Sort based on the normalized key. - names.sort(key=operator.itemgetter(4)) - - # Remove the extra key used for sorting. - for name_list in names: - name_list.pop() - - return names - - def _prepare_drawings(self): - # Iterate through the worksheets and set up chart and image drawings. - chart_ref_id = 0 - image_ref_id = 0 - drawing_id = 0 - x_dpi = 96 - y_dpi = 96 - - for sheet in self.worksheets(): - chart_count = len(sheet.charts) - image_count = len(sheet.images) - shape_count = len(sheet.shapes) - - header_image_count = len(sheet.header_images) - footer_image_count = len(sheet.footer_images) - has_drawing = False - - if not (chart_count or image_count or shape_count - or header_image_count or footer_image_count): - continue - - # Don't increase the drawing_id header/footer images. - if chart_count or image_count or shape_count: - drawing_id += 1 - has_drawing = True - - # Prepare the worksheet charts. - for index in range(chart_count): - chart_ref_id += 1 - sheet._prepare_chart(index, chart_ref_id, drawing_id) - - # Prepare the worksheet images. - for index in range(image_count): - filename = sheet.images[index][2] - image_data = sheet.images[index][10] - (image_type, width, height, name, x_dpi, y_dpi) = \ - self._get_image_properties(filename, image_data) - image_ref_id += 1 - - sheet._prepare_image(index, image_ref_id, drawing_id, width, - height, name, image_type, x_dpi, y_dpi) - - # Prepare the worksheet shapes. - for index in range(shape_count): - sheet._prepare_shape(index, drawing_id) - - # Prepare the header images. - for index in range(header_image_count): - - filename = sheet.header_images[index][0] - image_data = sheet.header_images[index][1] - position = sheet.header_images[index][2] - - (image_type, width, height, name, x_dpi, y_dpi) = \ - self._get_image_properties(filename, image_data) - - image_ref_id += 1 - - sheet._prepare_header_image(image_ref_id, width, height, - name, image_type, position, - x_dpi, y_dpi) - - # Prepare the footer images. - for index in range(footer_image_count): - - filename = sheet.footer_images[index][0] - image_data = sheet.footer_images[index][1] - position = sheet.footer_images[index][2] - - (image_type, width, height, name, x_dpi, y_dpi) = \ - self._get_image_properties(filename, image_data) - - image_ref_id += 1 - - sheet._prepare_header_image(image_ref_id, width, height, - name, image_type, position, - x_dpi, y_dpi) - - if has_drawing: - drawing = sheet.drawing - self.drawings.append(drawing) - - # Remove charts that were created but not inserted into worksheets. - for chart in self.charts[:]: - if chart.id == -1: - self.charts.remove(chart) - - # Sort the workbook charts references into the order that the were - # written to the worksheets above. - self.charts = sorted(self.charts, key=lambda chart: chart.id) - - self.drawing_count = drawing_id - - def _get_image_properties(self, filename, image_data): - # Extract dimension information from the image file. - height = 0 - width = 0 - x_dpi = 96 - y_dpi = 96 - - if not image_data: - # Open the image file and read in the data. - fh = open(filename, "rb") - data = fh.read() - else: - # Read the image data from the user supplied byte stream. - data = image_data.getvalue() - - # Get the image filename without the path. - image_name = os.path.basename(filename) - - # Look for some common image file markers. - marker1 = (unpack('3s', data[1:4]))[0] - marker2 = (unpack('>H', data[:2]))[0] - marker3 = (unpack('2s', data[:2]))[0] - - if sys.version_info < (2, 6, 0): - # Python 2.5/Jython. - png_marker = 'PNG' - bmp_marker = 'BM' - else: - # Eval the binary literals for Python 2.5/Jython compatibility. - png_marker = eval("b'PNG'") - bmp_marker = eval("b'BM'") - - if marker1 == png_marker: - self.image_types['png'] = 1 - (image_type, width, height, x_dpi, y_dpi) = self._process_png(data) - - elif marker2 == 0xFFD8: - self.image_types['jpeg'] = 1 - (image_type, width, height, x_dpi, y_dpi) = self._process_jpg(data) - - elif marker3 == bmp_marker: - self.image_types['bmp'] = 1 - (image_type, width, height) = self._process_bmp(data) - - else: - raise Exception("%s: Unknown or unsupported image file format." - % filename) - - # Check that we found the required data. - if not height or not width: - raise Exception("%s: no size data found in image file." % filename) - - # Store image data to copy it into file container. - self.images.append([filename, image_type, image_data]) - - if not image_data: - fh.close() - - return image_type, width, height, image_name, x_dpi, y_dpi - - def _process_png(self, data): - # Extract width and height information from a PNG file. - offset = 8 - data_length = len(data) - end_marker = False - width = 0 - height = 0 - x_dpi = 96 - y_dpi = 96 - - # Look for numbers rather than strings for Python 2.6/3 compatibility. - marker_ihdr = 0x49484452 # IHDR - marker_phys = 0x70485973 # pHYs - marker_iend = 0X49454E44 # IEND - - # Search through the image data to read the height and width in the - # IHDR element. Also read the DPI in the pHYs element. - while not end_marker and offset < data_length: - - length = (unpack('>I', data[offset + 0:offset + 4]))[0] - marker = (unpack('>I', data[offset + 4:offset + 8]))[0] - - # Read the image dimensions. - if marker == marker_ihdr: - width = (unpack('>I', data[offset + 8:offset + 12]))[0] - height = (unpack('>I', data[offset + 12:offset + 16]))[0] - - # Read the image DPI. - if marker == marker_phys: - x_density = (unpack('>I', data[offset + 8:offset + 12]))[0] - y_density = (unpack('>I', data[offset + 12:offset + 16]))[0] - units = (unpack('b', data[offset + 16:offset + 17]))[0] - - if units == 1: - x_dpi = x_density * 0.0254 - y_dpi = y_density * 0.0254 - - if marker == marker_iend: - end_marker = True - continue - - offset = offset + length + 12 - - return 'png', width, height, x_dpi, y_dpi - - def _process_jpg(self, data): - # Extract width and height information from a JPEG file. - offset = 2 - data_length = len(data) - end_marker = False - width = 0 - height = 0 - x_dpi = 96 - y_dpi = 96 - - # Search through the image data to read the height and width in the - # 0xFFC0/C2 element. Also read the DPI in the 0xFFE0 element. - while not end_marker and offset < data_length: - - marker = (unpack('>H', data[offset + 0:offset + 2]))[0] - length = (unpack('>H', data[offset + 2:offset + 4]))[0] - - # Read the image dimensions. - if marker == 0xFFC0 or marker == 0xFFC2: - height = (unpack('>H', data[offset + 5:offset + 7]))[0] - width = (unpack('>H', data[offset + 7:offset + 9]))[0] - - # Read the image DPI. - if marker == 0xFFE0: - units = (unpack('b', data[offset + 11:offset + 12]))[0] - x_density = (unpack('>H', data[offset + 12:offset + 14]))[0] - y_density = (unpack('>H', data[offset + 14:offset + 16]))[0] - - if units == 1: - x_dpi = x_density - y_dpi = y_density - - if units == 2: - x_dpi = x_density * 2.54 - y_dpi = y_density * 2.54 - - # Workaround for incorrect dpi. - if x_dpi == 1: - x_dpi = 96 - if y_dpi == 1: - y_dpi = 96 - - if marker == 0xFFDA: - end_marker = True - continue - - offset = offset + length + 2 - - return 'jpeg', width, height, x_dpi, y_dpi - - def _process_bmp(self, data): - # Extract width and height information from a BMP file. - width = (unpack('<L', data[18:22]))[0] - height = (unpack('<L', data[22:26]))[0] - return 'bmp', width, height - - def _extract_named_ranges(self, defined_names): - # Extract the named ranges from the sorted list of defined names. - # These are used in the App.xml file. - named_ranges = [] - - for defined_name in defined_names: - - name = defined_name[0] - index = defined_name[1] - sheet_range = defined_name[2] - - # Skip autoFilter ranges. - if name == '_xlnm._FilterDatabase': - continue - - # We are only interested in defined names with ranges. - if '!' in sheet_range: - sheet_name, _ = sheet_range.split('!', 1) - - # Match Print_Area and Print_Titles xlnm types. - if name.startswith('_xlnm.'): - xlnm_type = name.replace('_xlnm.', '') - name = sheet_name + '!' + xlnm_type - elif index != -1: - name = sheet_name + '!' + name - - named_ranges.append(name) - - return named_ranges - - def _get_sheet_index(self, sheetname): - # Convert a sheet name to its index. Return None otherwise. - sheetname = sheetname.strip("'") - - if sheetname in self.sheetnames: - return self.sheetnames.index(sheetname) - else: - return None - - def _prepare_vml(self): - # Iterate through the worksheets and set up the VML objects. - comment_id = 0 - vml_drawing_id = 0 - vml_data_id = 1 - vml_header_id = 0 - vml_shape_id = 1024 - vml_files = 0 - comment_files = 0 - has_button = False - - for sheet in self.worksheets(): - if not sheet.has_vml and not sheet.has_header_vml: - continue - - vml_files += 1 - - if sheet.has_vml: - if sheet.has_comments: - comment_files += 1 - comment_id += 1 - - vml_drawing_id += 1 - - count = sheet._prepare_vml_objects(vml_data_id, - vml_shape_id, - vml_drawing_id, - comment_id) - - # Each VML should start with a shape id incremented by 1024. - vml_data_id += 1 * int((1024 + count) / 1024) - vml_shape_id += 1024 * int((1024 + count) / 1024) - - if sheet.has_header_vml: - vml_header_id += 1 - vml_drawing_id += 1 - sheet._prepare_header_vml_objects(vml_header_id, - vml_drawing_id) - - self.num_vml_files = vml_files - self.num_comment_files = comment_files - - if len(sheet.buttons_list): - has_button = True - - # Set the sheet vba_codename if it has a button and the - # workbook has a vbaProject binary. - if self.vba_project and sheet.vba_codename is None: - sheet.set_vba_name() - - # Add a font format for cell comments. - if comment_files > 0: - xf = self.add_format({'font_name': 'Tahoma', 'font_size': 8, - 'color_indexed': 81, 'font_only': True}) - xf._get_xf_index() - - # Set the workbook vba_codename if one of the sheets has a button and - # the workbook has a vbaProject binary. - if has_button and self.vba_project and self.vba_codename is None: - self.set_vba_name() - - def _prepare_tables(self): - # Set the table ids for the worksheet tables. - table_id = 0 - seen = {} - - for sheet in self.worksheets(): - table_count = len(sheet.tables) - - if not table_count: - continue - - sheet._prepare_tables(table_id + 1, seen) - table_id += table_count - - def _add_chart_data(self): - # Add "cached" data to charts to provide the numCache and strCache - # data for series and title/axis ranges. - worksheets = {} - seen_ranges = {} - charts = [] - - # Map worksheet names to worksheet objects. - for worksheet in self.worksheets(): - worksheets[worksheet.name] = worksheet - - # Build a list of the worksheet charts including any combined charts. - for chart in self.charts: - charts.append(chart) - if chart.combined: - charts.append(chart.combined) - - for chart in charts: - - for c_range in chart.formula_ids.keys(): - r_id = chart.formula_ids[c_range] - - # Skip if the series has user defined data. - if chart.formula_data[r_id] is not None: - if (c_range not in seen_ranges - or seen_ranges[c_range] is None): - data = chart.formula_data[r_id] - seen_ranges[c_range] = data - continue - - # Check to see if the data is already cached locally. - if c_range in seen_ranges: - chart.formula_data[r_id] = seen_ranges[c_range] - continue - - # Convert the range formula to a sheet name and cell range. - (sheetname, cells) = self._get_chart_range(c_range) - - # Skip if we couldn't parse the formula. - if sheetname is None: - continue - - # Handle non-contiguous ranges like: - # (Sheet1!$A$1:$A$2,Sheet1!$A$4:$A$5). - # We don't try to parse them. We just return an empty list. - if sheetname.startswith('('): - chart.formula_data[r_id] = [] - seen_ranges[c_range] = [] - continue - - # Warn if the name is unknown since it indicates a user error - # in a chart series formula. - if sheetname not in worksheets: - warn("Unknown worksheet reference '%s' in range " - "'%s' passed to add_series()" - % (force_unicode(sheetname), force_unicode(c_range))) - chart.formula_data[r_id] = [] - seen_ranges[c_range] = [] - continue - - # Find the worksheet object based on the sheet name. - worksheet = worksheets[sheetname] - - # Get the data from the worksheet table. - data = worksheet._get_range_data(*cells) - - # TODO. Handle SST string ids if required. - - # Add the data to the chart. - chart.formula_data[r_id] = data - - # Store range data locally to avoid lookup if seen again. - seen_ranges[c_range] = data - - def _get_chart_range(self, c_range): - # Convert a range formula such as Sheet1!$B$1:$B$5 into a sheet name - # and cell range such as ( 'Sheet1', 0, 1, 4, 1 ). - - # Split the range formula into sheetname and cells at the last '!'. - pos = c_range.rfind('!') - if pos > 0: - sheetname = c_range[:pos] - cells = c_range[pos + 1:] - else: - return None, None - - # Split the cell range into 2 cells or else use single cell for both. - if cells.find(':') > 0: - (cell_1, cell_2) = cells.split(':', 1) - else: - (cell_1, cell_2) = (cells, cells) - - # Remove leading/trailing quotes and convert escaped quotes to single. - sheetname = sheetname.strip("'") - sheetname = sheetname.replace("''", "'") - - try: - # Get the row, col values from the Excel ranges. We do this in a - # try block for ranges that can't be parsed such as defined names. - (row_start, col_start) = xl_cell_to_rowcol(cell_1) - (row_end, col_end) = xl_cell_to_rowcol(cell_2) - except: - return None, None - - # We only handle 1D ranges. - if row_start != row_end and col_start != col_end: - return None, None - - return sheetname, [row_start, col_start, row_end, col_end] - - def _prepare_sst_string_data(self): - # Convert the SST string data from a dict to a list. - self.str_table._sort_string_data() - - ########################################################################### - # - # XML methods. - # - ########################################################################### - - def _write_workbook(self): - # Write <workbook> element. - - schema = 'http://schemas.openxmlformats.org' - xmlns = schema + '/spreadsheetml/2006/main' - xmlns_r = schema + '/officeDocument/2006/relationships' - - attributes = [ - ('xmlns', xmlns), - ('xmlns:r', xmlns_r), - ] - - self._xml_start_tag('workbook', attributes) - - def _write_file_version(self): - # Write the <fileVersion> element. - - app_name = 'xl' - last_edited = 4 - lowest_edited = 4 - rup_build = 4505 - - attributes = [ - ('appName', app_name), - ('lastEdited', last_edited), - ('lowestEdited', lowest_edited), - ('rupBuild', rup_build), - ] - - if self.vba_project: - attributes.append( - ('codeName', '{37E998C4-C9E5-D4B9-71C8-EB1FF731991C}')) - - self._xml_empty_tag('fileVersion', attributes) - - def _write_workbook_pr(self): - # Write <workbookPr> element. - default_theme_version = 124226 - attributes = [] - - if self.vba_codename: - attributes.append(('codeName', self.vba_codename)) - if self.date_1904: - attributes.append(('date1904', 1)) - - attributes.append(('defaultThemeVersion', default_theme_version)) - - self._xml_empty_tag('workbookPr', attributes) - - def _write_book_views(self): - # Write <bookViews> element. - self._xml_start_tag('bookViews') - self._write_workbook_view() - self._xml_end_tag('bookViews') - - def _write_workbook_view(self): - # Write <workbookView> element. - attributes = [ - ('xWindow', self.x_window), - ('yWindow', self.y_window), - ('windowWidth', self.window_width), - ('windowHeight', self.window_height), - ] - - # Store the tabRatio attribute when it isn't the default. - if self.tab_ratio != 500: - attributes.append(('tabRatio', self.tab_ratio)) - - # Store the firstSheet attribute when it isn't the default. - if self.worksheet_meta.firstsheet > 0: - firstsheet = self.worksheet_meta.firstsheet + 1 - attributes.append(('firstSheet', firstsheet)) - - # Store the activeTab attribute when it isn't the first sheet. - if self.worksheet_meta.activesheet > 0: - attributes.append(('activeTab', self.worksheet_meta.activesheet)) - - self._xml_empty_tag('workbookView', attributes) - - def _write_sheets(self): - # Write <sheets> element. - self._xml_start_tag('sheets') - - id_num = 1 - for worksheet in self.worksheets(): - self._write_sheet(worksheet.name, id_num, worksheet.hidden) - id_num += 1 - - self._xml_end_tag('sheets') - - def _write_sheet(self, name, sheet_id, hidden): - # Write <sheet> element. - attributes = [ - ('name', name), - ('sheetId', sheet_id), - ] - - if hidden: - attributes.append(('state', 'hidden')) - - attributes.append(('r:id', 'rId' + str(sheet_id))) - - self._xml_empty_tag('sheet', attributes) - - def _write_calc_pr(self): - # Write the <calcPr> element. - attributes = [('calcId', self.calc_id)] - - if self.calc_mode == 'manual': - attributes.append(('calcMode', self.calc_mode)) - attributes.append(('calcOnSave', "0")) - elif self.calc_mode == 'autoNoTable': - attributes.append(('calcMode', self.calc_mode)) - - if self.calc_on_load: - attributes.append(('fullCalcOnLoad', '1')) - - self._xml_empty_tag('calcPr', attributes) - - def _write_defined_names(self): - # Write the <definedNames> element. - if not self.defined_names: - return - - self._xml_start_tag('definedNames') - - for defined_name in self.defined_names: - self._write_defined_name(defined_name) - - self._xml_end_tag('definedNames') - - def _write_defined_name(self, defined_name): - # Write the <definedName> element. - name = defined_name[0] - sheet_id = defined_name[1] - sheet_range = defined_name[2] - hidden = defined_name[3] - - attributes = [('name', name)] - - if sheet_id != -1: - attributes.append(('localSheetId', sheet_id)) - if hidden: - attributes.append(('hidden', 1)) - - self._xml_data_element('definedName', sheet_range, attributes) - - -# A metadata class to share data between worksheets. -class WorksheetMeta(object): - """ - A class to track worksheets data such as the active sheet and the - first sheet. - - """ - - def __init__(self): - self.activesheet = 0 - self.firstsheet = 0
Binary file test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/workbook.pyc has changed
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/worksheet.py Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,6473 +0,0 @@ -############################################################################### -# -# Worksheet - A class for writing the Excel XLSX Worksheet file. -# -# Copyright 2013-2016, John McNamara, jmcnamara@cpan.org -# - -# Standard packages. -import re -import tempfile -import codecs -import os - -from warnings import warn - -# Standard packages in Python 2/3 compatibility mode. -from .compatibility import StringIO -from .compatibility import defaultdict -from .compatibility import namedtuple -from .compatibility import force_unicode -from .compatibility import num_types, str_types - -# Package imports. -from . import xmlwriter -from .format import Format -from .drawing import Drawing -from .shape import Shape -from .xmlwriter import XMLwriter -from .utility import xl_rowcol_to_cell -from .utility import xl_rowcol_to_cell_fast -from .utility import xl_cell_to_rowcol -from .utility import xl_col_to_name -from .utility import xl_range -from .utility import xl_color -from .utility import get_sparkline_style -from .utility import supported_datetime -from .utility import datetime_to_excel_datetime -from .utility import quote_sheetname - - -############################################################################### -# -# Decorator functions. -# -############################################################################### -def convert_cell_args(method): - """ - Decorator function to convert A1 notation in cell method calls - to the default row/col notation. - - """ - def cell_wrapper(self, *args, **kwargs): - - try: - # First arg is an int, default to row/col notation. - if len(args): - int(args[0]) - except ValueError: - # First arg isn't an int, convert to A1 notation. - new_args = list(xl_cell_to_rowcol(args[0])) - new_args.extend(args[1:]) - args = new_args - - return method(self, *args, **kwargs) - - return cell_wrapper - - -def convert_range_args(method): - """ - Decorator function to convert A1 notation in range method calls - to the default row/col notation. - - """ - def cell_wrapper(self, *args, **kwargs): - - try: - # First arg is an int, default to row/col notation. - if len(args): - int(args[0]) - except ValueError: - # First arg isn't an int, convert to A1 notation. - if ':' in args[0]: - cell_1, cell_2 = args[0].split(':') - row_1, col_1 = xl_cell_to_rowcol(cell_1) - row_2, col_2 = xl_cell_to_rowcol(cell_2) - else: - row_1, col_1 = xl_cell_to_rowcol(args[0]) - row_2, col_2 = row_1, col_1 - - new_args = [row_1, col_1, row_2, col_2] - new_args.extend(args[1:]) - args = new_args - - return method(self, *args, **kwargs) - - return cell_wrapper - - -def convert_column_args(method): - """ - Decorator function to convert A1 notation in columns method calls - to the default row/col notation. - - """ - def column_wrapper(self, *args, **kwargs): - - try: - # First arg is an int, default to row/col notation. - if len(args): - int(args[0]) - except ValueError: - # First arg isn't an int, convert to A1 notation. - cell_1, cell_2 = [col + '1' for col in args[0].split(':')] - _, col_1 = xl_cell_to_rowcol(cell_1) - _, col_2 = xl_cell_to_rowcol(cell_2) - new_args = [col_1, col_2] - new_args.extend(args[1:]) - args = new_args - - return method(self, *args, **kwargs) - - return column_wrapper - - -############################################################################### -# -# Named tuples used for cell types. -# -############################################################################### -cell_string_tuple = namedtuple('String', 'string, format') -cell_number_tuple = namedtuple('Number', 'number, format') -cell_blank_tuple = namedtuple('Blank', 'format') -cell_boolean_tuple = namedtuple('Boolean', 'boolean, format') -cell_formula_tuple = namedtuple('Formula', 'formula, format, value') -cell_arformula_tuple = namedtuple('ArrayFormula', - 'formula, format, value, range') - - -############################################################################### -# -# Worksheet Class definition. -# -############################################################################### -class Worksheet(xmlwriter.XMLwriter): - """ - A class for writing the Excel XLSX Worksheet file. - - """ - - ########################################################################### - # - # Public API. - # - ########################################################################### - - def __init__(self): - """ - Constructor. - - """ - - super(Worksheet, self).__init__() - - self.name = None - self.index = None - self.str_table = None - self.palette = None - self.optimization = 0 - self.tmpdir = None - self.is_chartsheet = False - - self.ext_sheets = [] - self.fileclosed = 0 - self.excel_version = 2007 - self.excel2003_style = False - - self.xls_rowmax = 1048576 - self.xls_colmax = 16384 - self.xls_strmax = 32767 - self.dim_rowmin = None - self.dim_rowmax = None - self.dim_colmin = None - self.dim_colmax = None - - self.colinfo = {} - self.selections = [] - self.hidden = 0 - self.active = 0 - self.tab_color = 0 - - self.panes = [] - self.active_pane = 3 - self.selected = 0 - - self.page_setup_changed = False - self.paper_size = 0 - self.orientation = 1 - - self.print_options_changed = False - self.hcenter = 0 - self.vcenter = 0 - self.print_gridlines = 0 - self.screen_gridlines = 1 - self.print_headers = 0 - - self.header_footer_changed = False - self.header = '' - self.footer = '' - self.header_footer_aligns = True - self.header_footer_scales = True - self.header_images = [] - self.footer_images = [] - self.header_images_list = [] - - self.margin_left = 0.7 - self.margin_right = 0.7 - self.margin_top = 0.75 - self.margin_bottom = 0.75 - self.margin_header = 0.3 - self.margin_footer = 0.3 - - self.repeat_row_range = '' - self.repeat_col_range = '' - self.print_area_range = '' - - self.page_order = 0 - self.black_white = 0 - self.draft_quality = 0 - self.print_comments = 0 - self.page_start = 0 - - self.fit_page = 0 - self.fit_width = 0 - self.fit_height = 0 - - self.hbreaks = [] - self.vbreaks = [] - - self.protect_options = {} - self.set_cols = {} - self.set_rows = defaultdict(dict) - - self.zoom = 100 - self.zoom_scale_normal = 1 - self.print_scale = 100 - self.is_right_to_left = 0 - self.show_zeros = 1 - self.leading_zeros = 0 - - self.outline_row_level = 0 - self.outline_col_level = 0 - self.outline_style = 0 - self.outline_below = 1 - self.outline_right = 1 - self.outline_on = 1 - self.outline_changed = False - - self.original_row_height = 15 - self.default_row_height = 15 - self.default_row_pixels = 20 - self.default_col_pixels = 64 - self.default_row_zeroed = 0 - - self.names = {} - self.write_match = [] - self.table = defaultdict(dict) - self.merge = [] - self.row_spans = {} - - self.has_vml = False - self.has_header_vml = False - self.has_comments = False - self.comments = defaultdict(dict) - self.comments_list = [] - self.comments_author = '' - self.comments_visible = 0 - self.vml_shape_id = 1024 - self.buttons_list = [] - self.vml_header_id = 0 - - self.autofilter_area = '' - self.autofilter_ref = None - self.filter_range = [] - self.filter_on = 0 - self.filter_range = [] - self.filter_cols = {} - self.filter_type = {} - - self.col_sizes = {} - self.row_sizes = {} - self.col_formats = {} - self.col_size_changed = False - self.row_size_changed = False - - self.last_shape_id = 1 - self.rel_count = 0 - self.hlink_count = 0 - self.hlink_refs = [] - self.external_hyper_links = [] - self.external_drawing_links = [] - self.external_comment_links = [] - self.external_vml_links = [] - self.external_table_links = [] - self.drawing_links = [] - self.vml_drawing_links = [] - self.charts = [] - self.images = [] - self.tables = [] - self.sparklines = [] - self.shapes = [] - self.shape_hash = {} - self.drawing = 0 - - self.rstring = '' - self.previous_row = 0 - - self.validations = [] - self.cond_formats = {} - self.dxf_priority = 1 - self.is_chartsheet = 0 - self.page_view = 0 - - self.vba_codename = None - - self.date_1904 = False - self.hyperlinks = defaultdict(dict) - - self.strings_to_numbers = False - self.strings_to_urls = True - self.nan_inf_to_errors = False - self.strings_to_formulas = True - - self.default_date_format = None - self.default_url_format = None - - self.row_data_filename = None - self.row_data_fh = None - self.worksheet_meta = None - self.vml_data_id = None - self.vml_shape_id = None - - self.row_data_filename = None - self.row_data_fh = None - self.row_data_fh_closed = False - - self.vertical_dpi = 0 - self.horizontal_dpi = 0 - - @convert_cell_args - def write(self, row, col, *args): - """ - Write data to a worksheet cell by calling the appropriate write_*() - method based on the type of data being passed. - - Args: - row: The cell row (zero indexed). - col: The cell column (zero indexed). - *args: Args to pass to sub functions. - - Returns: - 0: Success. - -1: Row or column is out of worksheet bounds. - other: Return value of called method. - - """ - # Check the number of args passed. - if not len(args): - raise TypeError("write() takes at least 4 arguments (3 given)") - - # The first arg should be the token for all write calls. - token = args[0] - - # Write None as a blank cell. - if token is None: - return self.write_blank(row, col, *args) - - # Write boolean types. - if isinstance(token, bool): - return self.write_boolean(row, col, *args) - - # Write datetime objects. - if supported_datetime(token): - return self.write_datetime(row, col, *args) - - # Write number types. - if isinstance(token, num_types): - return self.write_number(row, col, *args) - - # Write string types. - if isinstance(token, str_types): - # Map the data to the appropriate write_*() method. - if token == '': - return self.write_blank(row, col, *args) - - elif self.strings_to_formulas and token.startswith('='): - return self.write_formula(row, col, *args) - - elif self.strings_to_urls and re.match('(ftp|http)s?://', token): - return self.write_url(row, col, *args) - - elif self.strings_to_urls and re.match('mailto:', token): - return self.write_url(row, col, *args) - - elif self.strings_to_urls and re.match('(in|ex)ternal:', token): - return self.write_url(row, col, *args) - - elif self.strings_to_numbers: - try: - f = float(token) - if (self.nan_inf_to_errors or - (not self._isnan(f) and not self._isinf(f))): - return self.write_number(row, col, f, *args[1:]) - except ValueError: - # Not a number, write as a string. - pass - - return self.write_string(row, col, *args) - - else: - # We have a plain string. - return self.write_string(row, col, *args) - - # We haven't matched a supported type. Try float. - try: - f = float(token) - return self.write_number(row, col, f, *args[1:]) - except ValueError: - pass - except TypeError: - raise TypeError("Unsupported type %s in write()" % type(token)) - - # Finally try string. - try: - str(token) - return self.write_string(row, col, *args) - except ValueError: - raise TypeError("Unsupported type %s in write()" % type(token)) - - @convert_cell_args - def write_string(self, row, col, string, cell_format=None): - """ - Write a string to a worksheet cell. - - Args: - row: The cell row (zero indexed). - col: The cell column (zero indexed). - string: Cell data. Str. - format: An optional cell Format object. - - Returns: - 0: Success. - -1: Row or column is out of worksheet bounds. - -2: String truncated to 32k characters. - - """ - str_error = 0 - - # Check that row and col are valid and store max and min values. - if self._check_dimensions(row, col): - return -1 - - # Check that the string is < 32767 chars. - if len(string) > self.xls_strmax: - string = string[:self.xls_strmax] - str_error = -2 - - # Write a shared string or an in-line string in optimisation mode. - if self.optimization == 0: - string_index = self.str_table._get_shared_string_index(string) - else: - string_index = string - - # Write previous row if in in-line string optimization mode. - if self.optimization and row > self.previous_row: - self._write_single_row(row) - - # Store the cell data in the worksheet data table. - self.table[row][col] = cell_string_tuple(string_index, cell_format) - - return str_error - - @convert_cell_args - def write_number(self, row, col, number, cell_format=None): - """ - Write a number to a worksheet cell. - - Args: - row: The cell row (zero indexed). - col: The cell column (zero indexed). - number: Cell data. Int or float. - cell_format: An optional cell Format object. - - Returns: - 0: Success. - -1: Row or column is out of worksheet bounds. - - """ - if self._isnan(number) or self._isinf(number): - if self.nan_inf_to_errors: - if self._isnan(number): - return self.write_formula(row, col, '#NUM!', cell_format, - '#NUM!') - elif self._isinf(number): - return self.write_formula(row, col, '1/0', cell_format, - '#DIV/0!') - else: - raise TypeError( - "NAN/INF not supported in write_number() " - "without 'nan_inf_to_errors' Workbook() option") - - # Check that row and col are valid and store max and min values. - if self._check_dimensions(row, col): - return -1 - - # Write previous row if in in-line string optimization mode. - if self.optimization and row > self.previous_row: - self._write_single_row(row) - - # Store the cell data in the worksheet data table. - self.table[row][col] = cell_number_tuple(number, cell_format) - - return 0 - - @convert_cell_args - def write_blank(self, row, col, blank, cell_format=None): - """ - Write a blank cell with formatting to a worksheet cell. The blank - token is ignored and the format only is written to the cell. - - Args: - row: The cell row (zero indexed). - col: The cell column (zero indexed). - blank: Any value. It is ignored. - cell_format: An optional cell Format object. - - Returns: - 0: Success. - -1: Row or column is out of worksheet bounds. - - """ - # Don't write a blank cell unless it has a format. - if cell_format is None: - return 0 - - # Check that row and col are valid and store max and min values. - if self._check_dimensions(row, col): - return -1 - - # Write previous row if in in-line string optimization mode. - if self.optimization and row > self.previous_row: - self._write_single_row(row) - - # Store the cell data in the worksheet data table. - self.table[row][col] = cell_blank_tuple(cell_format) - - return 0 - - @convert_cell_args - def write_formula(self, row, col, formula, cell_format=None, value=0): - """ - Write a formula to a worksheet cell. - - Args: - row: The cell row (zero indexed). - col: The cell column (zero indexed). - formula: Cell formula. - cell_format: An optional cell Format object. - value: An optional value for the formula. Default is 0. - - Returns: - 0: Success. - -1: Row or column is out of worksheet bounds. - - """ - # Check that row and col are valid and store max and min values. - if self._check_dimensions(row, col): - return -1 - - # Hand off array formulas. - if formula.startswith('{') and formula.endswith('}'): - return self.write_array_formula(row, col, row, col, formula, - cell_format, value) - - # Remove the formula '=' sign if it exists. - if formula.startswith('='): - formula = formula.lstrip('=') - - # Write previous row if in in-line string optimization mode. - if self.optimization and row > self.previous_row: - self._write_single_row(row) - - # Store the cell data in the worksheet data table. - self.table[row][col] = cell_formula_tuple(formula, cell_format, value) - - return 0 - - @convert_range_args - def write_array_formula(self, first_row, first_col, last_row, last_col, - formula, cell_format=None, value=0): - """ - Write a formula to a worksheet cell. - - Args: - first_row: The first row of the cell range. (zero indexed). - first_col: The first column of the cell range. - last_row: The last row of the cell range. (zero indexed). - last_col: The last column of the cell range. - formula: Cell formula. - cell_format: An optional cell Format object. - value: An optional value for the formula. Default is 0. - - Returns: - 0: Success. - -1: Row or column is out of worksheet bounds. - - """ - - # Swap last row/col with first row/col as necessary. - if first_row > last_row: - first_row, last_row = last_row, first_row - if first_col > last_col: - first_col, last_col = last_col, first_col - - # Check that row and col are valid and store max and min values - if self._check_dimensions(last_row, last_col): - return -1 - - # Define array range - if first_row == last_row and first_col == last_col: - cell_range = xl_rowcol_to_cell(first_row, first_col) - else: - cell_range = (xl_rowcol_to_cell(first_row, first_col) + ':' - + xl_rowcol_to_cell(last_row, last_col)) - - # Remove array formula braces and the leading =. - if formula[0] == '{': - formula = formula[1:] - if formula[0] == '=': - formula = formula[1:] - if formula[-1] == '}': - formula = formula[:-1] - - # Write previous row if in in-line string optimization mode. - if self.optimization and first_row > self.previous_row: - self._write_single_row(first_row) - - # Store the cell data in the worksheet data table. - self.table[first_row][first_col] = cell_arformula_tuple(formula, - cell_format, - value, - cell_range) - - # Pad out the rest of the area with formatted zeroes. - if not self.optimization: - for row in range(first_row, last_row + 1): - for col in range(first_col, last_col + 1): - if row != first_row or col != first_col: - self.write_number(row, col, 0, cell_format) - - return 0 - - @convert_cell_args - def write_datetime(self, row, col, date, cell_format=None): - """ - Write a date or time to a worksheet cell. - - Args: - row: The cell row (zero indexed). - col: The cell column (zero indexed). - date: Date and/or time as a datetime object. - cell_format: A cell Format object. - - Returns: - 0: Success. - -1: Row or column is out of worksheet bounds. - - """ - # Check that row and col are valid and store max and min values. - if self._check_dimensions(row, col): - return -1 - - # Write previous row if in in-line string optimization mode. - if self.optimization and row > self.previous_row: - self._write_single_row(row) - - # Convert datetime to an Excel date. - number = self._convert_date_time(date) - - # Add the default date format. - if cell_format is None: - cell_format = self.default_date_format - - # Store the cell data in the worksheet data table. - self.table[row][col] = cell_number_tuple(number, cell_format) - - return 0 - - @convert_cell_args - def write_boolean(self, row, col, boolean, cell_format=None): - """ - Write a boolean value to a worksheet cell. - - Args: - row: The cell row (zero indexed). - col: The cell column (zero indexed). - boolean: Cell data. bool type. - cell_format: An optional cell Format object. - - Returns: - 0: Success. - -1: Row or column is out of worksheet bounds. - - """ - # Check that row and col are valid and store max and min values. - if self._check_dimensions(row, col): - return -1 - - # Write previous row if in in-line string optimization mode. - if self.optimization and row > self.previous_row: - self._write_single_row(row) - - if boolean: - value = 1 - else: - value = 0 - - # Store the cell data in the worksheet data table. - self.table[row][col] = cell_boolean_tuple(value, cell_format) - - return 0 - - # Write a hyperlink. This is comprised of two elements: the displayed - # string and the non-displayed link. The displayed string is the same as - # the link unless an alternative string is specified. The display string - # is written using the write_string() method. Therefore the max characters - # string limit applies. - # - # The hyperlink can be to a http, ftp, mail, internal sheet, or external - # directory urls. - @convert_cell_args - def write_url(self, row, col, url, cell_format=None, - string=None, tip=None): - """ - Write a hyperlink to a worksheet cell. - - Args: - row: The cell row (zero indexed). - col: The cell column (zero indexed). - url: Hyperlink url. - format: An optional cell Format object. - string: An optional display string for the hyperlink. - tip: An optional tooltip. - Returns: - 0: Success. - -1: Row or column is out of worksheet bounds. - -2: String longer than 32767 characters. - -3: URL longer than Excel limit of 255 characters - -4: Exceeds Excel limit of 65,530 urls per worksheet - """ - # Set the displayed string to the URL unless defined by the user. - if string is None: - string = url - - # Default to external link type such as 'http://' or 'external:'. - link_type = 1 - - # Remove the URI scheme from internal links. - if re.match("internal:", url): - url = url.replace('internal:', '') - string = string.replace('internal:', '') - link_type = 2 - - # Remove the URI scheme from external links and change the directory - # separator from Unix to Dos. - if re.match("external:", url): - url = url.replace('external:', '') - url = url.replace('/', '\\') - string = string.replace('external:', '') - string = string.replace('/', '\\') - - # Strip the mailto header. - string = string.replace('mailto:', '') - - # Check that row and col are valid and store max and min values - if self._check_dimensions(row, col): - return -1 - - # Check that the string is < 32767 chars - str_error = 0 - if len(string) > self.xls_strmax: - warn("Ignoring URL since it exceeds Excel's string limit of " - "32767 characters") - return -2 - - # Copy string for use in hyperlink elements. - url_str = string - - # External links to URLs and to other Excel workbooks have slightly - # different characteristics that we have to account for. - if link_type == 1: - # Escape URL unless it looks already escaped. - if not re.search('%[0-9a-fA-F]{2}', url): - # Can't use url.quote() here because it doesn't match Excel. - url = url.replace('%', '%25') - url = url.replace('"', '%22') - url = url.replace(' ', '%20') - url = url.replace('<', '%3c') - url = url.replace('>', '%3e') - url = url.replace('[', '%5b') - url = url.replace(']', '%5d') - url = url.replace('^', '%5e') - url = url.replace('`', '%60') - url = url.replace('{', '%7b') - url = url.replace('}', '%7d') - - # Split url into the link and optional anchor/location. - if '#' in url: - url, url_str = url.split('#', 1) - else: - url_str = None - - # Add the file:/// URI to the url for Windows style "C:/" link and - # Network shares. - if re.match('\w:', url) or re.match(r'\\', url): - url = 'file:///' + url - - # Convert a .\dir\file.xlsx link to dir\file.xlsx. - url = re.sub(r'^\.\\', '', url) - - # Excel limits the escaped URL and location/anchor to 255 characters. - tmp_url_str = url_str or '' - if len(url) > 255 or len(tmp_url_str) > 255: - warn("Ignoring URL '%s' with link or location/anchor > 255 " - "characters since it exceeds Excel's limit for URLS" % - force_unicode(url)) - return -3 - - # Check the limit of URLS per worksheet. - self.hlink_count += 1 - - if self.hlink_count > 65530: - warn("Ignoring URL '%s' since it exceeds Excel's limit of " - "65,530 URLS per worksheet." % force_unicode(url)) - return -5 - - # Write previous row if in in-line string optimization mode. - if self.optimization == 1 and row > self.previous_row: - self._write_single_row(row) - - # Add the default URL format. - if cell_format is None: - cell_format = self.default_url_format - - # Write the hyperlink string. - self.write_string(row, col, string, cell_format) - - # Store the hyperlink data in a separate structure. - self.hyperlinks[row][col] = { - 'link_type': link_type, - 'url': url, - 'str': url_str, - 'tip': tip} - - return str_error - - @convert_cell_args - def write_rich_string(self, row, col, *args): - """ - Write a "rich" string with multiple formats to a worksheet cell. - - Args: - row: The cell row (zero indexed). - col: The cell column (zero indexed). - string_parts: String and format pairs. - cell_format: Optional Format object. - - Returns: - 0: Success. - -1: Row or column is out of worksheet bounds. - -2: String truncated to 32k characters. - -3: 2 consecutive formats used. - - """ - tokens = list(args) - cell_format = None - str_length = 0 - string_index = 0 - - # Check that row and col are valid and store max and min values - if self._check_dimensions(row, col): - return -1 - - # If the last arg is a format we use it as the cell format. - if isinstance(tokens[-1], Format): - cell_format = tokens.pop() - - # Create a temp XMLWriter object and use it to write the rich string - # XML to a string. - fh = StringIO() - self.rstring = XMLwriter() - self.rstring._set_filehandle(fh) - - # Create a temp format with the default font for unformatted fragments. - default = Format() - - # Convert list of format, string tokens to pairs of (format, string) - # except for the first string fragment which doesn't require a default - # formatting run. Use the default for strings without a leading format. - fragments = [] - previous = 'format' - pos = 0 - - for token in tokens: - if not isinstance(token, Format): - # Token is a string. - if previous != 'format': - # If previous token wasn't a format add one before string. - fragments.append(default) - fragments.append(token) - else: - # If previous token was a format just add the string. - fragments.append(token) - - # Keep track of actual string str_length. - str_length += len(token) - previous = 'string' - else: - # Can't allow 2 formats in a row. - if previous == 'format' and pos > 0: - return -3 - - # Token is a format object. Add it to the fragment list. - fragments.append(token) - previous = 'format' - - pos += 1 - - # If the first token is a string start the <r> element. - if not isinstance(fragments[0], Format): - self.rstring._xml_start_tag('r') - - # Write the XML elements for the $format $string fragments. - for token in fragments: - if isinstance(token, Format): - # Write the font run. - self.rstring._xml_start_tag('r') - self._write_font(token) - else: - # Write the string fragment part, with whitespace handling. - attributes = [] - - if re.search('^\s', token) or re.search('\s$', token): - attributes.append(('xml:space', 'preserve')) - - self.rstring._xml_data_element('t', token, attributes) - self.rstring._xml_end_tag('r') - - # Read the in-memory string. - string = self.rstring.fh.getvalue() - - # Check that the string is < 32767 chars. - if str_length > self.xls_strmax: - return -2 - - # Write a shared string or an in-line string in optimisation mode. - if self.optimization == 0: - string_index = self.str_table._get_shared_string_index(string) - else: - string_index = string - - # Write previous row if in in-line string optimization mode. - if self.optimization and row > self.previous_row: - self._write_single_row(row) - - # Store the cell data in the worksheet data table. - self.table[row][col] = cell_string_tuple(string_index, cell_format) - - return 0 - - @convert_cell_args - def write_row(self, row, col, data, cell_format=None): - """ - Write a row of data starting from (row, col). - - Args: - row: The cell row (zero indexed). - col: The cell column (zero indexed). - data: A list of tokens to be written with write(). - format: An optional cell Format object. - Returns: - 0: Success. - other: Return value of write() method. - - """ - for token in data: - error = self.write(row, col, token, cell_format) - if error: - return error - col += 1 - - return 0 - - @convert_cell_args - def write_column(self, row, col, data, cell_format=None): - """ - Write a column of data starting from (row, col). - - Args: - row: The cell row (zero indexed). - col: The cell column (zero indexed). - data: A list of tokens to be written with write(). - format: An optional cell Format object. - Returns: - 0: Success. - other: Return value of write() method. - - """ - for token in data: - error = self.write(row, col, token, cell_format) - if error: - return error - row += 1 - - return 0 - - @convert_cell_args - def insert_image(self, row, col, filename, options={}): - """ - Insert an image with its top-left corner in a worksheet cell. - Args: - row: The cell row (zero indexed). - col: The cell column (zero indexed). - filename: Path and filename for image in PNG, JPG or BMP format. - options: Position, scale, url and data stream of the image. - Returns: - 0: Success. - """ - x_offset = options.get('x_offset', 0) - y_offset = options.get('y_offset', 0) - x_scale = options.get('x_scale', 1) - y_scale = options.get('y_scale', 1) - url = options.get('url', None) - tip = options.get('tip', None) - anchor = options.get('positioning', None) - image_data = options.get('image_data', None) - - if not image_data and not os.path.exists(filename): - warn("Image file '%s' not found." % force_unicode(filename)) - return -1 - - self.images.append([row, col, filename, x_offset, y_offset, - x_scale, y_scale, url, tip, anchor, image_data]) - - @convert_cell_args - def insert_textbox(self, row, col, text, options=None): - """ - Insert an textbox with its top-left corner in a worksheet cell. - Args: - row: The cell row (zero indexed). - col: The cell column (zero indexed). - text: The text for the textbox. - options: Textbox options. - Returns: - 0: Success. - """ - if options is None: - options = {} - - x_offset = options.get('x_offset', 0) - y_offset = options.get('y_offset', 0) - x_scale = options.get('x_scale', 1) - y_scale = options.get('y_scale', 1) - - self.shapes.append([row, col, x_offset, y_offset, - x_scale, y_scale, text, options]) - - @convert_cell_args - def insert_chart(self, row, col, chart, options={}): - """ - Insert an chart with its top-left corner in a worksheet cell. - Args: - row: The cell row (zero indexed). - col: The cell column (zero indexed). - chart: Chart object. - options: Position and scale of the chart. - - Returns: - 0: Success. - """ - - # Ensure a chart isn't inserted more than once. - if (chart.already_inserted or chart.combined - and chart.combined.already_inserted): - - warn('Chart cannot be inserted in a worksheet more than once.') - return - else: - chart.already_inserted = True - - if chart.combined: - chart.combined.already_inserted = True - - x_offset = options.get('x_offset', 0) - y_offset = options.get('y_offset', 0) - x_scale = options.get('x_scale', 1) - y_scale = options.get('y_scale', 1) - - # Allow Chart to override the scale and offset. - if chart.x_scale != 1: - x_scale = chart.x_scale - - if chart.y_scale != 1: - y_scale = chart.y_scale - - if chart.x_offset: - x_offset = chart.x_offset - - if chart.y_offset: - y_offset = chart.y_offset - - self.charts.append([row, col, chart, - x_offset, y_offset, - x_scale, y_scale]) - - @convert_cell_args - def write_comment(self, row, col, comment, options={}): - """ - Write a comment to a worksheet cell. - - Args: - row: The cell row (zero indexed). - col: The cell column (zero indexed). - comment: Cell comment. Str. - options: Comment formatting options. - - Returns: - 0: Success. - -1: Row or column is out of worksheet bounds. - -2: String longer than 32k characters. - - """ - # Check that row and col are valid and store max and min values - if self._check_dimensions(row, col): - return -1 - - # Check that the comment string is < 32767 chars. - if len(comment) > self.xls_strmax: - return -2 - - self.has_vml = 1 - self.has_comments = 1 - - # Process the properties of the cell comment. - self.comments[row][col] = \ - self._comment_params(row, col, comment, options) - - def show_comments(self): - """ - Make any comments in the worksheet visible. - - Args: - None. - - Returns: - Nothing. - - """ - self.comments_visible = 1 - - def set_comments_author(self, author): - """ - Set the default author of the cell comments. - - Args: - author: Comment author name. String. - - Returns: - Nothing. - - """ - self.comments_author = author - - def get_name(self): - """ - Retrieve the worksheet name. - - Args: - None. - - Returns: - Nothing. - - """ - # There is no set_name() method. Name must be set in add_worksheet(). - return self.name - - def activate(self): - """ - Set this worksheet as the active worksheet, i.e. the worksheet that is - displayed when the workbook is opened. Also set it as selected. - - Note: An active worksheet cannot be hidden. - - Args: - None. - - Returns: - Nothing. - - """ - self.hidden = 0 - self.selected = 1 - self.worksheet_meta.activesheet = self.index - - def select(self): - """ - Set current worksheet as a selected worksheet, i.e. the worksheet - has its tab highlighted. - - Note: A selected worksheet cannot be hidden. - - Args: - None. - - Returns: - Nothing. - - """ - self.selected = 1 - self.hidden = 0 - - def hide(self): - """ - Hide the current worksheet. - - Args: - None. - - Returns: - Nothing. - - """ - self.hidden = 1 - - # A hidden worksheet shouldn't be active or selected. - self.selected = 0 - - # TODO. Should add a check to see if the sheet is the global - # activesheet or firstsheet and reset them. - - def set_first_sheet(self): - """ - Set current worksheet as the first visible sheet. This is necessary - when there are a large number of worksheets and the activated - worksheet is not visible on the screen. - - Note: A selected worksheet cannot be hidden. - - Args: - None. - - Returns: - Nothing. - - """ - self.hidden = 0 # Active worksheet can't be hidden. - self.worksheet_meta.firstsheet = self.index - - @convert_column_args - def set_column(self, firstcol, lastcol, width=None, cell_format=None, - options={}): - """ - Set the width, and other properties of a single column or a - range of columns. - - Args: - firstcol: First column (zero-indexed). - lastcol: Last column (zero-indexed). Can be same as firstcol. - width: Column width. (optional). - cell_format: Column cell_format. (optional). - options: Dict of options such as hidden and level. - - Returns: - 0: Success. - -1: Column number is out of worksheet bounds. - - """ - # Ensure 2nd col is larger than first. - if firstcol > lastcol: - (firstcol, lastcol) = (lastcol, firstcol) - - # Don't modify the row dimensions when checking the columns. - ignore_row = True - - # Set optional column values. - hidden = options.get('hidden', False) - collapsed = options.get('collapsed', False) - level = options.get('level', 0) - # Store the column dimension only in some conditions. - if cell_format or (width and hidden): - ignore_col = False - else: - ignore_col = True - - # Check that each column is valid and store the max and min values. - if self._check_dimensions(0, lastcol, ignore_row, ignore_col): - return -1 - if self._check_dimensions(0, firstcol, ignore_row, ignore_col): - return -1 - - # Set the limits for the outline levels (0 <= x <= 7). - if level < 0: - level = 0 - if level > 7: - level = 7 - - if level > self.outline_col_level: - self.outline_col_level = level - - # Store the column data. Padded for sorting. - self.colinfo["%05d" % firstcol] = [firstcol, lastcol, width, - cell_format, hidden, level, - collapsed] - - # Store the column change to allow optimizations. - self.col_size_changed = True - - # Store the col sizes for use when calculating image vertices taking - # hidden columns into account. Also store the column formats. - - # Set width to zero if col is hidden - if hidden: - width = 0 - - for col in range(firstcol, lastcol + 1): - self.col_sizes[col] = width - if cell_format: - self.col_formats[col] = cell_format - - return 0 - - def set_row(self, row, height=None, cell_format=None, options={}): - """ - Set the width, and other properties of a row. - - Args: - row: Row number (zero-indexed). - height: Row width. (optional). - cell_format: Row cell_format. (optional). - options: Dict of options such as hidden, level and collapsed. - - Returns: - 0: Success. - -1: Row number is out of worksheet bounds. - - """ - # Use minimum col in _check_dimensions(). - if self.dim_colmin is not None: - min_col = self.dim_colmin - else: - min_col = 0 - - # Check that row is valid. - if self._check_dimensions(row, min_col): - return -1 - - if height is None: - height = self.default_row_height - - # Set optional row values. - hidden = options.get('hidden', False) - collapsed = options.get('collapsed', False) - level = options.get('level', 0) - - # If the height is 0 the row is hidden and the height is the default. - if height == 0: - hidden = 1 - height = self.default_row_height - - # Set the limits for the outline levels (0 <= x <= 7). - if level < 0: - level = 0 - if level > 7: - level = 7 - - if level > self.outline_row_level: - self.outline_row_level = level - - # Store the row properties. - self.set_rows[row] = [height, cell_format, hidden, level, collapsed] - - # Store the row change to allow optimizations. - self.row_size_changed = True - - if hidden: - height = 0 - - # Store the row sizes for use when calculating image vertices. - self.row_sizes[row] = height - - def set_default_row(self, height=None, hide_unused_rows=False): - """ - Set the default row properties. - - Args: - height: Default height. Optional, defaults to 15. - hide_unused_rows: Hide unused rows. Optional, defaults to False. - - Returns: - Nothing. - - """ - if height is None: - height = self.default_row_height - - if height != self.original_row_height: - # Store the row change to allow optimizations. - self.row_size_changed = True - self.default_row_height = height - - if hide_unused_rows: - self.default_row_zeroed = 1 - - @convert_range_args - def merge_range(self, first_row, first_col, last_row, last_col, - data, cell_format=None): - """ - Merge a range of cells. - - Args: - first_row: The first row of the cell range. (zero indexed). - first_col: The first column of the cell range. - last_row: The last row of the cell range. (zero indexed). - last_col: The last column of the cell range. - data: Cell data. - cell_format: Cell Format object. - - Returns: - 0: Success. - -1: Row or column is out of worksheet bounds. - other: Return value of write(). - - """ - # Merge a range of cells. The first cell should contain the data and - # the others should be blank. All cells should have the same format. - - # Excel doesn't allow a single cell to be merged - if first_row == last_row and first_col == last_col: - warn("Can't merge single cell") - return - - # Swap last row/col with first row/col as necessary - if first_row > last_row: - (first_row, last_row) = (last_row, first_row) - if first_col > last_col: - (first_col, last_col) = (last_col, first_col) - - # Check that column number is valid and store the max value - if self._check_dimensions(last_row, last_col) == -1: - return - - # Store the merge range. - self.merge.append([first_row, first_col, last_row, last_col]) - - # Write the first cell - self.write(first_row, first_col, data, cell_format) - - # Pad out the rest of the area with formatted blank cells. - for row in range(first_row, last_row + 1): - for col in range(first_col, last_col + 1): - if row == first_row and col == first_col: - continue - self.write_blank(row, col, '', cell_format) - - @convert_range_args - def autofilter(self, first_row, first_col, last_row, last_col): - """ - Set the autofilter area in the worksheet. - - Args: - first_row: The first row of the cell range. (zero indexed). - first_col: The first column of the cell range. - last_row: The last row of the cell range. (zero indexed). - last_col: The last column of the cell range. - - Returns: - Nothing. - - """ - # Reverse max and min values if necessary. - if last_row < first_row: - (first_row, last_row) = (last_row, first_row) - if last_col < first_col: - (first_col, last_col) = (last_col, first_col) - - # Build up the print area range "Sheet1!$A$1:$C$13". - area = self._convert_name_area(first_row, first_col, - last_row, last_col) - ref = xl_range(first_row, first_col, last_row, last_col) - - self.autofilter_area = area - self.autofilter_ref = ref - self.filter_range = [first_col, last_col] - - def filter_column(self, col, criteria): - """ - Set the column filter criteria. - - Args: - col: Filter column (zero-indexed). - criteria: Filter criteria. - - Returns: - Nothing. - - """ - if not self.autofilter_area: - warn("Must call autofilter() before filter_column()") - return - - # Check for a column reference in A1 notation and substitute. - try: - int(col) - except ValueError: - # Convert col ref to a cell ref and then to a col number. - col_letter = col - (_, col) = xl_cell_to_rowcol(col + '1') - - if col >= self.xls_colmax: - warn("Invalid column '%s'" % col_letter) - return - - (col_first, col_last) = self.filter_range - - # Reject column if it is outside filter range. - if col < col_first or col > col_last: - warn("Column '%d' outside autofilter() column range (%d, %d)" - % (col, col_first, col_last)) - return - - tokens = self._extract_filter_tokens(criteria) - - if not (len(tokens) == 3 or len(tokens) == 7): - warn("Incorrect number of tokens in criteria '%s'" % criteria) - - tokens = self._parse_filter_expression(criteria, tokens) - - # Excel handles single or double custom filters as default filters. - # We need to check for them and handle them accordingly. - if len(tokens) == 2 and tokens[0] == 2: - # Single equality. - self.filter_column_list(col, [tokens[1]]) - elif (len(tokens) == 5 and tokens[0] == 2 and tokens[2] == 1 - and tokens[3] == 2): - # Double equality with "or" operator. - self.filter_column_list(col, [tokens[1], tokens[4]]) - else: - # Non default custom filter. - self.filter_cols[col] = tokens - self.filter_type[col] = 0 - - self.filter_on = 1 - - def filter_column_list(self, col, filters): - """ - Set the column filter criteria in Excel 2007 list style. - - Args: - col: Filter column (zero-indexed). - filters: List of filter criteria to match. - - Returns: - Nothing. - - """ - if not self.autofilter_area: - warn("Must call autofilter() before filter_column()") - return - - # Check for a column reference in A1 notation and substitute. - try: - int(col) - except ValueError: - # Convert col ref to a cell ref and then to a col number. - col_letter = col - (_, col) = xl_cell_to_rowcol(col + '1') - - if col >= self.xls_colmax: - warn("Invalid column '%s'" % col_letter) - return - - (col_first, col_last) = self.filter_range - - # Reject column if it is outside filter range. - if col < col_first or col > col_last: - warn("Column '%d' outside autofilter() column range " - "(%d,%d)" % (col, col_first, col_last)) - return - - self.filter_cols[col] = filters - self.filter_type[col] = 1 - self.filter_on = 1 - - @convert_range_args - def data_validation(self, first_row, first_col, last_row, last_col, - options): - """ - Add a data validation to a worksheet. - - Args: - first_row: The first row of the cell range. (zero indexed). - first_col: The first column of the cell range. - last_row: The last row of the cell range. (zero indexed). - last_col: The last column of the cell range. - options: Data validation options. - - Returns: - 0: Success. - -1: Row or column is out of worksheet bounds. - -2: Incorrect parameter or option. - """ - # Check that row and col are valid without storing the values. - if self._check_dimensions(first_row, first_col, True, True): - return -1 - if self._check_dimensions(last_row, last_col, True, True): - return -1 - - # List of valid input parameters. - valid_parameters = { - 'validate': True, - 'criteria': True, - 'value': True, - 'source': True, - 'minimum': True, - 'maximum': True, - 'ignore_blank': True, - 'dropdown': True, - 'show_input': True, - 'input_title': True, - 'input_message': True, - 'show_error': True, - 'error_title': True, - 'error_message': True, - 'error_type': True, - 'other_cells': True, - } - - # Check for valid input parameters. - for param_key in options.keys(): - if param_key not in valid_parameters: - warn("Unknown parameter '%s' in data_validation()" % param_key) - return -2 - - # Map alternative parameter names 'source' or 'minimum' to 'value'. - if 'source' in options: - options['value'] = options['source'] - if 'minimum' in options: - options['value'] = options['minimum'] - - # 'validate' is a required parameter. - if 'validate' not in options: - warn("Parameter 'validate' is required in data_validation()") - return -2 - - # List of valid validation types. - valid_types = { - 'any': 'none', - 'any value': 'none', - 'whole number': 'whole', - 'whole': 'whole', - 'integer': 'whole', - 'decimal': 'decimal', - 'list': 'list', - 'date': 'date', - 'time': 'time', - 'text length': 'textLength', - 'length': 'textLength', - 'custom': 'custom', - } - - # Check for valid validation types. - if not options['validate'] in valid_types: - warn("Unknown validation type '%s' for parameter " - "'validate' in data_validation()" % options['validate']) - return -2 - else: - options['validate'] = valid_types[options['validate']] - - # No action is required for validation type 'any' if there are no - # input messages to display. - if (options['validate'] == 'none' - and options.get('input_title') is None - and options.get('input_message') is None): - return -2 - - # The any, list and custom validations don't have a criteria so we use - # a default of 'between'. - if (options['validate'] == 'none' - or options['validate'] == 'list' - or options['validate'] == 'custom'): - options['criteria'] = 'between' - options['maximum'] = None - - # 'criteria' is a required parameter. - if 'criteria' not in options: - warn("Parameter 'criteria' is required in data_validation()") - return -2 - - # List of valid criteria types. - criteria_types = { - 'between': 'between', - 'not between': 'notBetween', - 'equal to': 'equal', - '=': 'equal', - '==': 'equal', - 'not equal to': 'notEqual', - '!=': 'notEqual', - '<>': 'notEqual', - 'greater than': 'greaterThan', - '>': 'greaterThan', - 'less than': 'lessThan', - '<': 'lessThan', - 'greater than or equal to': 'greaterThanOrEqual', - '>=': 'greaterThanOrEqual', - 'less than or equal to': 'lessThanOrEqual', - '<=': 'lessThanOrEqual', - } - - # Check for valid criteria types. - if not options['criteria'] in criteria_types: - warn("Unknown criteria type '%s' for parameter " - "'criteria' in data_validation()" % options['criteria']) - return -2 - else: - options['criteria'] = criteria_types[options['criteria']] - - # 'Between' and 'Not between' criteria require 2 values. - if (options['criteria'] == 'between' or - options['criteria'] == 'notBetween'): - if 'maximum' not in options: - warn("Parameter 'maximum' is required in data_validation() " - "when using 'between' or 'not between' criteria") - return -2 - else: - options['maximum'] = None - - # List of valid error dialog types. - error_types = { - 'stop': 0, - 'warning': 1, - 'information': 2, - } - - # Check for valid error dialog types. - if 'error_type' not in options: - options['error_type'] = 0 - elif not options['error_type'] in error_types: - warn("Unknown criteria type '%s' for parameter 'error_type' " - "in data_validation()" % options['error_type']) - return -2 - else: - options['error_type'] = error_types[options['error_type']] - - # Convert date/times value if required. - if options['validate'] == 'date' or options['validate'] == 'time': - - if options['value']: - if not supported_datetime(options['value']): - warn("Data validation 'value/minimum' must be a " - "datetime object.") - return -2 - else: - date_time = self._convert_date_time(options['value']) - # Format date number to the same precision as Excel. - options['value'] = "%.15g" % date_time - - if options['maximum']: - if not supported_datetime(options['maximum']): - warn("Conditional format 'maximum' must be a " - "datetime object.") - return -2 - else: - date_time = self._convert_date_time(options['maximum']) - options['maximum'] = "%.15g" % date_time - - # Check that the input title doesn't exceed the maximum length. - if options.get('input_title') and len(options['input_title']) > 32: - warn("Length of input title '%s' exceeds Excel's limit of 32" - % force_unicode(options['input_title'])) - return -2 - - # Check that the error title doesn't exceed the maximum length. - if options.get('error_title') and len(options['error_title']) > 32: - warn("Length of error title '%s' exceeds Excel's limit of 32" - % force_unicode(options['error_title'])) - return -2 - - # Check that the input message doesn't exceed the maximum length. - if (options.get('input_message') - and len(options['input_message']) > 255): - warn("Length of input message '%s' exceeds Excel's limit of 255" - % force_unicode(options['input_message'])) - return -2 - - # Check that the error message doesn't exceed the maximum length. - if (options.get('error_message') - and len(options['error_message']) > 255): - warn("Length of error message '%s' exceeds Excel's limit of 255" - % force_unicode(options['error_message'])) - return -2 - - # Check that the input list doesn't exceed the maximum length. - if options['validate'] == 'list' and type(options['value']) is list: - formula = self._csv_join(*options['value']) - if len(formula) > 255: - warn("Length of list items '%s' exceeds Excel's limit of " - "255, use a formula range instead" - % force_unicode(formula)) - return -2 - - # Set some defaults if they haven't been defined by the user. - if 'ignore_blank' not in options: - options['ignore_blank'] = 1 - if 'dropdown' not in options: - options['dropdown'] = 1 - if 'show_input' not in options: - options['show_input'] = 1 - if 'show_error' not in options: - options['show_error'] = 1 - - # These are the cells to which the validation is applied. - options['cells'] = [[first_row, first_col, last_row, last_col]] - - # A (for now) undocumented parameter to pass additional cell ranges. - if 'other_cells' in options: - options['cells'].extend(options['other_cells']) - - # Store the validation information until we close the worksheet. - self.validations.append(options) - - @convert_range_args - def conditional_format(self, first_row, first_col, last_row, last_col, - options=None): - """ - Add a conditional format to a worksheet. - - Args: - first_row: The first row of the cell range. (zero indexed). - first_col: The first column of the cell range. - last_row: The last row of the cell range. (zero indexed). - last_col: The last column of the cell range. - options: Conditional format options. - - Returns: - 0: Success. - -1: Row or column is out of worksheet bounds. - -2: Incorrect parameter or option. - """ - # Check that row and col are valid without storing the values. - if self._check_dimensions(first_row, first_col, True, True): - return -1 - if self._check_dimensions(last_row, last_col, True, True): - return -1 - - if options is None: - options = {} - - # Copy the user defined options so they aren't modified. - options = options.copy() - - # List of valid input parameters. - valid_parameter = { - 'type': True, - 'format': True, - 'criteria': True, - 'value': True, - 'minimum': True, - 'maximum': True, - 'min_type': True, - 'mid_type': True, - 'max_type': True, - 'min_value': True, - 'mid_value': True, - 'max_value': True, - 'min_color': True, - 'mid_color': True, - 'max_color': True, - 'multi_range': True, - 'bar_color': 1} - - # Check for valid input parameters. - for param_key in options.keys(): - if param_key not in valid_parameter: - warn("Unknown parameter '%s' in conditional_formatting()" % - param_key) - return -2 - - # 'type' is a required parameter. - if 'type' not in options: - warn("Parameter 'type' is required in conditional_formatting()") - return -2 - - # List of valid validation types. - valid_type = { - 'cell': 'cellIs', - 'date': 'date', - 'time': 'time', - 'average': 'aboveAverage', - 'duplicate': 'duplicateValues', - 'unique': 'uniqueValues', - 'top': 'top10', - 'bottom': 'top10', - 'text': 'text', - 'time_period': 'timePeriod', - 'blanks': 'containsBlanks', - 'no_blanks': 'notContainsBlanks', - 'errors': 'containsErrors', - 'no_errors': 'notContainsErrors', - '2_color_scale': '2_color_scale', - '3_color_scale': '3_color_scale', - 'data_bar': 'dataBar', - 'formula': 'expression'} - - # Check for valid validation types. - if options['type'] not in valid_type: - warn("Unknown validation type '%s' for parameter 'type' " - "in conditional_formatting()" % options['type']) - return -2 - else: - if options['type'] == 'bottom': - options['direction'] = 'bottom' - options['type'] = valid_type[options['type']] - - # List of valid criteria types. - criteria_type = { - 'between': 'between', - 'not between': 'notBetween', - 'equal to': 'equal', - '=': 'equal', - '==': 'equal', - 'not equal to': 'notEqual', - '!=': 'notEqual', - '<>': 'notEqual', - 'greater than': 'greaterThan', - '>': 'greaterThan', - 'less than': 'lessThan', - '<': 'lessThan', - 'greater than or equal to': 'greaterThanOrEqual', - '>=': 'greaterThanOrEqual', - 'less than or equal to': 'lessThanOrEqual', - '<=': 'lessThanOrEqual', - 'containing': 'containsText', - 'not containing': 'notContains', - 'begins with': 'beginsWith', - 'ends with': 'endsWith', - 'yesterday': 'yesterday', - 'today': 'today', - 'last 7 days': 'last7Days', - 'last week': 'lastWeek', - 'this week': 'thisWeek', - 'continue week': 'continueWeek', - 'last month': 'lastMonth', - 'this month': 'thisMonth', - 'continue month': 'continueMonth'} - - # Check for valid criteria types. - if 'criteria' in options and options['criteria'] in criteria_type: - options['criteria'] = criteria_type[options['criteria']] - - # Convert date/times value if required. - if options['type'] == 'date' or options['type'] == 'time': - options['type'] = 'cellIs' - - if 'value' in options: - if not supported_datetime(options['value']): - warn("Conditional format 'value' must be a " - "datetime object.") - return -2 - else: - date_time = self._convert_date_time(options['value']) - # Format date number to the same precision as Excel. - options['value'] = "%.15g" % date_time - - if 'minimum' in options: - if not supported_datetime(options['minimum']): - warn("Conditional format 'minimum' must be a " - "datetime object.") - return -2 - else: - date_time = self._convert_date_time(options['minimum']) - options['minimum'] = "%.15g" % date_time - - if 'maximum' in options: - if not supported_datetime(options['maximum']): - warn("Conditional format 'maximum' must be a " - "datetime object.") - return -2 - else: - date_time = self._convert_date_time(options['maximum']) - options['maximum'] = "%.15g" % date_time - - # Swap last row/col for first row/col as necessary - if first_row > last_row: - first_row, last_row = last_row, first_row - - if first_col > last_col: - first_col, last_col = last_col, first_col - - # Set the formatting range. - # If the first and last cell are the same write a single cell. - if first_row == last_row and first_col == last_col: - cell_range = xl_rowcol_to_cell(first_row, first_col) - start_cell = cell_range - else: - cell_range = xl_range(first_row, first_col, last_row, last_col) - start_cell = xl_rowcol_to_cell(first_row, first_col) - - # Override with user defined multiple range if provided. - if 'multi_range' in options: - cell_range = options['multi_range'] - cell_range = cell_range.replace('$', '') - - # Get the dxf format index. - if 'format' in options and options['format']: - options['format'] = options['format']._get_dxf_index() - - # Set the priority based on the order of adding. - options['priority'] = self.dxf_priority - self.dxf_priority += 1 - - # Special handling of text criteria. - if options['type'] == 'text': - - if options['criteria'] == 'containsText': - options['type'] = 'containsText' - options['formula'] = ('NOT(ISERROR(SEARCH("%s",%s)))' - % (options['value'], start_cell)) - elif options['criteria'] == 'notContains': - options['type'] = 'notContainsText' - options['formula'] = ('ISERROR(SEARCH("%s",%s))' - % (options['value'], start_cell)) - elif options['criteria'] == 'beginsWith': - options['type'] = 'beginsWith' - options['formula'] = ('LEFT(%s,%d)="%s"' - % (start_cell, - len(options['value']), - options['value'])) - elif options['criteria'] == 'endsWith': - options['type'] = 'endsWith' - options['formula'] = ('RIGHT(%s,%d)="%s"' - % (start_cell, - len(options['value']), - options['value'])) - else: - warn("Invalid text criteria 'options['criteria']' " - "in conditional_formatting()") - - # Special handling of time time_period criteria. - if options['type'] == 'timePeriod': - - if options['criteria'] == 'yesterday': - options['formula'] = 'FLOOR(%s,1)=TODAY()-1' % start_cell - - elif options['criteria'] == 'today': - options['formula'] = 'FLOOR(%s,1)=TODAY()' % start_cell - - elif options['criteria'] == 'tomorrow': - options['formula'] = 'FLOOR(%s,1)=TODAY()+1' % start_cell - - elif options['criteria'] == 'last7Days': - options['formula'] = \ - ('AND(TODAY()-FLOOR(%s,1)<=6,FLOOR(%s,1)<=TODAY())' % - (start_cell, start_cell)) - - elif options['criteria'] == 'lastWeek': - options['formula'] = \ - ('AND(TODAY()-ROUNDDOWN(%s,0)>=(WEEKDAY(TODAY())),' - 'TODAY()-ROUNDDOWN(%s,0)<(WEEKDAY(TODAY())+7))' % - (start_cell, start_cell)) - - elif options['criteria'] == 'thisWeek': - options['formula'] = \ - ('AND(TODAY()-ROUNDDOWN(%s,0)<=WEEKDAY(TODAY())-1,' - 'ROUNDDOWN(%s,0)-TODAY()<=7-WEEKDAY(TODAY()))' % - (start_cell, start_cell)) - - elif options['criteria'] == 'continueWeek': - options['formula'] = \ - ('AND(ROUNDDOWN(%s,0)-TODAY()>(7-WEEKDAY(TODAY())),' - 'ROUNDDOWN(%s,0)-TODAY()<(15-WEEKDAY(TODAY())))' % - (start_cell, start_cell)) - - elif options['criteria'] == 'lastMonth': - options['formula'] = \ - ('AND(MONTH(%s)=MONTH(TODAY())-1,OR(YEAR(%s)=YEAR(' - 'TODAY()),AND(MONTH(%s)=1,YEAR(A1)=YEAR(TODAY())-1)))' % - (start_cell, start_cell, start_cell)) - - elif options['criteria'] == 'thisMonth': - options['formula'] = \ - ('AND(MONTH(%s)=MONTH(TODAY()),YEAR(%s)=YEAR(TODAY()))' % - (start_cell, start_cell)) - - elif options['criteria'] == 'continueMonth': - options['formula'] = \ - ('AND(MONTH(%s)=MONTH(TODAY())+1,OR(YEAR(%s)=YEAR(' - 'TODAY()),AND(MONTH(%s)=12,YEAR(%s)=YEAR(TODAY())+1)))' % - (start_cell, start_cell, start_cell, start_cell)) - - else: - warn("Invalid time_period criteria 'options['criteria']' " - "in conditional_formatting()") - - # Special handling of blanks/error types. - if options['type'] == 'containsBlanks': - options['formula'] = 'LEN(TRIM(%s))=0' % start_cell - - if options['type'] == 'notContainsBlanks': - options['formula'] = 'LEN(TRIM(%s))>0' % start_cell - - if options['type'] == 'containsErrors': - options['formula'] = 'ISERROR(%s)' % start_cell - - if options['type'] == 'notContainsErrors': - options['formula'] = 'NOT(ISERROR(%s))' % start_cell - - # Special handling for 2 color scale. - if options['type'] == '2_color_scale': - options['type'] = 'colorScale' - - # Color scales don't use any additional formatting. - options['format'] = None - - # Turn off 3 color parameters. - options['mid_type'] = None - options['mid_color'] = None - - options.setdefault('min_type', 'min') - options.setdefault('max_type', 'max') - options.setdefault('min_value', 0) - options.setdefault('max_value', 0) - options.setdefault('min_color', '#FF7128') - options.setdefault('max_color', '#FFEF9C') - - options['min_color'] = xl_color(options['min_color']) - options['max_color'] = xl_color(options['max_color']) - - # Special handling for 3 color scale. - if options['type'] == '3_color_scale': - options['type'] = 'colorScale' - - # Color scales don't use any additional formatting. - options['format'] = None - - options.setdefault('min_type', 'min') - options.setdefault('mid_type', 'percentile') - options.setdefault('max_type', 'max') - options.setdefault('min_value', 0) - options.setdefault('max_value', 0) - options.setdefault('min_color', '#F8696B') - options.setdefault('mid_color', '#FFEB84') - options.setdefault('max_color', '#63BE7B') - - options['min_color'] = xl_color(options['min_color']) - options['mid_color'] = xl_color(options['mid_color']) - options['max_color'] = xl_color(options['max_color']) - - # Set a default mid value. - if 'mid_value' not in options: - options['mid_value'] = 50 - - # Special handling for data bar. - if options['type'] == 'dataBar': - - # Color scales don't use any additional formatting. - options['format'] = None - - options.setdefault('min_type', 'min') - options.setdefault('max_type', 'max') - options.setdefault('min_value', 0) - options.setdefault('max_value', 0) - options.setdefault('bar_color', '#638EC6') - - options['bar_color'] = xl_color(options['bar_color']) - - # Store the validation information until we close the worksheet. - if cell_range in self.cond_formats: - self.cond_formats[cell_range].append(options) - else: - self.cond_formats[cell_range] = [options] - - @convert_range_args - def add_table(self, first_row, first_col, last_row, last_col, - options=None): - """ - Add an Excel table to a worksheet. - - Args: - first_row: The first row of the cell range. (zero indexed). - first_col: The first column of the cell range. - last_row: The last row of the cell range. (zero indexed). - last_col: The last column of the cell range. - options: Table format options. (Optional) - - Returns: - 0: Success. - -1: Not supported in optimisation mode. - -2: Row or column is out of worksheet bounds. - -3: Incorrect parameter or option. - """ - table = {} - col_formats = {} - - if options is None: - options = {} - - if self.optimization == 1: - warn("add_table() isn't supported when set_optimization() is on") - return -1 - - # Check that row and col are valid without storing the values. - if self._check_dimensions(first_row, first_col, True, True): - return -2 - if self._check_dimensions(last_row, last_col, True, True): - return -2 - - # List of valid input parameters. - valid_parameter = { - 'autofilter': True, - 'banded_columns': True, - 'banded_rows': True, - 'columns': True, - 'data': True, - 'first_column': True, - 'header_row': True, - 'last_column': True, - 'name': True, - 'style': True, - 'total_row': True, - } - - # Check for valid input parameters. - for param_key in options.keys(): - if param_key not in valid_parameter: - warn("Unknown parameter '%s' in add_table()" % param_key) - return -3 - - # Turn on Excel's defaults. - options['banded_rows'] = options.get('banded_rows', True) - options['header_row'] = options.get('header_row', True) - options['autofilter'] = options.get('autofilter', True) - - # Set the table options. - table['show_first_col'] = options.get('first_column', False) - table['show_last_col'] = options.get('last_column', False) - table['show_row_stripes'] = options.get('banded_rows', False) - table['show_col_stripes'] = options.get('banded_columns', False) - table['header_row_count'] = options.get('header_row', 0) - table['totals_row_shown'] = options.get('total_row', False) - - # Set the table name. - if 'name' in options: - name = options['name'] - table['name'] = name - - if ' ' in name: - warn("Name '%s' in add_table() cannot contain spaces" - % force_unicode(name)) - return -3 - - # Warn if the name contains invalid chars as defined by Excel. - if (not re.match(r'^[\w\\][\w\\.]*$', name, re.UNICODE) - or re.match(r'^\d', name)): - warn("Invalid Excel characters in add_table(): '%s'" - % force_unicode(name)) - return -1 - - # Warn if the name looks like a cell name. - if re.match(r'^[a-zA-Z][a-zA-Z]?[a-dA-D]?[0-9]+$', name): - warn("Name looks like a cell name in add_table(): '%s'" - % force_unicode(name)) - return -1 - - # Warn if the name looks like a R1C1 cell reference. - if (re.match(r'^[rcRC]$', name) - or re.match(r'^[rcRC]\d+[rcRC]\d+$', name)): - warn("Invalid name '%s' like a RC cell ref in add_table()" - % force_unicode(name)) - return -1 - - # Set the table style. - if 'style' in options: - table['style'] = options['style'] - # Remove whitespace from style name. - table['style'] = table['style'].replace(' ', '') - else: - table['style'] = "TableStyleMedium9" - - # Swap last row/col for first row/col as necessary. - if first_row > last_row: - (first_row, last_row) = (last_row, first_row) - if first_col > last_col: - (first_col, last_col) = (last_col, first_col) - - # Set the data range rows (without the header and footer). - first_data_row = first_row - last_data_row = last_row - - if 'header_row' in options: - first_data_row += 1 - - if 'total_row' in options: - last_data_row -= 1 - - # Set the table and autofilter ranges. - table['range'] = xl_range(first_row, first_col, - last_row, last_col) - - table['a_range'] = xl_range(first_row, first_col, - last_data_row, last_col) - - # If the header row if off the default is to turn autofilter off. - if not options['header_row']: - options['autofilter'] = 0 - - # Set the autofilter range. - if options['autofilter']: - table['autofilter'] = table['a_range'] - - # Add the table columns. - col_id = 1 - table['columns'] = [] - - for col_num in range(first_col, last_col + 1): - # Set up the default column data. - col_data = { - 'id': col_id, - 'name': 'Column' + str(col_id), - 'total_string': '', - 'total_function': '', - 'total_value': 0, - 'formula': '', - 'format': None, - 'name_format': None, - } - - # Overwrite the defaults with any use defined values. - if 'columns' in options: - # Check if there are user defined values for this column. - user_data = options['columns'][col_id - 1] - - if user_data: - # Get the column format. - xformat = user_data.get('format', None) - - # Map user defined values to internal values. - if user_data.get('header'): - col_data['name'] = user_data['header'] - - col_data['name_format'] = user_data.get('header_format') - - # Handle the column formula. - if 'formula' in user_data and user_data['formula']: - formula = user_data['formula'] - - # Remove the formula '=' sign if it exists. - if formula.startswith('='): - formula = formula.lstrip('=') - - # Covert Excel 2010 "@" ref to 2007 "#This Row". - formula = formula.replace('@', '[#This Row],') - - col_data['formula'] = formula - - for row in range(first_data_row, last_data_row + 1): - self.write_formula(row, col_num, formula, xformat) - - # Handle the function for the total row. - if user_data.get('total_function'): - function = user_data['total_function'] - - # Massage the function name. - function = function.lower() - function = function.replace('_', '') - function = function.replace(' ', '') - - if function == 'countnums': - function = 'countNums' - if function == 'stddev': - function = 'stdDev' - - col_data['total_function'] = function - - formula = \ - self._table_function_to_formula(function, - col_data['name']) - - value = user_data.get('total_value', 0) - - self.write_formula(last_row, col_num, formula, xformat, - value) - - elif user_data.get('total_string'): - # Total label only (not a function). - total_string = user_data['total_string'] - col_data['total_string'] = total_string - - self.write_string(last_row, col_num, total_string, - user_data.get('format')) - - # Get the dxf format index. - if xformat is not None: - col_data['format'] = xformat._get_dxf_index() - - # Store the column format for writing the cell data. - # It doesn't matter if it is undefined. - col_formats[col_id - 1] = xformat - - # Store the column data. - table['columns'].append(col_data) - - # Write the column headers to the worksheet. - if options['header_row']: - self.write_string(first_row, col_num, col_data['name'], - col_data['name_format']) - - col_id += 1 - - # Write the cell data if supplied. - if 'data' in options: - data = options['data'] - - i = 0 # For indexing the row data. - for row in range(first_data_row, last_data_row + 1): - j = 0 # For indexing the col data. - for col in range(first_col, last_col + 1): - if i < len(data) and j < len(data[i]): - token = data[i][j] - if j in col_formats: - self.write(row, col, token, col_formats[j]) - else: - self.write(row, col, token, None) - j += 1 - i += 1 - - # Store the table data. - self.tables.append(table) - - return table - - @convert_cell_args - def add_sparkline(self, row, col, options): - """ - Add sparklines to the worksheet. - - Args: - row: The cell row (zero indexed). - col: The cell column (zero indexed). - options: Sparkline formatting options. - - Returns: - 0: Success. - -1: Row or column is out of worksheet bounds. - -2: Incorrect parameter or option. - - """ - - # Check that row and col are valid without storing the values. - if self._check_dimensions(row, col, True, True): - return -1 - - sparkline = {'locations': [xl_rowcol_to_cell(row, col)]} - - # List of valid input parameters. - valid_parameters = { - 'location': True, - 'range': True, - 'type': True, - 'high_point': True, - 'low_point': True, - 'negative_points': True, - 'first_point': True, - 'last_point': True, - 'markers': True, - 'style': True, - 'series_color': True, - 'negative_color': True, - 'markers_color': True, - 'first_color': True, - 'last_color': True, - 'high_color': True, - 'low_color': True, - 'max': True, - 'min': True, - 'axis': True, - 'reverse': True, - 'empty_cells': True, - 'show_hidden': True, - 'plot_hidden': True, - 'date_axis': True, - 'weight': True, - } - - # Check for valid input parameters. - for param_key in options.keys(): - if param_key not in valid_parameters: - warn("Unknown parameter '%s' in add_sparkline()" % param_key) - return -1 - - # 'range' is a required parameter. - if 'range' not in options: - warn("Parameter 'range' is required in add_sparkline()") - return -2 - - # Handle the sparkline type. - spark_type = options.get('type', 'line') - - if spark_type not in ('line', 'column', 'win_loss'): - warn("Parameter 'type' must be 'line', 'column' " - "or 'win_loss' in add_sparkline()") - return -2 - - if spark_type == 'win_loss': - spark_type = 'stacked' - sparkline['type'] = spark_type - - # We handle single location/range values or list of values. - if 'location' in options: - if type(options['location']) is list: - sparkline['locations'] = options['location'] - else: - sparkline['locations'] = [options['location']] - - if type(options['range']) is list: - sparkline['ranges'] = options['range'] - else: - sparkline['ranges'] = [options['range']] - - range_count = len(sparkline['ranges']) - location_count = len(sparkline['locations']) - - # The ranges and locations must match. - if range_count != location_count: - warn("Must have the same number of location and range " - "parameters in add_sparkline()") - return -2 - - # Store the count. - sparkline['count'] = len(sparkline['locations']) - - # Get the worksheet name for the range conversion below. - sheetname = quote_sheetname(self.name) - - # Cleanup the input ranges. - new_ranges = [] - for spark_range in sparkline['ranges']: - - # Remove the absolute reference $ symbols. - spark_range = spark_range.replace('$', '') - - # Remove the = from formula. - spark_range = spark_range.lstrip('=') - - # Convert a simple range into a full Sheet1!A1:D1 range. - if '!' not in spark_range: - spark_range = sheetname + "!" + spark_range - - new_ranges.append(spark_range) - - sparkline['ranges'] = new_ranges - - # Cleanup the input locations. - new_locations = [] - for location in sparkline['locations']: - location = location.replace('$', '') - new_locations.append(location) - - sparkline['locations'] = new_locations - - # Map options. - sparkline['high'] = options.get('high_point') - sparkline['low'] = options.get('low_point') - sparkline['negative'] = options.get('negative_points') - sparkline['first'] = options.get('first_point') - sparkline['last'] = options.get('last_point') - sparkline['markers'] = options.get('markers') - sparkline['min'] = options.get('min') - sparkline['max'] = options.get('max') - sparkline['axis'] = options.get('axis') - sparkline['reverse'] = options.get('reverse') - sparkline['hidden'] = options.get('show_hidden') - sparkline['weight'] = options.get('weight') - - # Map empty cells options. - empty = options.get('empty_cells', '') - - if empty == 'zero': - sparkline['empty'] = 0 - elif empty == 'connect': - sparkline['empty'] = 'span' - else: - sparkline['empty'] = 'gap' - - # Map the date axis range. - date_range = options.get('date_axis') - - if date_range and '!' not in date_range: - date_range = sheetname + "!" + date_range - - sparkline['date_axis'] = date_range - - # Set the sparkline styles. - style_id = options.get('style', 0) - style = get_sparkline_style(style_id) - - sparkline['series_color'] = style['series'] - sparkline['negative_color'] = style['negative'] - sparkline['markers_color'] = style['markers'] - sparkline['first_color'] = style['first'] - sparkline['last_color'] = style['last'] - sparkline['high_color'] = style['high'] - sparkline['low_color'] = style['low'] - - # Override the style colors with user defined colors. - self._set_spark_color(sparkline, options, 'series_color') - self._set_spark_color(sparkline, options, 'negative_color') - self._set_spark_color(sparkline, options, 'markers_color') - self._set_spark_color(sparkline, options, 'first_color') - self._set_spark_color(sparkline, options, 'last_color') - self._set_spark_color(sparkline, options, 'high_color') - self._set_spark_color(sparkline, options, 'low_color') - - self.sparklines.append(sparkline) - - @convert_range_args - def set_selection(self, first_row, first_col, last_row, last_col): - """ - Set the selected cell or cells in a worksheet - - Args: - first_row: The first row of the cell range. (zero indexed). - first_col: The first column of the cell range. - last_row: The last row of the cell range. (zero indexed). - last_col: The last column of the cell range. - - Returns: - 0: Nothing. - """ - pane = None - - # Range selection. Do this before swapping max/min to allow the - # selection direction to be reversed. - active_cell = xl_rowcol_to_cell(first_row, first_col) - - # Swap last row/col for first row/col if necessary - if first_row > last_row: - (first_row, last_row) = (last_row, first_row) - - if first_col > last_col: - (first_col, last_col) = (last_col, first_col) - - # If the first and last cell are the same write a single cell. - if (first_row == last_row) and (first_col == last_col): - sqref = active_cell - else: - sqref = xl_range(first_row, first_col, last_row, last_col) - - # Selection isn't set for cell A1. - if sqref == 'A1': - return - - self.selections = [[pane, active_cell, sqref]] - - def outline_settings(self, outline_on=1, outline_below=1, outline_right=1, - outline_style=0): - """ - Control outline settings. - - Args: - outline_on: Outlines are visible. Optional, defaults to True. - outline_below: Show row outline symbols below the outline bar. - Optional, defaults to True. - outline_right: Show column outline symbols to the right of the - outline bar. Optional, defaults to True. - outline_style: Use Automatic style. Optional, defaults to False. - - Returns: - 0: Nothing. - """ - self.outline_on = outline_on - self.outline_below = outline_below - self.outline_right = outline_right - self.outline_style = outline_style - - self.outline_changed = True - - @convert_cell_args - def freeze_panes(self, row, col, top_row=None, left_col=None, pane_type=0): - """ - Create worksheet panes and mark them as frozen. - - Args: - row: The cell row (zero indexed). - col: The cell column (zero indexed). - top_row: Topmost visible row in scrolling region of pane. - left_col: Leftmost visible row in scrolling region of pane. - - Returns: - 0: Nothing. - - """ - if top_row is None: - top_row = row - - if left_col is None: - left_col = col - - self.panes = [row, col, top_row, left_col, pane_type] - - @convert_cell_args - def split_panes(self, x, y, top_row=None, left_col=None): - """ - Create worksheet panes and mark them as split. - - Args: - x: The position for the vertical split. - y: The position for the horizontal split. - top_row: Topmost visible row in scrolling region of pane. - left_col: Leftmost visible row in scrolling region of pane. - - Returns: - 0: Nothing. - - """ - # Same as freeze panes with a different pane type. - self.freeze_panes(x, y, top_row, left_col, 2) - - def set_zoom(self, zoom=100): - """ - Set the worksheet zoom factor. - - Args: - zoom: Scale factor: 10 <= zoom <= 400. - - Returns: - Nothing. - - """ - # Ensure the zoom scale is in Excel's range. - if zoom < 10 or zoom > 400: - warn("Zoom factor %d outside range: 10 <= zoom <= 400" % zoom) - zoom = 100 - - self.zoom = int(zoom) - - def right_to_left(self): - """ - Display the worksheet right to left for some versions of Excel. - - Args: - None. - - Returns: - Nothing. - - """ - self.is_right_to_left = 1 - - def hide_zero(self): - """ - Hide zero values in worksheet cells. - - Args: - None. - - Returns: - Nothing. - - """ - self.show_zeros = 0 - - def set_tab_color(self, color): - """ - Set the color of the worksheet tab. - - Args: - color: A #RGB color index. - - Returns: - Nothing. - - """ - self.tab_color = xl_color(color) - - def protect(self, password='', options=None): - """ - Set the password and protection options of the worksheet. - - Args: - password: An optional password string. - options: A dictionary of worksheet objects to protect. - - Returns: - Nothing. - - """ - if password != '': - password = self._encode_password(password) - - if not options: - options = {} - - # Default values for objects that can be protected. - defaults = { - 'sheet': True, - 'content': False, - 'objects': False, - 'scenarios': False, - 'format_cells': False, - 'format_columns': False, - 'format_rows': False, - 'insert_columns': False, - 'insert_rows': False, - 'insert_hyperlinks': False, - 'delete_columns': False, - 'delete_rows': False, - 'select_locked_cells': True, - 'sort': False, - 'autofilter': False, - 'pivot_tables': False, - 'select_unlocked_cells': True} - - # Overwrite the defaults with user specified values. - for key in (options.keys()): - - if key in defaults: - defaults[key] = options[key] - else: - warn("Unknown protection object: '%s'" % key) - - # Set the password after the user defined values. - defaults['password'] = password - - self.protect_options = defaults - - @convert_cell_args - def insert_button(self, row, col, options={}): - """ - Insert a button form object into the worksheet. - - Args: - row: The cell row (zero indexed). - col: The cell column (zero indexed). - options: Button formatting options. - - Returns: - 0: Success. - -1: Row or column is out of worksheet bounds. - - """ - button = self._button_params(row, col, options) - - self.buttons_list.append(button) - - self.has_vml = 1 - - ########################################################################### - # - # Public API. Page Setup methods. - # - ########################################################################### - def set_landscape(self): - """ - Set the page orientation as landscape. - - Args: - None. - - Returns: - Nothing. - - """ - self.orientation = 0 - self.page_setup_changed = True - - def set_portrait(self): - """ - Set the page orientation as portrait. - - Args: - None. - - Returns: - Nothing. - - """ - self.orientation = 1 - self.page_setup_changed = True - - def set_page_view(self): - """ - Set the page view mode. - - Args: - None. - - Returns: - Nothing. - - """ - self.page_view = 1 - - def set_paper(self, paper_size): - """ - Set the paper type. US Letter = 1, A4 = 9. - - Args: - paper_size: Paper index. - - Returns: - Nothing. - - """ - if paper_size: - self.paper_size = paper_size - self.page_setup_changed = True - - def center_horizontally(self): - """ - Center the page horizontally. - - Args: - None. - - Returns: - Nothing. - - """ - self.print_options_changed = True - self.hcenter = 1 - - def center_vertically(self): - """ - Center the page vertically. - - Args: - None. - - Returns: - Nothing. - - """ - self.print_options_changed = True - self.vcenter = 1 - - def set_margins(self, left=0.7, right=0.7, top=0.75, bottom=0.75): - """ - Set all the page margins in inches. - - Args: - left: Left margin. - right: Right margin. - top: Top margin. - bottom: Bottom margin. - - Returns: - Nothing. - - """ - self.margin_left = left - self.margin_right = right - self.margin_top = top - self.margin_bottom = bottom - - def set_header(self, header='', options=None, margin=None): - """ - Set the page header caption and optional margin. - - Args: - header: Header string. - margin: Header margin. - options: Header options, mainly for images. - - Returns: - Nothing. - - """ - header_orig = header - header = header.replace('&[Picture]', '&G') - - if len(header) >= 255: - warn('Header string must be less than 255 characters') - return - - if options is not None: - # For backward compatibility allow options to be the margin. - if not isinstance(options, dict): - options = {'margin': options} - else: - options = {} - - # For backward compatibility. - if margin is not None: - options['margin'] = margin - - # Reset the list in case the function is called more than once. - self.header_images = [] - - if options.get('image_left'): - self.header_images.append([options.get('image_left'), - options.get('image_data_left'), - 'LH']) - - if options.get('image_center'): - self.header_images.append([options.get('image_center'), - options.get('image_data_center'), - 'CH']) - - if options.get('image_right'): - self.header_images.append([options.get('image_right'), - options.get('image_data_right'), - 'RH']) - - placeholder_count = header.count('&G') - image_count = len(self.header_images) - - if placeholder_count != image_count: - warn("Number of header images (%s) doesn't match placeholder " - "count (%s) in string: %s" - % (image_count, placeholder_count, header_orig)) - self.header_images = [] - return - - if 'align_with_margins' in options: - self.header_footer_aligns = options['align_with_margins'] - - if 'scale_with_doc' in options: - self.header_footer_scales = options['scale_with_doc'] - - self.header = header - self.margin_header = options.get('margin', 0.3) - self.header_footer_changed = True - - if image_count: - self.has_header_vml = True - - def set_footer(self, footer='', options=None, margin=None): - """ - Set the page footer caption and optional margin. - - Args: - footer: Footer string. - margin: Footer margin. - options: Footer options, mainly for images. - - Returns: - Nothing. - - """ - footer_orig = footer - footer = footer.replace('&[Picture]', '&G') - - if len(footer) >= 255: - warn('Footer string must be less than 255 characters') - return - - if options is not None: - # For backward compatibility allow options to be the margin. - if not isinstance(options, dict): - options = {'margin': options} - else: - options = {} - - # For backward compatibility. - if margin is not None: - options['margin'] = margin - - # Reset the list in case the function is called more than once. - self.footer_images = [] - - if options.get('image_left'): - self.footer_images.append([options.get('image_left'), - options.get('image_data_left'), - 'LF']) - - if options.get('image_center'): - self.footer_images.append([options.get('image_center'), - options.get('image_data_center'), - 'CF']) - - if options.get('image_right'): - self.footer_images.append([options.get('image_right'), - options.get('image_data_right'), - 'RF']) - - placeholder_count = footer.count('&G') - image_count = len(self.footer_images) - - if placeholder_count != image_count: - warn("Number of footer images (%s) doesn't match placeholder " - "count (%s) in string: %s" - % (image_count, placeholder_count, footer_orig)) - self.footer_images = [] - return - - if 'align_with_margins' in options: - self.header_footer_aligns = options['align_with_margins'] - - if 'scale_with_doc' in options: - self.header_footer_scales = options['scale_with_doc'] - - self.footer = footer - self.margin_footer = options.get('margin', 0.3) - self.header_footer_changed = True - - if image_count: - self.has_header_vml = True - - def repeat_rows(self, first_row, last_row=None): - """ - Set the rows to repeat at the top of each printed page. - - Args: - first_row: Start row for range. - last_row: End row for range. - - Returns: - Nothing. - - """ - if last_row is None: - last_row = first_row - - # Convert rows to 1 based. - first_row += 1 - last_row += 1 - - # Create the row range area like: $1:$2. - area = '$%d:$%d' % (first_row, last_row) - - # Build up the print titles area "Sheet1!$1:$2" - sheetname = quote_sheetname(self.name) - self.repeat_row_range = sheetname + '!' + area - - @convert_column_args - def repeat_columns(self, first_col, last_col=None): - """ - Set the columns to repeat at the left hand side of each printed page. - - Args: - first_col: Start column for range. - last_col: End column for range. - - Returns: - Nothing. - - """ - if last_col is None: - last_col = first_col - - # Convert to A notation. - first_col = xl_col_to_name(first_col, 1) - last_col = xl_col_to_name(last_col, 1) - - # Create a column range like $C:$D. - area = first_col + ':' + last_col - - # Build up the print area range "=Sheet2!$C:$D" - sheetname = quote_sheetname(self.name) - self.repeat_col_range = sheetname + "!" + area - - def hide_gridlines(self, option=1): - """ - Set the option to hide gridlines on the screen and the printed page. - - Args: - option: 0 : Don't hide gridlines - 1 : Hide printed gridlines only - 2 : Hide screen and printed gridlines - - Returns: - Nothing. - - """ - if option == 0: - self.print_gridlines = 1 - self.screen_gridlines = 1 - self.print_options_changed = True - elif option == 1: - self.print_gridlines = 0 - self.screen_gridlines = 1 - else: - self.print_gridlines = 0 - self.screen_gridlines = 0 - - def print_row_col_headers(self): - """ - Set the option to print the row and column headers on the printed page. - - Args: - None. - - Returns: - Nothing. - - """ - self.print_headers = 1 - self.print_options_changed = True - - @convert_range_args - def print_area(self, first_row, first_col, last_row, last_col): - """ - Set the print area in the current worksheet. - - Args: - first_row: The first row of the cell range. (zero indexed). - first_col: The first column of the cell range. - last_row: The last row of the cell range. (zero indexed). - last_col: The last column of the cell range. - - Returns: - 0: Success. - -1: Row or column is out of worksheet bounds. - - """ - # Set the print area in the current worksheet. - - # Ignore max print area since it is the same as no area for Excel. - if (first_row == 0 and first_col == 0 - and last_row == self.xls_rowmax - 1 - and last_col == self.xls_colmax - 1): - return - - # Build up the print area range "Sheet1!$A$1:$C$13". - area = self._convert_name_area(first_row, first_col, - last_row, last_col) - self.print_area_range = area - - def print_across(self): - """ - Set the order in which pages are printed. - - Args: - None. - - Returns: - Nothing. - - """ - self.page_order = 1 - self.page_setup_changed = True - - def fit_to_pages(self, width, height): - """ - Fit the printed area to a specific number of pages both vertically and - horizontally. - - Args: - width: Number of pages horizontally. - height: Number of pages vertically. - - Returns: - Nothing. - - """ - self.fit_page = 1 - self.fit_width = width - self.fit_height = height - self.page_setup_changed = True - - def set_start_page(self, start_page): - """ - Set the start page number when printing. - - Args: - start_page: Start page number. - - Returns: - Nothing. - - """ - self.page_start = start_page - - def set_print_scale(self, scale): - """ - Set the scale factor for the printed page. - - Args: - scale: Print scale. 10 <= scale <= 400. - - Returns: - Nothing. - - """ - # Confine the scale to Excel's range. - if scale < 10 or scale > 400: - warn("Print scale '%d' outside range: 10 <= scale <= 400" % scale) - return - - # Turn off "fit to page" option when print scale is on. - self.fit_page = 0 - - self.print_scale = int(scale) - self.page_setup_changed = True - - def set_h_pagebreaks(self, breaks): - """ - Set the horizontal page breaks on a worksheet. - - Args: - breaks: List of rows where the page breaks should be added. - - Returns: - Nothing. - - """ - self.hbreaks = breaks - - def set_v_pagebreaks(self, breaks): - """ - Set the horizontal page breaks on a worksheet. - - Args: - breaks: List of columns where the page breaks should be added. - - Returns: - Nothing. - - """ - self.vbreaks = breaks - - def set_vba_name(self, name=None): - """ - Set the VBA name for the worksheet. By default this is the - same as the sheet name: i.e., Sheet1 etc. - - Args: - name: The VBA name for the worksheet. - - Returns: - Nothing. - - """ - if name is not None: - self.vba_codename = name - else: - self.vba_codename = self.name - - ########################################################################### - # - # Private API. - # - ########################################################################### - def _initialize(self, init_data): - self.name = init_data['name'] - self.index = init_data['index'] - self.str_table = init_data['str_table'] - self.worksheet_meta = init_data['worksheet_meta'] - self.optimization = init_data['optimization'] - self.tmpdir = init_data['tmpdir'] - self.date_1904 = init_data['date_1904'] - self.strings_to_numbers = init_data['strings_to_numbers'] - self.strings_to_formulas = init_data['strings_to_formulas'] - self.strings_to_urls = init_data['strings_to_urls'] - self.nan_inf_to_errors = init_data['nan_inf_to_errors'] - self.default_date_format = init_data['default_date_format'] - self.default_url_format = init_data['default_url_format'] - self.excel2003_style = init_data['excel2003_style'] - - if self.excel2003_style: - self.original_row_height = 12.75 - self.default_row_height = 12.75 - self.default_row_pixels = 17 - self.margin_left = 0.75 - self.margin_right = 0.75 - self.margin_top = 1 - self.margin_bottom = 1 - self.margin_header = 0.5 - self.margin_footer = 0.5 - self.header_footer_aligns = False - - # Open a temp filehandle to store row data in optimization mode. - if self.optimization == 1: - # This is sub-optimal but we need to create a temp file - # with utf8 encoding in Python < 3. - (fd, filename) = tempfile.mkstemp(dir=self.tmpdir) - os.close(fd) - self.row_data_filename = filename - self.row_data_fh = codecs.open(filename, 'w+', 'utf-8') - - # Set as the worksheet filehandle until the file is assembled. - self.fh = self.row_data_fh - - def _assemble_xml_file(self): - # Assemble and write the XML file. - - # Write the XML declaration. - self._xml_declaration() - - # Write the root worksheet element. - self._write_worksheet() - - # Write the worksheet properties. - self._write_sheet_pr() - - # Write the worksheet dimensions. - self._write_dimension() - - # Write the sheet view properties. - self._write_sheet_views() - - # Write the sheet format properties. - self._write_sheet_format_pr() - - # Write the sheet column info. - self._write_cols() - - # Write the worksheet data such as rows columns and cells. - if self.optimization == 0: - self._write_sheet_data() - else: - self._write_optimized_sheet_data() - - # Write the sheetProtection element. - self._write_sheet_protection() - - # Write the phoneticPr element. - if self.excel2003_style: - self._write_phonetic_pr() - - # Write the autoFilter element. - self._write_auto_filter() - - # Write the mergeCells element. - self._write_merge_cells() - - # Write the conditional formats. - self._write_conditional_formats() - - # Write the dataValidations element. - self._write_data_validations() - - # Write the hyperlink element. - self._write_hyperlinks() - - # Write the printOptions element. - self._write_print_options() - - # Write the worksheet page_margins. - self._write_page_margins() - - # Write the worksheet page setup. - self._write_page_setup() - - # Write the headerFooter element. - self._write_header_footer() - - # Write the rowBreaks element. - self._write_row_breaks() - - # Write the colBreaks element. - self._write_col_breaks() - - # Write the drawing element. - self._write_drawings() - - # Write the legacyDrawing element. - self._write_legacy_drawing() - - # Write the legacyDrawingHF element. - self._write_legacy_drawing_hf() - - # Write the tableParts element. - self._write_table_parts() - - # Write the extLst and sparklines. - self._write_ext_sparklines() - - # Close the worksheet tag. - self._xml_end_tag('worksheet') - - # Close the file. - self._xml_close() - - def _check_dimensions(self, row, col, ignore_row=False, ignore_col=False): - # Check that row and col are valid and store the max and min - # values for use in other methods/elements. The ignore_row / - # ignore_col flags is used to indicate that we wish to perform - # the dimension check without storing the value. The ignore - # flags are use by set_row() and data_validate. - - # Check that the row/col are within the worksheet bounds. - if row < 0 or col < 0: - return -1 - if row >= self.xls_rowmax or col >= self.xls_colmax: - return -1 - - # In optimization mode we don't change dimensions for rows - # that are already written. - if not ignore_row and not ignore_col and self.optimization == 1: - if row < self.previous_row: - return -2 - - if not ignore_row: - if self.dim_rowmin is None or row < self.dim_rowmin: - self.dim_rowmin = row - if self.dim_rowmax is None or row > self.dim_rowmax: - self.dim_rowmax = row - - if not ignore_col: - if self.dim_colmin is None or col < self.dim_colmin: - self.dim_colmin = col - if self.dim_colmax is None or col > self.dim_colmax: - self.dim_colmax = col - - return 0 - - def _convert_date_time(self, dt_obj): - # Convert a datetime object to an Excel serial date and time. - return datetime_to_excel_datetime(dt_obj, self.date_1904) - - def _convert_name_area(self, row_num_1, col_num_1, row_num_2, col_num_2): - # Convert zero indexed rows and columns to the format required by - # worksheet named ranges, eg, "Sheet1!$A$1:$C$13". - - range1 = '' - range2 = '' - area = '' - row_col_only = 0 - - # Convert to A1 notation. - col_char_1 = xl_col_to_name(col_num_1, 1) - col_char_2 = xl_col_to_name(col_num_2, 1) - row_char_1 = '$' + str(row_num_1 + 1) - row_char_2 = '$' + str(row_num_2 + 1) - - # We need to handle special cases that refer to rows or columns only. - if row_num_1 == 0 and row_num_2 == self.xls_rowmax - 1: - range1 = col_char_1 - range2 = col_char_2 - row_col_only = 1 - elif col_num_1 == 0 and col_num_2 == self.xls_colmax - 1: - range1 = row_char_1 - range2 = row_char_2 - row_col_only = 1 - else: - range1 = col_char_1 + row_char_1 - range2 = col_char_2 + row_char_2 - - # A repeated range is only written once (if it isn't a special case). - if range1 == range2 and not row_col_only: - area = range1 - else: - area = range1 + ':' + range2 - - # Build up the print area range "Sheet1!$A$1:$C$13". - sheetname = quote_sheetname(self.name) - area = sheetname + "!" + area - - return area - - def _sort_pagebreaks(self, breaks): - # This is an internal method used to filter elements of a list of - # pagebreaks used in the _store_hbreak() and _store_vbreak() methods. - # It: - # 1. Removes duplicate entries from the list. - # 2. Sorts the list. - # 3. Removes 0 from the list if present. - if not breaks: - return - - breaks_set = set(breaks) - - if 0 in breaks_set: - breaks_set.remove(0) - - breaks_list = list(breaks_set) - breaks_list.sort() - - # The Excel 2007 specification says that the maximum number of page - # breaks is 1026. However, in practice it is actually 1023. - max_num_breaks = 1023 - if len(breaks_list) > max_num_breaks: - breaks_list = breaks_list[:max_num_breaks] - - return breaks_list - - def _extract_filter_tokens(self, expression): - # Extract the tokens from the filter expression. The tokens are mainly - # non-whitespace groups. The only tricky part is to extract string - # tokens that contain whitespace and/or quoted double quotes (Excel's - # escaped quotes). - # - # Examples: 'x < 2000' - # 'x > 2000 and x < 5000' - # 'x = "foo"' - # 'x = "foo bar"' - # 'x = "foo "" bar"' - # - if not expression: - return [] - - token_re = re.compile(r'"(?:[^"]|"")*"|\S+') - tokens = token_re.findall(expression) - - new_tokens = [] - # Remove single leading and trailing quotes and un-escape other quotes. - for token in tokens: - if token.startswith('"'): - token = token[1:] - - if token.endswith('"'): - token = token[:-1] - - token = token.replace('""', '"') - - new_tokens.append(token) - - return new_tokens - - def _parse_filter_expression(self, expression, tokens): - # Converts the tokens of a possibly conditional expression into 1 or 2 - # sub expressions for further parsing. - # - # Examples: - # ('x', '==', 2000) -> exp1 - # ('x', '>', 2000, 'and', 'x', '<', 5000) -> exp1 and exp2 - - if len(tokens) == 7: - # The number of tokens will be either 3 (for 1 expression) - # or 7 (for 2 expressions). - conditional = tokens[3] - - if re.match('(and|&&)', conditional): - conditional = 0 - elif re.match('(or|\|\|)', conditional): - conditional = 1 - else: - warn("Token '%s' is not a valid conditional " - "in filter expression '%s'" % (conditional, expression)) - - expression_1 = self._parse_filter_tokens(expression, tokens[0:3]) - expression_2 = self._parse_filter_tokens(expression, tokens[4:7]) - - return expression_1 + [conditional] + expression_2 - else: - return self._parse_filter_tokens(expression, tokens) - - def _parse_filter_tokens(self, expression, tokens): - # Parse the 3 tokens of a filter expression and return the operator - # and token. The use of numbers instead of operators is a legacy of - # Spreadsheet::WriteExcel. - operators = { - '==': 2, - '=': 2, - '=~': 2, - 'eq': 2, - - '!=': 5, - '!~': 5, - 'ne': 5, - '<>': 5, - - '<': 1, - '<=': 3, - '>': 4, - '>=': 6, - } - - operator = operators.get(tokens[1], None) - token = tokens[2] - - # Special handling of "Top" filter expressions. - if re.match('top|bottom', tokens[0].lower()): - value = int(tokens[1]) - - if value < 1 or value > 500: - warn("The value '%d' in expression '%s' " - "must be in the range 1 to 500" % (value, expression)) - - token = token.lower() - - if token != 'items' and token != '%': - warn("The type '%s' in expression '%s' " - "must be either 'items' or '%'" % (token, expression)) - - if tokens[0].lower() == 'top': - operator = 30 - else: - operator = 32 - - if tokens[2] == '%': - operator += 1 - - token = str(value) - - if not operator and tokens[0]: - warn("Token '%s' is not a valid operator " - "in filter expression '%s'" % (token[0], expression)) - - # Special handling for Blanks/NonBlanks. - if re.match('blanks|nonblanks', token.lower()): - # Only allow Equals or NotEqual in this context. - if operator != 2 and operator != 5: - warn("The operator '%s' in expression '%s' " - "is not valid in relation to Blanks/NonBlanks'" - % (tokens[1], expression)) - - token = token.lower() - - # The operator should always be 2 (=) to flag a "simple" equality - # in the binary record. Therefore we convert <> to =. - if token == 'blanks': - if operator == 5: - token = ' ' - else: - if operator == 5: - operator = 2 - token = 'blanks' - else: - operator = 5 - token = ' ' - - # if the string token contains an Excel match character then change the - # operator type to indicate a non "simple" equality. - if operator == 2 and re.search('[*?]', token): - operator = 22 - - return [operator, token] - - def _encode_password(self, plaintext): - # Encode the worksheet protection "password" as a simple hash. - # Based on the algorithm by Daniel Rentz of OpenOffice. - i = 0 - count = len(plaintext) - digits = [] - - for char in plaintext: - i += 1 - char = ord(char) << i - low_15 = char & 0x7fff - high_15 = char & 0x7fff << 15 - high_15 >>= 15 - char = low_15 | high_15 - digits.append(char) - - password_hash = 0x0000 - - for digit in digits: - password_hash ^= digit - - password_hash ^= count - password_hash ^= 0xCE4B - - return "%X" % password_hash - - def _prepare_image(self, index, image_id, drawing_id, width, height, - name, image_type, x_dpi, y_dpi): - # Set up images/drawings. - drawing_type = 2 - (row, col, _, x_offset, y_offset, - x_scale, y_scale, url, tip, anchor, _) = self.images[index] - - width *= x_scale - height *= y_scale - - # Scale by non 96dpi resolutions. - width *= 96.0 / x_dpi - height *= 96.0 / y_dpi - - dimensions = self._position_object_emus(col, row, x_offset, y_offset, - width, height) - - # Convert from pixels to emus. - width = int(0.5 + (width * 9525)) - height = int(0.5 + (height * 9525)) - - # Create a Drawing obj to use with worksheet unless one already exists. - if not self.drawing: - drawing = Drawing() - drawing.embedded = 1 - self.drawing = drawing - - self.external_drawing_links.append(['/drawing', - '../drawings/drawing' - + str(drawing_id) - + '.xml', None]) - else: - drawing = self.drawing - - drawing_object = [drawing_type] - drawing_object.extend(dimensions) - drawing_object.extend([width, height, name, None, url, tip, anchor]) - - drawing._add_drawing_object(drawing_object) - - if url: - rel_type = "/hyperlink" - target_mode = "External" - - if re.match('(ftp|http)s?://', url): - target = url - - if re.match('external:', url): - target = url.replace('external:', '') - - if re.match("internal:", url): - target = url.replace('internal:', '#') - target_mode = None - - self.drawing_links.append([rel_type, target, target_mode]) - - self.drawing_links.append(['/image', - '../media/image' - + str(image_id) + '.' - + image_type]) - - def _prepare_shape(self, index, drawing_id): - # Set up shapes/drawings. - drawing_type = 3 - - (row, col, x_offset, y_offset, - x_scale, y_scale, text, options) = self.shapes[index] - - width = options.get('width', self.default_col_pixels * 3) - height = options.get('height', self.default_row_pixels * 6) - - width *= x_scale - height *= y_scale - - dimensions = self._position_object_emus(col, row, x_offset, y_offset, - width, height) - - # Convert from pixels to emus. - width = int(0.5 + (width * 9525)) - height = int(0.5 + (height * 9525)) - - # Create a Drawing obj to use with worksheet unless one already exists. - if not self.drawing: - drawing = Drawing() - drawing.embedded = 1 - self.drawing = drawing - - self.external_drawing_links.append(['/drawing', - '../drawings/drawing' - + str(drawing_id) - + '.xml', None]) - else: - drawing = self.drawing - - shape = Shape('rect', 'TextBox', options) - shape.text = text - - drawing_object = [drawing_type] - drawing_object.extend(dimensions) - drawing_object.extend([width, height, None, shape, None, - None, None]) - - drawing._add_drawing_object(drawing_object) - - def _prepare_header_image(self, image_id, width, height, name, image_type, - position, x_dpi, y_dpi): - # Set up an image without a drawing object for header/footer images. - - # Strip the extension from the filename. - name = re.sub('\..*$', '', name) - - self.header_images_list.append([width, height, name, position, - x_dpi, y_dpi]) - - self.vml_drawing_links.append(['/image', - '../media/image' - + str(image_id) + '.' - + image_type]) - - def _prepare_chart(self, index, chart_id, drawing_id): - # Set up chart/drawings. - drawing_type = 1 - - (row, col, chart, x_offset, y_offset, x_scale, y_scale) = \ - self.charts[index] - - chart.id = chart_id - 1 - - # Use user specified dimensions, if any. - width = int(0.5 + (chart.width * x_scale)) - height = int(0.5 + (chart.height * y_scale)) - - dimensions = self._position_object_emus(col, row, x_offset, y_offset, - width, height) - - # Set the chart name for the embedded object if it has been specified. - name = chart.chart_name - - # Create a Drawing obj to use with worksheet unless one already exists. - if not self.drawing: - drawing = Drawing() - drawing.embedded = 1 - self.drawing = drawing - - self.external_drawing_links.append(['/drawing', - '../drawings/drawing' - + str(drawing_id) - + '.xml']) - else: - drawing = self.drawing - - drawing_object = [drawing_type] - drawing_object.extend(dimensions) - drawing_object.extend([width, height, name, None]) - - drawing._add_drawing_object(drawing_object) - - self.drawing_links.append(['/chart', - '../charts/chart' - + str(chart_id) - + '.xml']) - - def _position_object_emus(self, col_start, row_start, x1, y1, - width, height): - # Calculate the vertices that define the position of a graphical - # object within the worksheet in EMUs. - # - # The vertices are expressed as English Metric Units (EMUs). There are - # 12,700 EMUs per point. Therefore, 12,700 * 3 /4 = 9,525 EMUs per - # pixel - (col_start, row_start, x1, y1, - col_end, row_end, x2, y2, x_abs, y_abs) = \ - self._position_object_pixels(col_start, row_start, x1, y1, - width, height) - - # Convert the pixel values to EMUs. See above. - x1 = int(0.5 + 9525 * x1) - y1 = int(0.5 + 9525 * y1) - x2 = int(0.5 + 9525 * x2) - y2 = int(0.5 + 9525 * y2) - x_abs = int(0.5 + 9525 * x_abs) - y_abs = int(0.5 + 9525 * y_abs) - - return (col_start, row_start, x1, y1, col_end, row_end, x2, y2, - x_abs, y_abs) - - # Calculate the vertices that define the position of a graphical object - # within the worksheet in pixels. - # - # +------------+------------+ - # | A | B | - # +-----+------------+------------+ - # | |(x1,y1) | | - # | 1 |(A1)._______|______ | - # | | | | | - # | | | | | - # +-----+----| OBJECT |-----+ - # | | | | | - # | 2 | |______________. | - # | | | (B2)| - # | | | (x2,y2)| - # +---- +------------+------------+ - # - # Example of an object that covers some of the area from cell A1 to B2. - # - # Based on the width and height of the object we need to calculate 8 vars: - # - # col_start, row_start, col_end, row_end, x1, y1, x2, y2. - # - # We also calculate the absolute x and y position of the top left vertex of - # the object. This is required for images. - # - # The width and height of the cells that the object occupies can be - # variable and have to be taken into account. - # - # The values of col_start and row_start are passed in from the calling - # function. The values of col_end and row_end are calculated by - # subtracting the width and height of the object from the width and - # height of the underlying cells. - # - def _position_object_pixels(self, col_start, row_start, x1, y1, - width, height): - # col_start # Col containing upper left corner of object. - # x1 # Distance to left side of object. - # - # row_start # Row containing top left corner of object. - # y1 # Distance to top of object. - # - # col_end # Col containing lower right corner of object. - # x2 # Distance to right side of object. - # - # row_end # Row containing bottom right corner of object. - # y2 # Distance to bottom of object. - # - # width # Width of object frame. - # height # Height of object frame. - # - # x_abs # Absolute distance to left side of object. - # y_abs # Absolute distance to top side of object. - x_abs = 0 - y_abs = 0 - - # Adjust start column for negative offsets. - while x1 < 0 and col_start > 0: - x1 += self._size_col(col_start - 1) - col_start -= 1 - - # Adjust start row for negative offsets. - while y1 < 0 and row_start > 0: - y1 += self._size_row(row_start - 1) - row_start -= 1 - - # Ensure that the image isn't shifted off the page at top left. - if x1 < 0: - x1 = 0 - - if y1 < 0: - y1 = 0 - - # Calculate the absolute x offset of the top-left vertex. - if self.col_size_changed: - for col_id in range(col_start): - x_abs += self._size_col(col_id) - else: - # Optimisation for when the column widths haven't changed. - x_abs += self.default_col_pixels * col_start - - x_abs += x1 - - # Calculate the absolute y offset of the top-left vertex. - if self.row_size_changed: - for row_id in range(row_start): - y_abs += self._size_row(row_id) - else: - # Optimisation for when the row heights haven't changed. - y_abs += self.default_row_pixels * row_start - - y_abs += y1 - - # Adjust start column for offsets that are greater than the col width. - while x1 >= self._size_col(col_start): - x1 -= self._size_col(col_start) - col_start += 1 - - # Adjust start row for offsets that are greater than the row height. - while y1 >= self._size_row(row_start): - y1 -= self._size_row(row_start) - row_start += 1 - - # Initialise end cell to the same as the start cell. - col_end = col_start - row_end = row_start - - width = width + x1 - height = height + y1 - - # Subtract the underlying cell widths to find end cell of the object. - while width >= self._size_col(col_end): - width -= self._size_col(col_end) - col_end += 1 - - # Subtract the underlying cell heights to find end cell of the object. - - while height >= self._size_row(row_end): - height -= self._size_row(row_end) - row_end += 1 - - # The end vertices are whatever is left from the width and height. - x2 = width - y2 = height - - return ([col_start, row_start, x1, y1, col_end, row_end, x2, y2, - x_abs, y_abs]) - - def _size_col(self, col): - # Convert the width of a cell from user's units to pixels. Excel rounds - # the column width to the nearest pixel. If the width hasn't been set - # by the user we use the default value. If the column is hidden it - # has a value of zero. - max_digit_width = 7 # For Calabri 11. - padding = 5 - pixels = 0 - - # Look up the cell value to see if it has been changed. - if col in self.col_sizes and self.col_sizes[col] is not None: - width = self.col_sizes[col] - - # Convert to pixels. - if width == 0: - pixels = 0 - elif width < 1: - pixels = int(width * (max_digit_width + padding) + 0.5) - else: - pixels = int(width * max_digit_width + 0.5) + padding - else: - pixels = self.default_col_pixels - - return pixels - - def _size_row(self, row): - # Convert the height of a cell from user's units to pixels. If the - # height hasn't been set by the user we use the default value. If - # the row is hidden it has a value of zero. - pixels = 0 - - # Look up the cell value to see if it has been changed - if row in self.row_sizes: - height = self.row_sizes[row] - - if height == 0: - pixels = 0 - else: - pixels = int(4.0 / 3.0 * height) - else: - pixels = int(4.0 / 3.0 * self.default_row_height) - - return pixels - - def _comment_params(self, row, col, string, options): - # This method handles the additional optional parameters to - # write_comment() as well as calculating the comment object - # position and vertices. - default_width = 128 - default_height = 74 - - params = { - 'author': None, - 'color': '#ffffe1', - 'start_cell': None, - 'start_col': None, - 'start_row': None, - 'visible': None, - 'width': default_width, - 'height': default_height, - 'x_offset': None, - 'x_scale': 1, - 'y_offset': None, - 'y_scale': 1, - } - - # Overwrite the defaults with any user supplied values. Incorrect or - # misspelled parameters are silently ignored. - for key in options.keys(): - params[key] = options[key] - - # Ensure that a width and height have been set. - if not params['width']: - params['width'] = default_width - if not params['height']: - params['height'] = default_height - - # Set the comment background color. - params['color'] = xl_color(params['color']).lower() - - # Convert from Excel XML style color to XML html style color. - params['color'] = params['color'].replace('ff', '#', 1) - - # Convert a cell reference to a row and column. - if params['start_cell'] is not None: - (start_row, start_col) = xl_cell_to_rowcol(params['start_cell']) - params['start_row'] = start_row - params['start_col'] = start_col - - # Set the default start cell and offsets for the comment. These are - # generally fixed in relation to the parent cell. However there are - # some edge cases for cells at the, er, edges. - row_max = self.xls_rowmax - col_max = self.xls_colmax - - if params['start_row'] is None: - if row == 0: - params['start_row'] = 0 - elif row == row_max - 3: - params['start_row'] = row_max - 7 - elif row == row_max - 2: - params['start_row'] = row_max - 6 - elif row == row_max - 1: - params['start_row'] = row_max - 5 - else: - params['start_row'] = row - 1 - - if params['y_offset'] is None: - if row == 0: - params['y_offset'] = 2 - elif row == row_max - 3: - params['y_offset'] = 16 - elif row == row_max - 2: - params['y_offset'] = 16 - elif row == row_max - 1: - params['y_offset'] = 14 - else: - params['y_offset'] = 10 - - if params['start_col'] is None: - if col == col_max - 3: - params['start_col'] = col_max - 6 - elif col == col_max - 2: - params['start_col'] = col_max - 5 - elif col == col_max - 1: - params['start_col'] = col_max - 4 - else: - params['start_col'] = col + 1 - - if params['x_offset'] is None: - if col == col_max - 3: - params['x_offset'] = 49 - elif col == col_max - 2: - params['x_offset'] = 49 - elif col == col_max - 1: - params['x_offset'] = 49 - else: - params['x_offset'] = 15 - - # Scale the size of the comment box if required. - if params['x_scale']: - params['width'] = params['width'] * params['x_scale'] - - if params['y_scale']: - params['height'] = params['height'] * params['y_scale'] - - # Round the dimensions to the nearest pixel. - params['width'] = int(0.5 + params['width']) - params['height'] = int(0.5 + params['height']) - - # Calculate the positions of the comment object. - vertices = self._position_object_pixels( - params['start_col'], params['start_row'], params['x_offset'], - params['y_offset'], params['width'], params['height']) - - # Add the width and height for VML. - vertices.append(params['width']) - vertices.append(params['height']) - - return ([row, col, string, params['author'], - params['visible'], params['color']] + [vertices]) - - def _button_params(self, row, col, options): - # This method handles the parameters passed to insert_button() as well - # as calculating the comment object position and vertices. - - default_height = self.default_row_pixels - default_width = self.default_col_pixels - - button_number = 1 + len(self.buttons_list) - button = {'row': row, 'col': col, 'font': {}} - params = {} - - # Overwrite the defaults with any user supplied values. Incorrect or - # misspelled parameters are silently ignored. - for key in options.keys(): - params[key] = options[key] - - # Set the button caption. - caption = params.get('caption') - - # Set a default caption if none was specified by user. - if caption is None: - caption = 'Button %d' % button_number - - button['font']['caption'] = caption - - # Set the macro name. - if params.get('macro'): - button['macro'] = '[0]!' + params['macro'] - else: - button['macro'] = '[0]!Button%d_Click' % button_number - - # Ensure that a width and height have been set. - params['width'] = params.get('width', default_width) - params['height'] = params.get('height', default_height) - - # Set the x/y offsets. - params['x_offset'] = params.get('x_offset', 0) - params['y_offset'] = params.get('y_offset', 0) - - # Scale the size of the button if required. - params['width'] = params['width'] * params.get('x_scale', 1) - params['height'] = params['height'] * params.get('y_scale', 1) - - # Round the dimensions to the nearest pixel. - params['width'] = int(0.5 + params['width']) - params['height'] = int(0.5 + params['height']) - - params['start_row'] = row - params['start_col'] = col - - # Calculate the positions of the button object. - vertices = self._position_object_pixels( - params['start_col'], params['start_row'], params['x_offset'], - params['y_offset'], params['width'], params['height']) - - # Add the width and height for VML. - vertices.append(params['width']) - vertices.append(params['height']) - - button['vertices'] = vertices - - return button - - def _prepare_vml_objects(self, vml_data_id, vml_shape_id, vml_drawing_id, - comment_id): - comments = [] - # Sort the comments into row/column order for easier comparison - # testing and set the external links for comments and buttons. - row_nums = sorted(self.comments.keys()) - - for row in row_nums: - col_nums = sorted(self.comments[row].keys()) - - for col in col_nums: - # Set comment visibility if required and not user defined. - if self.comments_visible: - if self.comments[row][col][4] is None: - self.comments[row][col][4] = 1 - - # Set comment author if not already user defined. - if self.comments[row][col][3] is None: - self.comments[row][col][3] = self.comments_author - - comments.append(self.comments[row][col]) - - self.external_vml_links.append(['/vmlDrawing', - '../drawings/vmlDrawing' - + str(vml_drawing_id) - + '.vml']) - - if self.has_comments: - self.comments_list = comments - - self.external_comment_links.append(['/comments', - '../comments' - + str(comment_id) - + '.xml']) - - count = len(comments) - start_data_id = vml_data_id - - # The VML o:idmap data id contains a comma separated range when there - # is more than one 1024 block of comments, like this: data="1,2". - for i in range(int(count / 1024)): - vml_data_id = '%s,%d' % (vml_data_id, start_data_id + i + 1) - - self.vml_data_id = vml_data_id - self.vml_shape_id = vml_shape_id - - return count - - def _prepare_header_vml_objects(self, vml_header_id, vml_drawing_id): - # Set up external linkage for VML header/footer images. - - self.vml_header_id = vml_header_id - - self.external_vml_links.append(['/vmlDrawing', - '../drawings/vmlDrawing' - + str(vml_drawing_id) + '.vml']) - - def _prepare_tables(self, table_id, seen): - # Set the table ids for the worksheet tables. - for table in self.tables: - table['id'] = table_id - - if table.get('name') is None: - # Set a default name. - table['name'] = 'Table' + str(table_id) - - # Check for duplicate table names. - name = table['name'].lower() - - if name in seen: - raise Exception("invalid duplicate table name '%s' found." % - table['name']) - else: - seen[name] = True - - # Store the link used for the rels file. - self.external_table_links.append(['/table', - '../tables/table' - + str(table_id) - + '.xml']) - table_id += 1 - - def _table_function_to_formula(self, function, col_name): - # Convert a table total function to a worksheet formula. - formula = '' - - subtotals = { - 'average': 101, - 'countNums': 102, - 'count': 103, - 'max': 104, - 'min': 105, - 'stdDev': 107, - 'sum': 109, - 'var': 110, - } - - if function in subtotals: - func_num = subtotals[function] - formula = "SUBTOTAL(%s,[%s])" % (func_num, col_name) - else: - warn("Unsupported function '%s' in add_table()" % function) - - return formula - - def _set_spark_color(self, sparkline, options, user_color): - # Set the sparkline color. - if user_color not in options: - return - - sparkline[user_color] = {'rgb': xl_color(options[user_color])} - - def _get_range_data(self, row_start, col_start, row_end, col_end): - # Returns a range of data from the worksheet _table to be used in - # chart cached data. Strings are returned as SST ids and decoded - # in the workbook. Return None for data that doesn't exist since - # Excel can chart series with data missing. - - if self.optimization: - return () - - data = [] - - # Iterate through the table data. - for row_num in range(row_start, row_end + 1): - # Store None if row doesn't exist. - if row_num not in self.table: - data.append(None) - continue - - for col_num in range(col_start, col_end + 1): - - if col_num in self.table[row_num]: - cell = self.table[row_num][col_num] - - if type(cell).__name__ == 'Number': - # Return a number with Excel's precision. - data.append("%.15g" % cell.number) - - elif type(cell).__name__ == 'String': - # Return a string from it's shared string index. - index = cell.string - string = self.str_table._get_shared_string(index) - - data.append(string) - - elif (type(cell).__name__ == 'Formula' - or type(cell).__name__ == 'ArrayFormula'): - # Return the formula value. - value = cell.value - - if value is None: - value = 0 - - data.append(value) - - elif type(cell).__name__ == 'Blank': - # Return a empty cell. - data.append('') - else: - - # Store None if column doesn't exist. - data.append(None) - - return data - - def _csv_join(self, *items): - # Create a csv string for use with data validation formulas and lists. - - # Convert non string types to string. - items = [str(item) if not isinstance(item, str_types) else item - for item in items] - - return ','.join(items) - - ########################################################################### - # - # The following font methods are, more or less, duplicated from the - # Styles class. Not the cleanest version of reuse but works for now. - # - ########################################################################### - def _write_font(self, xf_format): - # Write the <font> element. - xml_writer = self.rstring - - xml_writer._xml_start_tag('rPr') - - # Handle the main font properties. - if xf_format.bold: - xml_writer._xml_empty_tag('b') - if xf_format.italic: - xml_writer._xml_empty_tag('i') - if xf_format.font_strikeout: - xml_writer._xml_empty_tag('strike') - if xf_format.font_outline: - xml_writer._xml_empty_tag('outline') - if xf_format.font_shadow: - xml_writer._xml_empty_tag('shadow') - - # Handle the underline variants. - if xf_format.underline: - self._write_underline(xf_format.underline) - - # Handle super/subscript. - if xf_format.font_script == 1: - self._write_vert_align('superscript') - if xf_format.font_script == 2: - self._write_vert_align('subscript') - - # Write the font size - xml_writer._xml_empty_tag('sz', [('val', xf_format.font_size)]) - - # Handle colors. - if xf_format.theme: - self._write_color('theme', xf_format.theme) - elif xf_format.color_indexed: - self._write_color('indexed', xf_format.color_indexed) - elif xf_format.font_color: - color = self._get_palette_color(xf_format.font_color) - self._write_rstring_color('rgb', color) - else: - self._write_rstring_color('theme', 1) - - # Write some other font properties related to font families. - xml_writer._xml_empty_tag('rFont', [('val', xf_format.font_name)]) - xml_writer._xml_empty_tag('family', [('val', xf_format.font_family)]) - - if xf_format.font_name == 'Calibri' and not xf_format.hyperlink: - xml_writer._xml_empty_tag('scheme', - [('val', xf_format.font_scheme)]) - - xml_writer._xml_end_tag('rPr') - - def _write_underline(self, underline): - # Write the underline font element. - attributes = [] - - # Handle the underline variants. - if underline == 2: - attributes = [('val', 'double')] - elif underline == 33: - attributes = [('val', 'singleAccounting')] - elif underline == 34: - attributes = [('val', 'doubleAccounting')] - - self.rstring._xml_empty_tag('u', attributes) - - def _write_vert_align(self, val): - # Write the <vertAlign> font sub-element. - attributes = [('val', val)] - - self.rstring._xml_empty_tag('vertAlign', attributes) - - def _write_rstring_color(self, name, value): - # Write the <color> element. - attributes = [(name, value)] - - self.rstring._xml_empty_tag('color', attributes) - - def _get_palette_color(self, color): - # Convert the RGB color. - if color[0] == '#': - color = color[1:] - - return "FF" + color.upper() - - def _isnan(self, x): - # Workaround for lack of math.isnan in Python 2.5/Jython. - return x != x - - def _isinf(self, x): - # Workaround for lack of math.isinf in Python 2.5/Jython. - return (x - x) != 0 - - def _opt_close(self): - # Close the row data filehandle in optimization mode. - if not self.row_data_fh_closed: - self.row_data_fh.close() - self.row_data_fh_closed = True - - def _opt_reopen(self): - # Reopen the row data filehandle in optimization mode. - if self.row_data_fh_closed: - filename = self.row_data_filename - self.row_data_fh = codecs.open(filename, 'a+', 'utf-8') - self.row_data_fh_closed = False - self.fh = self.row_data_fh - - ########################################################################### - # - # XML methods. - # - ########################################################################### - - def _write_worksheet(self): - # Write the <worksheet> element. This is the root element. - - schema = 'http://schemas.openxmlformats.org/' - xmlns = schema + 'spreadsheetml/2006/main' - xmlns_r = schema + 'officeDocument/2006/relationships' - xmlns_mc = schema + 'markup-compatibility/2006' - ms_schema = 'http://schemas.microsoft.com/' - xmlns_x14ac = ms_schema + 'office/spreadsheetml/2009/9/ac' - - attributes = [ - ('xmlns', xmlns), - ('xmlns:r', xmlns_r)] - - # Add some extra attributes for Excel 2010. Mainly for sparklines. - if self.excel_version == 2010: - attributes.append(('xmlns:mc', xmlns_mc)) - attributes.append(('xmlns:x14ac', xmlns_x14ac)) - attributes.append(('mc:Ignorable', 'x14ac')) - - self._xml_start_tag('worksheet', attributes) - - def _write_dimension(self): - # Write the <dimension> element. This specifies the range of - # cells in the worksheet. As a special case, empty - # spreadsheets use 'A1' as a range. - - if self.dim_rowmin is None and self.dim_colmin is None: - # If the min dimensions are not defined then no dimensions - # have been set and we use the default 'A1'. - ref = 'A1' - - elif self.dim_rowmin is None and self.dim_colmin is not None: - # If the row dimensions aren't set but the column - # dimensions are set then they have been changed via - # set_column(). - - if self.dim_colmin == self.dim_colmax: - # The dimensions are a single cell and not a range. - ref = xl_rowcol_to_cell(0, self.dim_colmin) - else: - # The dimensions are a cell range. - cell_1 = xl_rowcol_to_cell(0, self.dim_colmin) - cell_2 = xl_rowcol_to_cell(0, self.dim_colmax) - ref = cell_1 + ':' + cell_2 - - elif (self.dim_rowmin == self.dim_rowmax and - self.dim_colmin == self.dim_colmax): - # The dimensions are a single cell and not a range. - ref = xl_rowcol_to_cell(self.dim_rowmin, self.dim_colmin) - else: - # The dimensions are a cell range. - cell_1 = xl_rowcol_to_cell(self.dim_rowmin, self.dim_colmin) - cell_2 = xl_rowcol_to_cell(self.dim_rowmax, self.dim_colmax) - ref = cell_1 + ':' + cell_2 - - self._xml_empty_tag('dimension', [('ref', ref)]) - - def _write_sheet_views(self): - # Write the <sheetViews> element. - self._xml_start_tag('sheetViews') - - # Write the sheetView element. - self._write_sheet_view() - - self._xml_end_tag('sheetViews') - - def _write_sheet_view(self): - # Write the <sheetViews> element. - attributes = [] - - # Hide screen gridlines if required - if not self.screen_gridlines: - attributes.append(('showGridLines', 0)) - - # Hide zeroes in cells. - if not self.show_zeros: - attributes.append(('showZeros', 0)) - - # Display worksheet right to left for Hebrew, Arabic and others. - if self.is_right_to_left: - attributes.append(('rightToLeft', 1)) - - # Show that the sheet tab is selected. - if self.selected: - attributes.append(('tabSelected', 1)) - - # Turn outlines off. Also required in the outlinePr element. - if not self.outline_on: - attributes.append(("showOutlineSymbols", 0)) - - # Set the page view/layout mode if required. - if self.page_view: - attributes.append(('view', 'pageLayout')) - - # Set the zoom level. - if self.zoom != 100: - if not self.page_view: - attributes.append(('zoomScale', self.zoom)) - if self.zoom_scale_normal: - attributes.append(('zoomScaleNormal', self.zoom)) - - attributes.append(('workbookViewId', 0)) - - if self.panes or len(self.selections): - self._xml_start_tag('sheetView', attributes) - self._write_panes() - self._write_selections() - self._xml_end_tag('sheetView') - else: - self._xml_empty_tag('sheetView', attributes) - - def _write_sheet_format_pr(self): - # Write the <sheetFormatPr> element. - default_row_height = self.default_row_height - row_level = self.outline_row_level - col_level = self.outline_col_level - - attributes = [('defaultRowHeight', default_row_height)] - - if self.default_row_height != self.original_row_height: - attributes.append(('customHeight', 1)) - - if self.default_row_zeroed: - attributes.append(('zeroHeight', 1)) - - if row_level: - attributes.append(('outlineLevelRow', row_level)) - if col_level: - attributes.append(('outlineLevelCol', col_level)) - - if self.excel_version == 2010: - attributes.append(('x14ac:dyDescent', '0.25')) - - self._xml_empty_tag('sheetFormatPr', attributes) - - def _write_cols(self): - # Write the <cols> element and <col> sub elements. - - # Exit unless some column have been formatted. - if not self.colinfo: - return - - self._xml_start_tag('cols') - - for col in sorted(self.colinfo.keys()): - self._write_col_info(self.colinfo[col]) - - self._xml_end_tag('cols') - - def _write_col_info(self, col_info): - # Write the <col> element. - - (col_min, col_max, width, cell_format, - hidden, level, collapsed) = col_info - - custom_width = 1 - xf_index = 0 - - # Get the cell_format index. - if cell_format: - xf_index = cell_format._get_xf_index() - - # Set the Excel default column width. - if width is None: - if not hidden: - width = 8.43 - custom_width = 0 - else: - width = 0 - elif width == 8.43: - # Width is defined but same as default. - custom_width = 0 - - # Convert column width from user units to character width. - if width > 0: - # For Calabri 11. - max_digit_width = 7 - padding = 5 - - if width < 1: - width = int((int(width * (max_digit_width + padding) + 0.5)) - / float(max_digit_width) * 256.0) / 256.0 - else: - width = int((int(width * max_digit_width + 0.5) + padding) - / float(max_digit_width) * 256.0) / 256.0 - - attributes = [ - ('min', col_min + 1), - ('max', col_max + 1), - ('width', "%.15g" % width)] - - if xf_index: - attributes.append(('style', xf_index)) - if hidden: - attributes.append(('hidden', '1')) - if custom_width: - attributes.append(('customWidth', '1')) - if level: - attributes.append(('outlineLevel', level)) - if collapsed: - attributes.append(('collapsed', '1')) - - self._xml_empty_tag('col', attributes) - - def _write_sheet_data(self): - # Write the <sheetData> element. - - if self.dim_rowmin is None: - # If the dimensions aren't defined there is no data to write. - self._xml_empty_tag('sheetData') - else: - self._xml_start_tag('sheetData') - self._write_rows() - self._xml_end_tag('sheetData') - - def _write_optimized_sheet_data(self): - # Write the <sheetData> element when the memory optimisation is on. - # In this case we read the data stored in the temp file and rewrite - # it to the XML sheet file. - if self.dim_rowmin is None: - # If the dimensions aren't defined then there is no data to write. - self._xml_empty_tag('sheetData') - else: - self._xml_start_tag('sheetData') - - # Rewind the filehandle that was used for temp row data. - buff_size = 65536 - self.row_data_fh.seek(0) - data = self.row_data_fh.read(buff_size) - - while data: - self.fh.write(data) - data = self.row_data_fh.read(buff_size) - - self.row_data_fh.close() - os.unlink(self.row_data_filename) - - self._xml_end_tag('sheetData') - - def _write_page_margins(self): - # Write the <pageMargins> element. - attributes = [ - ('left', self.margin_left), - ('right', self.margin_right), - ('top', self.margin_top), - ('bottom', self.margin_bottom), - ('header', self.margin_header), - ('footer', self.margin_footer)] - - self._xml_empty_tag('pageMargins', attributes) - - def _write_page_setup(self): - # Write the <pageSetup> element. - # - # The following is an example taken from Excel. - # - # <pageSetup - # paperSize="9" - # scale="110" - # fitToWidth="2" - # fitToHeight="2" - # pageOrder="overThenDown" - # orientation="portrait" - # blackAndWhite="1" - # draft="1" - # horizontalDpi="200" - # verticalDpi="200" - # r:id="rId1" - # /> - # - attributes = [] - - # Skip this element if no page setup has changed. - if not self.page_setup_changed: - return - - # Set paper size. - if self.paper_size: - attributes.append(('paperSize', self.paper_size)) - - # Set the print_scale. - if self.print_scale != 100: - attributes.append(('scale', self.print_scale)) - - # Set the "Fit to page" properties. - if self.fit_page and self.fit_width != 1: - attributes.append(('fitToWidth', self.fit_width)) - - if self.fit_page and self.fit_height != 1: - attributes.append(('fitToHeight', self.fit_height)) - - # Set the page print direction. - if self.page_order: - attributes.append(('pageOrder', "overThenDown")) - - # Set start page for printing. - if self.page_start > 1: - attributes.append(('firstPageNumber', self.page_start)) - - # Set page orientation. - if self.orientation: - attributes.append(('orientation', 'portrait')) - else: - attributes.append(('orientation', 'landscape')) - - # Set start page for printing. - if self.page_start != 0: - attributes.append(('useFirstPageNumber', '1')) - - # Set the DPI. Mainly only for testing. - if self.vertical_dpi: - attributes.append(('verticalDpi', self.vertical_dpi)) - - if self.horizontal_dpi: - attributes.append(('horizontalDpi', self.horizontal_dpi)) - - self._xml_empty_tag('pageSetup', attributes) - - def _write_print_options(self): - # Write the <printOptions> element. - attributes = [] - - if not self.print_options_changed: - return - - # Set horizontal centering. - if self.hcenter: - attributes.append(('horizontalCentered', 1)) - - # Set vertical centering. - if self.vcenter: - attributes.append(('verticalCentered', 1)) - - # Enable row and column headers. - if self.print_headers: - attributes.append(('headings', 1)) - - # Set printed gridlines. - if self.print_gridlines: - attributes.append(('gridLines', 1)) - - self._xml_empty_tag('printOptions', attributes) - - def _write_header_footer(self): - # Write the <headerFooter> element. - attributes = [] - - if not self.header_footer_scales: - attributes.append(('scaleWithDoc', 0)) - - if not self.header_footer_aligns: - attributes.append(('alignWithMargins', 0)) - - if self.header_footer_changed: - self._xml_start_tag('headerFooter', attributes) - if self.header: - self._write_odd_header() - if self.footer: - self._write_odd_footer() - self._xml_end_tag('headerFooter') - elif self.excel2003_style: - self._xml_empty_tag('headerFooter', attributes) - - def _write_odd_header(self): - # Write the <headerFooter> element. - self._xml_data_element('oddHeader', self.header) - - def _write_odd_footer(self): - # Write the <headerFooter> element. - self._xml_data_element('oddFooter', self.footer) - - def _write_rows(self): - # Write out the worksheet data as a series of rows and cells. - self._calculate_spans() - - for row_num in range(self.dim_rowmin, self.dim_rowmax + 1): - - if (row_num in self.set_rows or row_num in self.comments - or self.table[row_num]): - # Only process rows with formatting, cell data and/or comments. - - span_index = int(row_num / 16) - - if span_index in self.row_spans: - span = self.row_spans[span_index] - else: - span = None - - if self.table[row_num]: - # Write the cells if the row contains data. - if row_num not in self.set_rows: - self._write_row(row_num, span) - else: - self._write_row(row_num, span, self.set_rows[row_num]) - - for col_num in range(self.dim_colmin, self.dim_colmax + 1): - if col_num in self.table[row_num]: - col_ref = self.table[row_num][col_num] - self._write_cell(row_num, col_num, col_ref) - - self._xml_end_tag('row') - - elif row_num in self.comments: - # Row with comments in cells. - self._write_empty_row(row_num, span, - self.set_rows[row_num]) - else: - # Blank row with attributes only. - self._write_empty_row(row_num, span, - self.set_rows[row_num]) - - def _write_single_row(self, current_row_num=0): - # Write out the worksheet data as a single row with cells. - # This method is used when memory optimisation is on. A single - # row is written and the data table is reset. That way only - # one row of data is kept in memory at any one time. We don't - # write span data in the optimised case since it is optional. - - # Set the new previous row as the current row. - row_num = self.previous_row - self.previous_row = current_row_num - - if (row_num in self.set_rows or row_num in self.comments - or self.table[row_num]): - # Only process rows with formatting, cell data and/or comments. - - # No span data in optimised mode. - span = None - - if self.table[row_num]: - # Write the cells if the row contains data. - if row_num not in self.set_rows: - self._write_row(row_num, span) - else: - self._write_row(row_num, span, self.set_rows[row_num]) - - for col_num in range(self.dim_colmin, self.dim_colmax + 1): - if col_num in self.table[row_num]: - col_ref = self.table[row_num][col_num] - self._write_cell(row_num, col_num, col_ref) - - self._xml_end_tag('row') - else: - # Row attributes or comments only. - self._write_empty_row(row_num, span, self.set_rows[row_num]) - - # Reset table. - self.table.clear() - - def _calculate_spans(self): - # Calculate the "spans" attribute of the <row> tag. This is an - # XLSX optimisation and isn't strictly required. However, it - # makes comparing files easier. The span is the same for each - # block of 16 rows. - spans = {} - span_min = None - span_max = None - - for row_num in range(self.dim_rowmin, self.dim_rowmax + 1): - - if row_num in self.table: - # Calculate spans for cell data. - for col_num in range(self.dim_colmin, self.dim_colmax + 1): - if col_num in self.table[row_num]: - if span_min is None: - span_min = col_num - span_max = col_num - else: - if col_num < span_min: - span_min = col_num - if col_num > span_max: - span_max = col_num - - if row_num in self.comments: - # Calculate spans for comments. - for col_num in range(self.dim_colmin, self.dim_colmax + 1): - if (row_num in self.comments - and col_num in self.comments[row_num]): - if span_min is None: - span_min = col_num - span_max = col_num - else: - if col_num < span_min: - span_min = col_num - if col_num > span_max: - span_max = col_num - - if ((row_num + 1) % 16 == 0) or row_num == self.dim_rowmax: - span_index = int(row_num / 16) - - if span_min is not None: - span_min += 1 - span_max += 1 - spans[span_index] = "%s:%s" % (span_min, span_max) - span_min = None - - self.row_spans = spans - - def _write_row(self, row, spans, properties=None, empty_row=False): - # Write the <row> element. - xf_index = 0 - - if properties: - height, cell_format, hidden, level, collapsed = properties - else: - height, cell_format, hidden, level, collapsed = None, None, 0, 0, 0 - - if height is None: - height = self.default_row_height - - attributes = [('r', row + 1)] - - # Get the cell_format index. - if cell_format: - xf_index = cell_format._get_xf_index() - - # Add row attributes where applicable. - if spans: - attributes.append(('spans', spans)) - - if xf_index: - attributes.append(('s', xf_index)) - - if cell_format: - attributes.append(('customFormat', 1)) - - if height != self.original_row_height: - attributes.append(('ht', height)) - - if hidden: - attributes.append(('hidden', 1)) - - if height != self.original_row_height: - attributes.append(('customHeight', 1)) - - if level: - attributes.append(('outlineLevel', level)) - - if collapsed: - attributes.append(('collapsed', 1)) - - if self.excel_version == 2010: - attributes.append(('x14ac:dyDescent', '0.25')) - - if empty_row: - self._xml_empty_tag_unencoded('row', attributes) - else: - self._xml_start_tag_unencoded('row', attributes) - - def _write_empty_row(self, row, spans, properties=None): - # Write and empty <row> element. - self._write_row(row, spans, properties, empty_row=True) - - def _write_cell(self, row, col, cell): - # Write the <cell> element. - # Note. This is the innermost loop so efficiency is important. - - error_codes = ['#DIV/0!', '#N/A', '#NAME?', '#NULL!', - '#NUM!', '#REF!', '#VALUE!'] - - cell_range = xl_rowcol_to_cell_fast(row, col) - - attributes = [('r', cell_range)] - - if cell.format: - # Add the cell format index. - xf_index = cell.format._get_xf_index() - attributes.append(('s', xf_index)) - elif row in self.set_rows and self.set_rows[row][1]: - # Add the row format. - row_xf = self.set_rows[row][1] - attributes.append(('s', row_xf._get_xf_index())) - elif col in self.col_formats: - # Add the column format. - col_xf = self.col_formats[col] - attributes.append(('s', col_xf._get_xf_index())) - - # Write the various cell types. - if type(cell).__name__ == 'Number': - # Write a number. - self._xml_number_element(cell.number, attributes) - - elif type(cell).__name__ == 'String': - # Write a string. - string = cell.string - - if not self.optimization: - # Write a shared string. - self._xml_string_element(string, attributes) - else: - # Write an optimised in-line string. - - # Escape control characters. See SharedString.pm for details. - string = re.sub('(_x[0-9a-fA-F]{4}_)', r'_x005F\1', string) - string = re.sub(r'([\x00-\x08\x0B-\x1F])', - lambda match: "_x%04X_" % - ord(match.group(1)), string) - - # Write any rich strings without further tags. - if re.search('^<r>', string) and re.search('</r>$', string): - self._xml_rich_inline_string(string, attributes) - else: - # Add attribute to preserve leading or trailing whitespace. - preserve = 0 - if re.search('^\s', string) or re.search('\s$', string): - preserve = 1 - - self._xml_inline_string(string, preserve, attributes) - - elif type(cell).__name__ == 'Formula': - # Write a formula. First check the formula value type. - value = cell.value - if type(cell.value) == bool: - attributes.append(('t', 'b')) - if cell.value: - value = 1 - else: - value = 0 - - elif isinstance(cell.value, str_types): - if cell.value in error_codes: - attributes.append(('t', 'e')) - else: - attributes.append(('t', 'str')) - - self._xml_formula_element(cell.formula, value, attributes) - - elif type(cell).__name__ == 'ArrayFormula': - # Write a array formula. - - # First check if the formula value is a string. - try: - float(cell.value) - except ValueError: - attributes.append(('t', 'str')) - - # Write an array formula. - self._xml_start_tag('c', attributes) - self._write_cell_array_formula(cell.formula, cell.range) - self._write_cell_value(cell.value) - self._xml_end_tag('c') - - elif type(cell).__name__ == 'Blank': - # Write a empty cell. - self._xml_empty_tag('c', attributes) - - elif type(cell).__name__ == 'Boolean': - # Write a boolean cell. - attributes.append(('t', 'b')) - self._xml_start_tag('c', attributes) - self._write_cell_value(cell.boolean) - self._xml_end_tag('c') - - def _write_cell_value(self, value): - # Write the cell value <v> element. - if value is None: - value = '' - - self._xml_data_element('v', value) - - def _write_cell_array_formula(self, formula, cell_range): - # Write the cell array formula <f> element. - attributes = [ - ('t', 'array'), - ('ref', cell_range) - ] - - self._xml_data_element('f', formula, attributes) - - def _write_sheet_pr(self): - # Write the <sheetPr> element for Sheet level properties. - attributes = [] - - if (not self.fit_page - and not self.filter_on - and not self.tab_color - and not self.outline_changed - and not self.vba_codename): - return - - if self.vba_codename: - attributes.append(('codeName', self.vba_codename)) - - if self.filter_on: - attributes.append(('filterMode', 1)) - - if (self.fit_page - or self.tab_color - or self.outline_changed): - self._xml_start_tag('sheetPr', attributes) - self._write_tab_color() - self._write_outline_pr() - self._write_page_set_up_pr() - self._xml_end_tag('sheetPr') - else: - self._xml_empty_tag('sheetPr', attributes) - - def _write_page_set_up_pr(self): - # Write the <pageSetUpPr> element. - if not self.fit_page: - return - - attributes = [('fitToPage', 1)] - self._xml_empty_tag('pageSetUpPr', attributes) - - def _write_tab_color(self): - # Write the <tabColor> element. - color = self.tab_color - - if not color: - return - - attributes = [('rgb', color)] - - self._xml_empty_tag('tabColor', attributes) - - def _write_outline_pr(self): - # Write the <outlinePr> element. - attributes = [] - - if not self.outline_changed: - return - - if self.outline_style: - attributes.append(("applyStyles", 1)) - if not self.outline_below: - attributes.append(("summaryBelow", 0)) - if not self.outline_right: - attributes.append(("summaryRight", 0)) - if not self.outline_on: - attributes.append(("showOutlineSymbols", 0)) - - self._xml_empty_tag('outlinePr', attributes) - - def _write_row_breaks(self): - # Write the <rowBreaks> element. - page_breaks = self._sort_pagebreaks(self.hbreaks) - - if not page_breaks: - return - - count = len(page_breaks) - - attributes = [ - ('count', count), - ('manualBreakCount', count), - ] - - self._xml_start_tag('rowBreaks', attributes) - - for row_num in page_breaks: - self._write_brk(row_num, 16383) - - self._xml_end_tag('rowBreaks') - - def _write_col_breaks(self): - # Write the <colBreaks> element. - page_breaks = self._sort_pagebreaks(self.vbreaks) - - if not page_breaks: - return - - count = len(page_breaks) - - attributes = [ - ('count', count), - ('manualBreakCount', count), - ] - - self._xml_start_tag('colBreaks', attributes) - - for col_num in page_breaks: - self._write_brk(col_num, 1048575) - - self._xml_end_tag('colBreaks') - - def _write_brk(self, brk_id, brk_max): - # Write the <brk> element. - attributes = [ - ('id', brk_id), - ('max', brk_max), - ('man', 1)] - - self._xml_empty_tag('brk', attributes) - - def _write_merge_cells(self): - # Write the <mergeCells> element. - merged_cells = self.merge - count = len(merged_cells) - - if not count: - return - - attributes = [('count', count)] - - self._xml_start_tag('mergeCells', attributes) - - for merged_range in merged_cells: - - # Write the mergeCell element. - self._write_merge_cell(merged_range) - - self._xml_end_tag('mergeCells') - - def _write_merge_cell(self, merged_range): - # Write the <mergeCell> element. - (row_min, col_min, row_max, col_max) = merged_range - - # Convert the merge dimensions to a cell range. - cell_1 = xl_rowcol_to_cell(row_min, col_min) - cell_2 = xl_rowcol_to_cell(row_max, col_max) - ref = cell_1 + ':' + cell_2 - - attributes = [('ref', ref)] - - self._xml_empty_tag('mergeCell', attributes) - - def _write_hyperlinks(self): - # Process any stored hyperlinks in row/col order and write the - # <hyperlinks> element. The attributes are different for internal - # and external links. - hlink_refs = [] - display = None - - # Sort the hyperlinks into row order. - row_nums = sorted(self.hyperlinks.keys()) - - # Exit if there are no hyperlinks to process. - if not row_nums: - return - - # Iterate over the rows. - for row_num in row_nums: - # Sort the hyperlinks into column order. - col_nums = sorted(self.hyperlinks[row_num].keys()) - - # Iterate over the columns. - for col_num in col_nums: - # Get the link data for this cell. - link = self.hyperlinks[row_num][col_num] - link_type = link["link_type"] - - # If the cell isn't a string then we have to add the url as - # the string to display. - if (self.table - and self.table[row_num] - and self.table[row_num][col_num]): - cell = self.table[row_num][col_num] - if type(cell).__name__ != 'String': - display = link["url"] - - if link_type == 1: - # External link with rel file relationship. - self.rel_count += 1 - - hlink_refs.append([link_type, - row_num, - col_num, - self.rel_count, - link["str"], - display, - link["tip"]]) - - # Links for use by the packager. - self.external_hyper_links.append(['/hyperlink', - link["url"], 'External']) - else: - # Internal link with rel file relationship. - hlink_refs.append([link_type, - row_num, - col_num, - link["url"], - link["str"], - link["tip"]]) - - # Write the hyperlink elements. - self._xml_start_tag('hyperlinks') - - for args in hlink_refs: - link_type = args.pop(0) - - if link_type == 1: - self._write_hyperlink_external(*args) - elif link_type == 2: - self._write_hyperlink_internal(*args) - - self._xml_end_tag('hyperlinks') - - def _write_hyperlink_external(self, row, col, id_num, location=None, - display=None, tooltip=None): - # Write the <hyperlink> element for external links. - ref = xl_rowcol_to_cell(row, col) - r_id = 'rId' + str(id_num) - - attributes = [ - ('ref', ref), - ('r:id', r_id)] - - if location is not None: - attributes.append(('location', location)) - if display is not None: - attributes.append(('display', display)) - if tooltip is not None: - attributes.append(('tooltip', tooltip)) - - self._xml_empty_tag('hyperlink', attributes) - - def _write_hyperlink_internal(self, row, col, location=None, display=None, - tooltip=None): - # Write the <hyperlink> element for internal links. - ref = xl_rowcol_to_cell(row, col) - - attributes = [ - ('ref', ref), - ('location', location)] - - if tooltip is not None: - attributes.append(('tooltip', tooltip)) - attributes.append(('display', display)) - - self._xml_empty_tag('hyperlink', attributes) - - def _write_auto_filter(self): - # Write the <autoFilter> element. - if not self.autofilter_ref: - return - - attributes = [('ref', self.autofilter_ref)] - - if self.filter_on: - # Autofilter defined active filters. - self._xml_start_tag('autoFilter', attributes) - self._write_autofilters() - self._xml_end_tag('autoFilter') - - else: - # Autofilter defined without active filters. - self._xml_empty_tag('autoFilter', attributes) - - def _write_autofilters(self): - # Function to iterate through the columns that form part of an - # autofilter range and write the appropriate filters. - (col1, col2) = self.filter_range - - for col in range(col1, col2 + 1): - # Skip if column doesn't have an active filter. - if col not in self.filter_cols: - continue - - # Retrieve the filter tokens and write the autofilter records. - tokens = self.filter_cols[col] - filter_type = self.filter_type[col] - - # Filters are relative to first column in the autofilter. - self._write_filter_column(col - col1, filter_type, tokens) - - def _write_filter_column(self, col_id, filter_type, filters): - # Write the <filterColumn> element. - attributes = [('colId', col_id)] - - self._xml_start_tag('filterColumn', attributes) - - if filter_type == 1: - # Type == 1 is the new XLSX style filter. - self._write_filters(filters) - else: - # Type == 0 is the classic "custom" filter. - self._write_custom_filters(filters) - - self._xml_end_tag('filterColumn') - - def _write_filters(self, filters): - # Write the <filters> element. - - if len(filters) == 1 and filters[0] == 'blanks': - # Special case for blank cells only. - self._xml_empty_tag('filters', [('blank', 1)]) - else: - # General case. - self._xml_start_tag('filters') - - for autofilter in filters: - self._write_filter(autofilter) - - self._xml_end_tag('filters') - - def _write_filter(self, val): - # Write the <filter> element. - attributes = [('val', val)] - - self._xml_empty_tag('filter', attributes) - - def _write_custom_filters(self, tokens): - # Write the <customFilters> element. - if len(tokens) == 2: - # One filter expression only. - self._xml_start_tag('customFilters') - self._write_custom_filter(*tokens) - self._xml_end_tag('customFilters') - else: - # Two filter expressions. - attributes = [] - - # Check if the "join" operand is "and" or "or". - if tokens[2] == 0: - attributes = [('and', 1)] - else: - attributes = [('and', 0)] - - # Write the two custom filters. - self._xml_start_tag('customFilters', attributes) - self._write_custom_filter(tokens[0], tokens[1]) - self._write_custom_filter(tokens[3], tokens[4]) - self._xml_end_tag('customFilters') - - def _write_custom_filter(self, operator, val): - # Write the <customFilter> element. - attributes = [] - - operators = { - 1: 'lessThan', - 2: 'equal', - 3: 'lessThanOrEqual', - 4: 'greaterThan', - 5: 'notEqual', - 6: 'greaterThanOrEqual', - 22: 'equal', - } - - # Convert the operator from a number to a descriptive string. - if operators[operator] is not None: - operator = operators[operator] - else: - warn("Unknown operator = %s" % operator) - - # The 'equal' operator is the default attribute and isn't stored. - if not operator == 'equal': - attributes.append(('operator', operator)) - attributes.append(('val', val)) - - self._xml_empty_tag('customFilter', attributes) - - def _write_sheet_protection(self): - # Write the <sheetProtection> element. - attributes = [] - - if not self.protect_options: - return - - options = self.protect_options - - if options['password']: - attributes.append(('password', options['password'])) - if options['sheet']: - attributes.append(('sheet', 1)) - if options['content']: - attributes.append(('content', 1)) - if not options['objects']: - attributes.append(('objects', 1)) - if not options['scenarios']: - attributes.append(('scenarios', 1)) - if options['format_cells']: - attributes.append(('formatCells', 0)) - if options['format_columns']: - attributes.append(('formatColumns', 0)) - if options['format_rows']: - attributes.append(('formatRows', 0)) - if options['insert_columns']: - attributes.append(('insertColumns', 0)) - if options['insert_rows']: - attributes.append(('insertRows', 0)) - if options['insert_hyperlinks']: - attributes.append(('insertHyperlinks', 0)) - if options['delete_columns']: - attributes.append(('deleteColumns', 0)) - if options['delete_rows']: - attributes.append(('deleteRows', 0)) - if not options['select_locked_cells']: - attributes.append(('selectLockedCells', 1)) - if options['sort']: - attributes.append(('sort', 0)) - if options['autofilter']: - attributes.append(('autoFilter', 0)) - if options['pivot_tables']: - attributes.append(('pivotTables', 0)) - if not options['select_unlocked_cells']: - attributes.append(('selectUnlockedCells', 1)) - - self._xml_empty_tag('sheetProtection', attributes) - - def _write_drawings(self): - # Write the <drawing> elements. - if not self.drawing: - return - - self.rel_count += 1 - self._write_drawing(self.rel_count) - - def _write_drawing(self, drawing_id): - # Write the <drawing> element. - r_id = 'rId' + str(drawing_id) - - attributes = [('r:id', r_id)] - - self._xml_empty_tag('drawing', attributes) - - def _write_legacy_drawing(self): - # Write the <legacyDrawing> element. - if not self.has_vml: - return - - # Increment the relationship id for any drawings or comments. - self.rel_count += 1 - r_id = 'rId' + str(self.rel_count) - - attributes = [('r:id', r_id)] - - self._xml_empty_tag('legacyDrawing', attributes) - - def _write_legacy_drawing_hf(self): - # Write the <legacyDrawingHF> element. - if not self.has_header_vml: - return - - # Increment the relationship id for any drawings or comments. - self.rel_count += 1 - r_id = 'rId' + str(self.rel_count) - - attributes = [('r:id', r_id)] - - self._xml_empty_tag('legacyDrawingHF', attributes) - - def _write_data_validations(self): - # Write the <dataValidations> element. - validations = self.validations - count = len(validations) - - if not count: - return - - attributes = [('count', count)] - - self._xml_start_tag('dataValidations', attributes) - - for validation in validations: - - # Write the dataValidation element. - self._write_data_validation(validation) - - self._xml_end_tag('dataValidations') - - def _write_data_validation(self, options): - # Write the <dataValidation> element. - sqref = '' - attributes = [] - - # Set the cell range(s) for the data validation. - for cells in options['cells']: - - # Add a space between multiple cell ranges. - if sqref != '': - sqref += ' ' - - (row_first, col_first, row_last, col_last) = cells - - # Swap last row/col for first row/col as necessary - if row_first > row_last: - (row_first, row_last) = (row_last, row_first) - - if col_first > col_last: - (col_first, col_last) = (col_last, col_first) - - # If the first and last cell are the same write a single cell. - if (row_first == row_last) and (col_first == col_last): - sqref += xl_rowcol_to_cell(row_first, col_first) - else: - sqref += xl_range(row_first, col_first, row_last, col_last) - - if options['validate'] != 'none': - attributes.append(('type', options['validate'])) - - if options['criteria'] != 'between': - attributes.append(('operator', options['criteria'])) - - if 'error_type' in options: - if options['error_type'] == 1: - attributes.append(('errorStyle', 'warning')) - if options['error_type'] == 2: - attributes.append(('errorStyle', 'information')) - - if options['ignore_blank']: - attributes.append(('allowBlank', 1)) - - if not options['dropdown']: - attributes.append(('showDropDown', 1)) - - if options['show_input']: - attributes.append(('showInputMessage', 1)) - - if options['show_error']: - attributes.append(('showErrorMessage', 1)) - - if 'error_title' in options: - attributes.append(('errorTitle', options['error_title'])) - - if 'error_message' in options: - attributes.append(('error', options['error_message'])) - - if 'input_title' in options: - attributes.append(('promptTitle', options['input_title'])) - - if 'input_message' in options: - attributes.append(('prompt', options['input_message'])) - - attributes.append(('sqref', sqref)) - - if options['validate'] == 'none': - self._xml_empty_tag('dataValidation', attributes) - else: - self._xml_start_tag('dataValidation', attributes) - - # Write the formula1 element. - self._write_formula_1(options['value']) - - # Write the formula2 element. - if options['maximum'] is not None: - self._write_formula_2(options['maximum']) - - self._xml_end_tag('dataValidation') - - def _write_formula_1(self, formula): - # Write the <formula1> element. - - if type(formula) is list: - formula = self._csv_join(*formula) - formula = '"%s"' % formula - else: - # Check if the formula is a number. - try: - float(formula) - except ValueError: - # Not a number. Remove the formula '=' sign if it exists. - if formula.startswith('='): - formula = formula.lstrip('=') - - self._xml_data_element('formula1', formula) - - def _write_formula_2(self, formula): - # Write the <formula2> element. - - # Check if the formula is a number. - try: - float(formula) - except ValueError: - # Not a number. Remove the formula '=' sign if it exists. - if formula.startswith('='): - formula = formula.lstrip('=') - - self._xml_data_element('formula2', formula) - - def _write_conditional_formats(self): - # Write the Worksheet conditional formats. - ranges = sorted(self.cond_formats.keys()) - - if not ranges: - return - - for cond_range in ranges: - self._write_conditional_formatting(cond_range, - self.cond_formats[cond_range]) - - def _write_conditional_formatting(self, cond_range, params): - # Write the <conditionalFormatting> element. - attributes = [('sqref', cond_range)] - self._xml_start_tag('conditionalFormatting', attributes) - for param in params: - # Write the cfRule element. - self._write_cf_rule(param) - self._xml_end_tag('conditionalFormatting') - - def _write_cf_rule(self, params): - # Write the <cfRule> element. - attributes = [('type', params['type'])] - - if 'format' in params and params['format'] is not None: - attributes.append(('dxfId', params['format'])) - - attributes.append(('priority', params['priority'])) - - if params['type'] == 'cellIs': - attributes.append(('operator', params['criteria'])) - - self._xml_start_tag('cfRule', attributes) - - if 'minimum' in params and 'maximum' in params: - self._write_formula(params['minimum']) - self._write_formula(params['maximum']) - else: - self._write_formula(params['value']) - - self._xml_end_tag('cfRule') - - elif params['type'] == 'aboveAverage': - if re.search('below', params['criteria']): - attributes.append(('aboveAverage', 0)) - - if re.search('equal', params['criteria']): - attributes.append(('equalAverage', 1)) - - if re.search('[123] std dev', params['criteria']): - match = re.search('([123]) std dev', params['criteria']) - attributes.append(('stdDev', match.group(1))) - - self._xml_empty_tag('cfRule', attributes) - - elif params['type'] == 'top10': - if 'criteria' in params and params['criteria'] == '%': - attributes.append(('percent', 1)) - - if 'direction' in params: - attributes.append(('bottom', 1)) - - rank = params['value'] or 10 - attributes.append(('rank', rank)) - - self._xml_empty_tag('cfRule', attributes) - - elif params['type'] == 'duplicateValues': - self._xml_empty_tag('cfRule', attributes) - - elif params['type'] == 'uniqueValues': - self._xml_empty_tag('cfRule', attributes) - - elif (params['type'] == 'containsText' - or params['type'] == 'notContainsText' - or params['type'] == 'beginsWith' - or params['type'] == 'endsWith'): - attributes.append(('operator', params['criteria'])) - attributes.append(('text', params['value'])) - self._xml_start_tag('cfRule', attributes) - self._write_formula(params['formula']) - self._xml_end_tag('cfRule') - - elif params['type'] == 'timePeriod': - attributes.append(('timePeriod', params['criteria'])) - self._xml_start_tag('cfRule', attributes) - self._write_formula(params['formula']) - self._xml_end_tag('cfRule') - - elif (params['type'] == 'containsBlanks' - or params['type'] == 'notContainsBlanks' - or params['type'] == 'containsErrors' - or params['type'] == 'notContainsErrors'): - self._xml_start_tag('cfRule', attributes) - self._write_formula(params['formula']) - self._xml_end_tag('cfRule') - - elif params['type'] == 'colorScale': - self._xml_start_tag('cfRule', attributes) - self._write_color_scale(params) - self._xml_end_tag('cfRule') - - elif params['type'] == 'dataBar': - self._xml_start_tag('cfRule', attributes) - self._write_data_bar(params) - self._xml_end_tag('cfRule') - - elif params['type'] == 'expression': - self._xml_start_tag('cfRule', attributes) - self._write_formula(params['criteria']) - self._xml_end_tag('cfRule') - - def _write_formula(self, formula): - # Write the <formula> element. - - # Check if the formula is a number. - try: - float(formula) - except ValueError: - # Not a number. Remove the formula '=' sign if it exists. - if formula.startswith('='): - formula = formula.lstrip('=') - - self._xml_data_element('formula', formula) - - def _write_color_scale(self, param): - # Write the <colorScale> element. - - self._xml_start_tag('colorScale') - - self._write_cfvo(param['min_type'], param['min_value']) - - if param['mid_type'] is not None: - self._write_cfvo(param['mid_type'], param['mid_value']) - - self._write_cfvo(param['max_type'], param['max_value']) - - self._write_color('rgb', param['min_color']) - - if param['mid_color'] is not None: - self._write_color('rgb', param['mid_color']) - - self._write_color('rgb', param['max_color']) - - self._xml_end_tag('colorScale') - - def _write_data_bar(self, param): - # Write the <dataBar> element. - self._xml_start_tag('dataBar') - - self._write_cfvo(param['min_type'], param['min_value']) - self._write_cfvo(param['max_type'], param['max_value']) - self._write_color('rgb', param['bar_color']) - - self._xml_end_tag('dataBar') - - def _write_cfvo(self, cf_type, val): - # Write the <cfvo> element. - attributes = [('type', cf_type), ('val', val)] - - self._xml_empty_tag('cfvo', attributes) - - def _write_color(self, name, value): - # Write the <color> element. - attributes = [(name, value)] - - self._xml_empty_tag('color', attributes) - - def _write_selections(self): - # Write the <selection> elements. - for selection in self.selections: - self._write_selection(*selection) - - def _write_selection(self, pane, active_cell, sqref): - # Write the <selection> element. - attributes = [] - - if pane: - attributes.append(('pane', pane)) - - if active_cell: - attributes.append(('activeCell', active_cell)) - - if sqref: - attributes.append(('sqref', sqref)) - - self._xml_empty_tag('selection', attributes) - - def _write_panes(self): - # Write the frozen or split <pane> elements. - panes = self.panes - - if not len(panes): - return - - if panes[4] == 2: - self._write_split_panes(*panes) - else: - self._write_freeze_panes(*panes) - - def _write_freeze_panes(self, row, col, top_row, left_col, pane_type): - # Write the <pane> element for freeze panes. - attributes = [] - - y_split = row - x_split = col - top_left_cell = xl_rowcol_to_cell(top_row, left_col) - active_pane = '' - state = '' - active_cell = '' - sqref = '' - - # Move user cell selection to the panes. - if self.selections: - (_, active_cell, sqref) = self.selections[0] - self.selections = [] - - # Set the active pane. - if row and col: - active_pane = 'bottomRight' - - row_cell = xl_rowcol_to_cell(row, 0) - col_cell = xl_rowcol_to_cell(0, col) - - self.selections.append(['topRight', col_cell, col_cell]) - self.selections.append(['bottomLeft', row_cell, row_cell]) - self.selections.append(['bottomRight', active_cell, sqref]) - - elif col: - active_pane = 'topRight' - self.selections.append(['topRight', active_cell, sqref]) - - else: - active_pane = 'bottomLeft' - self.selections.append(['bottomLeft', active_cell, sqref]) - - # Set the pane type. - if pane_type == 0: - state = 'frozen' - elif pane_type == 1: - state = 'frozenSplit' - else: - state = 'split' - - if x_split: - attributes.append(('xSplit', x_split)) - - if y_split: - attributes.append(('ySplit', y_split)) - - attributes.append(('topLeftCell', top_left_cell)) - attributes.append(('activePane', active_pane)) - attributes.append(('state', state)) - - self._xml_empty_tag('pane', attributes) - - def _write_split_panes(self, row, col, top_row, left_col, pane_type): - # Write the <pane> element for split panes. - attributes = [] - has_selection = 0 - active_pane = '' - active_cell = '' - sqref = '' - - y_split = row - x_split = col - - # Move user cell selection to the panes. - if self.selections: - (_, active_cell, sqref) = self.selections[0] - self.selections = [] - has_selection = 1 - - # Convert the row and col to 1/20 twip units with padding. - if y_split: - y_split = int(20 * y_split + 300) - - if x_split: - x_split = self._calculate_x_split_width(x_split) - - # For non-explicit topLeft definitions, estimate the cell offset based - # on the pixels dimensions. This is only a workaround and doesn't take - # adjusted cell dimensions into account. - if top_row == row and left_col == col: - top_row = int(0.5 + (y_split - 300) / 20 / 15) - left_col = int(0.5 + (x_split - 390) / 20 / 3 * 4 / 64) - - top_left_cell = xl_rowcol_to_cell(top_row, left_col) - - # If there is no selection set the active cell to the top left cell. - if not has_selection: - active_cell = top_left_cell - sqref = top_left_cell - - # Set the Cell selections. - if row and col: - active_pane = 'bottomRight' - - row_cell = xl_rowcol_to_cell(top_row, 0) - col_cell = xl_rowcol_to_cell(0, left_col) - - self.selections.append(['topRight', col_cell, col_cell]) - self.selections.append(['bottomLeft', row_cell, row_cell]) - self.selections.append(['bottomRight', active_cell, sqref]) - - elif col: - active_pane = 'topRight' - self.selections.append(['topRight', active_cell, sqref]) - - else: - active_pane = 'bottomLeft' - self.selections.append(['bottomLeft', active_cell, sqref]) - - # Format splits to the same precision as Excel. - if x_split: - attributes.append(('xSplit', "%.15g" % x_split)) - - if y_split: - attributes.append(('ySplit', "%.15g" % y_split)) - - attributes.append(('topLeftCell', top_left_cell)) - - if has_selection: - attributes.append(('activePane', active_pane)) - - self._xml_empty_tag('pane', attributes) - - def _calculate_x_split_width(self, width): - # Convert column width from user units to pane split width. - - max_digit_width = 7 # For Calabri 11. - padding = 5 - - # Convert to pixels. - if width < 1: - pixels = int(width * (max_digit_width + padding) + 0.5) - else: - pixels = int(width * max_digit_width + 0.5) + padding - - # Convert to points. - points = pixels * 3 / 4 - - # Convert to twips (twentieths of a point). - twips = points * 20 - - # Add offset/padding. - width = twips + 390 - - return width - - def _write_table_parts(self): - # Write the <tableParts> element. - tables = self.tables - count = len(tables) - - # Return if worksheet doesn't contain any tables. - if not count: - return - - attributes = [('count', count,)] - - self._xml_start_tag('tableParts', attributes) - - for _ in tables: - - # Write the tablePart element. - self.rel_count += 1 - self._write_table_part(self.rel_count) - - self._xml_end_tag('tableParts') - - def _write_table_part(self, r_id): - # Write the <tablePart> element. - - r_id = 'rId' + str(r_id) - - attributes = [('r:id', r_id,)] - - self._xml_empty_tag('tablePart', attributes) - - def _write_ext_sparklines(self): - # Write the <extLst> element and sparkline sub-elements. - sparklines = self.sparklines - count = len(sparklines) - - # Return if worksheet doesn't contain any sparklines. - if not count: - return - - # Write the extLst element. - self._xml_start_tag('extLst') - - # Write the ext element. - self._write_ext() - - # Write the x14:sparklineGroups element. - self._write_sparkline_groups() - - # Write the sparkline elements. - for sparkline in reversed(sparklines): - - # Write the x14:sparklineGroup element. - self._write_sparkline_group(sparkline) - - # Write the x14:colorSeries element. - self._write_color_series(sparkline['series_color']) - - # Write the x14:colorNegative element. - self._write_color_negative(sparkline['negative_color']) - - # Write the x14:colorAxis element. - self._write_color_axis() - - # Write the x14:colorMarkers element. - self._write_color_markers(sparkline['markers_color']) - - # Write the x14:colorFirst element. - self._write_color_first(sparkline['first_color']) - - # Write the x14:colorLast element. - self._write_color_last(sparkline['last_color']) - - # Write the x14:colorHigh element. - self._write_color_high(sparkline['high_color']) - - # Write the x14:colorLow element. - self._write_color_low(sparkline['low_color']) - - if sparkline['date_axis']: - self._xml_data_element('xm:f', sparkline['date_axis']) - - self._write_sparklines(sparkline) - - self._xml_end_tag('x14:sparklineGroup') - - self._xml_end_tag('x14:sparklineGroups') - self._xml_end_tag('ext') - self._xml_end_tag('extLst') - - def _write_sparklines(self, sparkline): - # Write the <x14:sparklines> element and <x14:sparkline> sub-elements. - - # Write the sparkline elements. - self._xml_start_tag('x14:sparklines') - - for i in range(sparkline['count']): - spark_range = sparkline['ranges'][i] - location = sparkline['locations'][i] - - self._xml_start_tag('x14:sparkline') - self._xml_data_element('xm:f', spark_range) - self._xml_data_element('xm:sqref', location) - self._xml_end_tag('x14:sparkline') - - self._xml_end_tag('x14:sparklines') - - def _write_ext(self): - # Write the <ext> element. - schema = 'http://schemas.microsoft.com/office/' - xmlns_x_14 = schema + 'spreadsheetml/2009/9/main' - uri = '{05C60535-1F16-4fd2-B633-F4F36F0B64E0}' - - attributes = [ - ('xmlns:x14', xmlns_x_14), - ('uri', uri), - ] - - self._xml_start_tag('ext', attributes) - - def _write_sparkline_groups(self): - # Write the <x14:sparklineGroups> element. - xmlns_xm = 'http://schemas.microsoft.com/office/excel/2006/main' - - attributes = [('xmlns:xm', xmlns_xm)] - - self._xml_start_tag('x14:sparklineGroups', attributes) - - def _write_sparkline_group(self, options): - # Write the <x14:sparklineGroup> element. - # - # Example for order. - # - # <x14:sparklineGroup - # manualMax="0" - # manualMin="0" - # lineWeight="2.25" - # type="column" - # dateAxis="1" - # displayEmptyCellsAs="span" - # markers="1" - # high="1" - # low="1" - # first="1" - # last="1" - # negative="1" - # displayXAxis="1" - # displayHidden="1" - # minAxisType="custom" - # maxAxisType="custom" - # rightToLeft="1"> - # - empty = options.get('empty') - attributes = [] - - if options.get('max') is not None: - if options['max'] == 'group': - options['cust_max'] = 'group' - else: - attributes.append(('manualMax', options['max'])) - options['cust_max'] = 'custom' - - if options.get('min') is not None: - - if options['min'] == 'group': - options['cust_min'] = 'group' - else: - attributes.append(('manualMin', options['min'])) - options['cust_min'] = 'custom' - - # Ignore the default type attribute (line). - if options['type'] != 'line': - attributes.append(('type', options['type'])) - - if options.get('weight'): - attributes.append(('lineWeight', options['weight'])) - - if options.get('date_axis'): - attributes.append(('dateAxis', 1)) - - if empty: - attributes.append(('displayEmptyCellsAs', empty)) - - if options.get('markers'): - attributes.append(('markers', 1)) - - if options.get('high'): - attributes.append(('high', 1)) - - if options.get('low'): - attributes.append(('low', 1)) - - if options.get('first'): - attributes.append(('first', 1)) - - if options.get('last'): - attributes.append(('last', 1)) - - if options.get('negative'): - attributes.append(('negative', 1)) - - if options.get('axis'): - attributes.append(('displayXAxis', 1)) - - if options.get('hidden'): - attributes.append(('displayHidden', 1)) - - if options.get('cust_min'): - attributes.append(('minAxisType', options['cust_min'])) - - if options.get('cust_max'): - attributes.append(('maxAxisType', options['cust_max'])) - - if options.get('reverse'): - attributes.append(('rightToLeft', 1)) - - self._xml_start_tag('x14:sparklineGroup', attributes) - - def _write_spark_color(self, element, color): - # Helper function for the sparkline color functions below. - attributes = [] - - if color.get('rgb'): - attributes.append(('rgb', color['rgb'])) - - if color.get('theme'): - attributes.append(('theme', color['theme'])) - - if color.get('tint'): - attributes.append(('tint', color['tint'])) - - self._xml_empty_tag(element, attributes) - - def _write_color_series(self, color): - # Write the <x14:colorSeries> element. - self._write_spark_color('x14:colorSeries', color) - - def _write_color_negative(self, color): - # Write the <x14:colorNegative> element. - self._write_spark_color('x14:colorNegative', color) - - def _write_color_axis(self): - # Write the <x14:colorAxis> element. - self._write_spark_color('x14:colorAxis', {'rgb': 'FF000000'}) - - def _write_color_markers(self, color): - # Write the <x14:colorMarkers> element. - self._write_spark_color('x14:colorMarkers', color) - - def _write_color_first(self, color): - # Write the <x14:colorFirst> element. - self._write_spark_color('x14:colorFirst', color) - - def _write_color_last(self, color): - # Write the <x14:colorLast> element. - self._write_spark_color('x14:colorLast', color) - - def _write_color_high(self, color): - # Write the <x14:colorHigh> element. - self._write_spark_color('x14:colorHigh', color) - - def _write_color_low(self, color): - # Write the <x14:colorLow> element. - self._write_spark_color('x14:colorLow', color) - - def _write_phonetic_pr(self): - # Write the <phoneticPr> element. - attributes = [ - ('fontId', '0'), - ('type', 'noConversion'), - ] - - self._xml_empty_tag('phoneticPr', attributes)
Binary file test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/worksheet.pyc has changed
--- a/test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/xmlwriter.py Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,210 +0,0 @@ -############################################################################### -# -# XMLwriter - A base class for XlsxWriter classes. -# -# Used in conjunction with XlsxWriter. -# -# Copyright 2013-2016, John McNamara, jmcnamara@cpan.org -# - -# Standard packages. -import re -import codecs - -# Standard packages in Python 2/3 compatibility mode. -from .compatibility import StringIO - - -class XMLwriter(object): - """ - Simple XML writer class. - - """ - - def __init__(self): - self.fh = None - self.escapes = re.compile('["&<>\n]') - self.internal_fh = False - - def _set_filehandle(self, filehandle): - # Set the writer filehandle directly. Mainly for testing. - self.fh = filehandle - self.internal_fh = False - - def _set_xml_writer(self, filename): - # Set the XML writer filehandle for the object. - if isinstance(filename, StringIO): - self.internal_fh = False - self.fh = filename - else: - self.internal_fh = True - self.fh = codecs.open(filename, 'w', 'utf-8') - - def _xml_close(self): - # Close the XML filehandle if we created it. - if self.internal_fh: - self.fh.close() - - def _xml_declaration(self): - # Write the XML declaration. - self.fh.write( - """<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n""") - - def _xml_start_tag(self, tag, attributes=[]): - # Write an XML start tag with optional attributes. - for key, value in attributes: - value = self._escape_attributes(value) - tag += ' %s="%s"' % (key, value) - - self.fh.write("<%s>" % tag) - - def _xml_start_tag_unencoded(self, tag, attributes=[]): - # Write an XML start tag with optional, unencoded, attributes. - # This is a minor speed optimisation for elements that don't - # need encoding. - for key, value in attributes: - tag += ' %s="%s"' % (key, value) - - self.fh.write("<%s>" % tag) - - def _xml_end_tag(self, tag): - # Write an XML end tag. - self.fh.write("</%s>" % tag) - - def _xml_empty_tag(self, tag, attributes=[]): - # Write an empty XML tag with optional attributes. - for key, value in attributes: - value = self._escape_attributes(value) - tag += ' %s="%s"' % (key, value) - - self.fh.write("<%s/>" % tag) - - def _xml_empty_tag_unencoded(self, tag, attributes=[]): - # Write an empty XML tag with optional, unencoded, attributes. - # This is a minor speed optimisation for elements that don't - # need encoding. - for key, value in attributes: - tag += ' %s="%s"' % (key, value) - - self.fh.write("<%s/>" % tag) - - def _xml_data_element(self, tag, data, attributes=[]): - # Write an XML element containing data with optional attributes. - end_tag = tag - - for key, value in attributes: - value = self._escape_attributes(value) - tag += ' %s="%s"' % (key, value) - - data = self._escape_data(data) - self.fh.write("<%s>%s</%s>" % (tag, data, end_tag)) - - def _xml_string_element(self, index, attributes=[]): - # Optimised tag writer for <c> cell string elements in the inner loop. - attr = '' - - for key, value in attributes: - value = self._escape_attributes(value) - attr += ' %s="%s"' % (key, value) - - self.fh.write("""<c%s t="s"><v>%d</v></c>""" % (attr, index)) - - def _xml_si_element(self, string, attributes=[]): - # Optimised tag writer for shared strings <si> elements. - attr = '' - - for key, value in attributes: - value = self._escape_attributes(value) - attr += ' %s="%s"' % (key, value) - - string = self._escape_data(string) - - self.fh.write("""<si><t%s>%s</t></si>""" % (attr, string)) - - def _xml_rich_si_element(self, string): - # Optimised tag writer for shared strings <si> rich string elements. - - self.fh.write("""<si>%s</si>""" % string) - - def _xml_number_element(self, number, attributes=[]): - # Optimised tag writer for <c> cell number elements in the inner loop. - attr = '' - - for key, value in attributes: - value = self._escape_attributes(value) - attr += ' %s="%s"' % (key, value) - - self.fh.write("""<c%s><v>%.15g</v></c>""" % (attr, number)) - - def _xml_formula_element(self, formula, result, attributes=[]): - # Optimised tag writer for <c> cell formula elements in the inner loop. - attr = '' - - for key, value in attributes: - value = self._escape_attributes(value) - attr += ' %s="%s"' % (key, value) - - self.fh.write("""<c%s><f>%s</f><v>%s</v></c>""" - % (attr, self._escape_data(formula), - self._escape_data(result))) - - def _xml_inline_string(self, string, preserve, attributes=[]): - # Optimised tag writer for inlineStr cell elements in the inner loop. - attr = '' - t_attr = '' - - # Set the <t> attribute to preserve whitespace. - if preserve: - t_attr = ' xml:space="preserve"' - - for key, value in attributes: - value = self._escape_attributes(value) - attr += ' %s="%s"' % (key, value) - - string = self._escape_data(string) - - self.fh.write("""<c%s t="inlineStr"><is><t%s>%s</t></is></c>""" % - (attr, t_attr, string)) - - def _xml_rich_inline_string(self, string, attributes=[]): - # Optimised tag writer for rich inlineStr in the inner loop. - attr = '' - - for key, value in attributes: - value = self._escape_attributes(value) - attr += ' %s="%s"' % (key, value) - - self.fh.write("""<c%s t="inlineStr"><is>%s</is></c>""" % - (attr, string)) - - def _escape_attributes(self, attribute): - # Escape XML characters in attributes. - try: - if not self.escapes.search(attribute): - return attribute - except TypeError: - return attribute - - attribute = attribute.replace('&', '&') - attribute = attribute.replace('"', '"') - attribute = attribute.replace('<', '<') - attribute = attribute.replace('>', '>') - attribute = attribute.replace('\n', '
') - - return attribute - - def _escape_data(self, data): - # Escape XML characters in data sections of tags. Note, this - # is different from _escape_attributes() in that double quotes - # are not escaped by Excel. - try: - if not self.escapes.search(data): - return data - except TypeError: - return data - - data = data.replace('&', '&') - data = data.replace('<', '<') - data = data.replace('>', '>') - - return data
Binary file test.tool_dependencies.rnachipintegrator/rnachipintegrator/1.0.0/lib/python2.7/site-packages/xlsxwriter/xmlwriter.pyc has changed
--- a/test.tool_dependencies.rnachipintegrator/xlsxwriter/0.8.4/bin/vba_extract.py Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,4 +0,0 @@ -#!/home/pjb/virtual-envs/planemo/bin/python -# EASY-INSTALL-SCRIPT: 'XlsxWriter==0.8.4','vba_extract.py' -__requires__ = 'XlsxWriter==0.8.4' -__import__('pkg_resources').run_script('XlsxWriter==0.8.4', 'vba_extract.py')
--- a/test.tool_dependencies.rnachipintegrator/xlsxwriter/0.8.4/env.sh Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,6 +0,0 @@ -#!/bin/sh -# Source this to setup xlsxwriter/0.8.4 -echo Setting up xlsxwriter 0.8.4 -export PYTHONPATH=/home/pjb/projects/galaxy-tools-update-rnachipintegrator/rnachipintegrator/test.tool_dependencies.rnachipintegrator/xlsxwriter/0.8.4/lib/python:$PYTHONPATH -export PATH=/home/pjb/projects/galaxy-tools-update-rnachipintegrator/rnachipintegrator/test.tool_dependencies.rnachipintegrator/xlsxwriter/0.8.4/bin:$PATH -#
Binary file test.tool_dependencies.rnachipintegrator/xlsxwriter/0.8.4/lib/python/XlsxWriter-0.8.4-py2.7.egg has changed
--- a/test.tool_dependencies.rnachipintegrator/xlsxwriter/0.8.4/lib/python/easy-install.pth Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3 +0,0 @@ -import sys; sys.__plen = len(sys.path) -./XlsxWriter-0.8.4-py2.7.egg -import sys; new=sys.path[sys.__plen:]; del sys.path[sys.__plen:]; p=getattr(sys,'__egginsert',0); sys.path[p:p]=new; sys.__egginsert = p+len(new)
--- a/test.tool_dependencies.rnachipintegrator/xlsxwriter/0.8.4/lib/python/site.py Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,76 +0,0 @@ -def __boot(): - import sys - import os - PYTHONPATH = os.environ.get('PYTHONPATH') - if PYTHONPATH is None or (sys.platform=='win32' and not PYTHONPATH): - PYTHONPATH = [] - else: - PYTHONPATH = PYTHONPATH.split(os.pathsep) - - pic = getattr(sys,'path_importer_cache',{}) - stdpath = sys.path[len(PYTHONPATH):] - mydir = os.path.dirname(__file__) - #print "searching",stdpath,sys.path - - for item in stdpath: - if item==mydir or not item: - continue # skip if current dir. on Windows, or my own directory - importer = pic.get(item) - if importer is not None: - loader = importer.find_module('site') - if loader is not None: - # This should actually reload the current module - loader.load_module('site') - break - else: - try: - import imp # Avoid import loop in Python >= 3.3 - stream, path, descr = imp.find_module('site',[item]) - except ImportError: - continue - if stream is None: - continue - try: - # This should actually reload the current module - imp.load_module('site',stream,path,descr) - finally: - stream.close() - break - else: - raise ImportError("Couldn't find the real 'site' module") - - #print "loaded", __file__ - - known_paths = dict([(makepath(item)[1],1) for item in sys.path]) # 2.2 comp - - oldpos = getattr(sys,'__egginsert',0) # save old insertion position - sys.__egginsert = 0 # and reset the current one - - for item in PYTHONPATH: - addsitedir(item) - - sys.__egginsert += oldpos # restore effective old position - - d, nd = makepath(stdpath[0]) - insert_at = None - new_path = [] - - for item in sys.path: - p, np = makepath(item) - - if np==nd and insert_at is None: - # We've hit the first 'system' path entry, so added entries go here - insert_at = len(new_path) - - if np in known_paths or insert_at is None: - new_path.append(item) - else: - # new path after the insert point, back-insert it - new_path.insert(insert_at, item) - insert_at += 1 - - sys.path[:] = new_path - -if __name__=='site': - __boot() - del __boot
Binary file test.tool_dependencies.rnachipintegrator/xlsxwriter/0.8.4/lib/python/site.pyc has changed
--- a/tool_data_table_conf.xml.test Wed Feb 24 09:25:18 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,6 +0,0 @@ -<tables> - <table name="rnachipintegrator_canonical_genes" comment_char="#"> - <columns>value, dbkey, name, path</columns> - <file path="${__HERE__}/test-data/rnachipintegrator_canonical_genes.loc" /> - </table> -</tables>