In [1]:
import os
import sys

In [2]:
version = "0.9.1"

In [3]:
def check_py_file_path(py_file_path):

    py_file_name == py_file_path.split("/")[-1]

    py_file_name_without_py = py_file_name[: -len(".py")]

    if py_file_name_without_py.isupper():

        importable_names = [py_file_name_without_py]

    else:

        importable_names = []

        with open(py_file_path) as py_file:

            for line in py_file.readlines():

                for prefix, separator in (("def ", "("), ("class ", ":")):

                    if line.startswith(prefix):

                        importable_names.append(
                            line.strip().split(separator)[0][len(prefix) :]
                        )

    if len(importable_names) != 1:

        raise ValueError("N importable names ({}) != 1".format(len(importable_names)))

    importable_name = importable_names[0]

    if importable_name != py_file_name_without_py:

        raise ValueError(
            "{}(.py) != {}".format(py_file_name_without_py, importable_name)
        )

In [4]:
import_lines = []

for py_file_name in sorted(os.listdir("ccal")):

    print(py_file_name)

    if py_file_name != "__init__.py" and py_file_name.endswith(".py"):

        check_py_file_path("ccal/{}".format(py_file_name))

        import_lines.append("from .{0} import {0}".format(py_file_name[: -len(".py")]))


BAD_VARIANT_IDS.py
CODON_TO_AMINO_ACID.py
COLOR_CATEGORICAL.py
COLOR_WHITE_BLACK.py
COLOR_WHITE_BROWN.py
GPSMap.py
VARIANT_CLASSIFICATION_MUTSIG_EFFECT.py
VARIANT_EFFECTS.py
VCF_ANN_FIELDS.py
VCF_COLUMNS.py
__init__.py
__pycache__
_anneal_node_and_element_positions.py
_check_node_x_element.py
_check_w_or_h.py
_cluster_clustering_x_element_and_compute_ccc.py
_compute_context_indices.py
_compute_norm.py
_count.py
_describe_vcf_df.py
_fit_skew_t_pdfs.py
_get_coclustering_portion.py
_get_target_grid_indices.py
_get_triangulation_edges.py
_gzip_compress.py
_identify_what_to_count.py
_ignore_bad_and_compute_euclidean_distance_between_2_1d_arrays.py
_make_annotations.py
_make_clean_vcf_df.py
_make_context_matrix.py
_make_element_x_dimension.py
_make_grid_values_and_categorical_labels.py
_make_variant_dict_consistent.py
_match.py
_match_randomly_sampled_target_and_data_to_compute_margin_of_errors.py
_match_target_and_data.py
_normalize_nd_array.py
_permute_target_and_match_target_and_data.py
_plot_2d.py
_plot_gps_map.py
_plot_mountain.py
_print_and_run_command.py
_process_target_or_data_for_plotting.py
_single_sample_gseas.py
_update_H_by_multiplicative_update.py
_update_W_by_multiplicative_update.py
add_conda_to_path.py
apply_function_on_2_1d_arrays.py
apply_function_on_2_2d_arrays_slices.py
cast_series_to_builtins.py
cast_str_to_builtins.py
check_nd_array_for_bad.py
clean_and_write_df_to_tsv.py
clean_git_url.py
clean_name.py
clean_path.py
clip_nd_array_by_standard_deviation.py
cluster_2d_array_slices.py
compute_bandwidths.py
compute_context.py
compute_correlation_distance.py
compute_empirical_p_value.py
compute_empirical_p_values_and_fdrs.py
compute_entropy.py
compute_information_coefficient.py
compute_information_distance.py
compute_joint_probability.py
compute_kullback_leibler_divergence.py
compute_mutational_signature_enrichment.py
compute_nd_array_margin_of_error.py
compute_posterior_probability.py
conda_is_installed.py
copy_path.py
correlate.py
count_gene_impacts_from_variant_dicts.py
count_vcf_gz_rows.py
create_gitkeep.py
cross_validate.py
download.py
download_and_parse_geo_data.py
drop_df_slice.py
drop_df_slice_greedily.py
dump_gps_map.py
echo_or_print.py
establish_path.py
estimate_kernel_density.py
exit_.py
fit_skew_t_pdf.py
fit_skew_t_pdfs.py
flatten_nested_iterable.py
get_1d_array_unique_objects_in_order.py
get_allelic_frequencies.py
get_colormap_colors.py
get_conda_environments.py
get_conda_prefix.py
get_function_name.py
get_genotype.py
get_gff3_attribute.py
get_git_versions.py
get_installed_pip_libraries.py
get_intersections_between_2_1d_arrays.py
get_machine.py
get_maf_variant_classification.py
get_now.py
get_object_reference.py
get_open_port.py
get_population_allelic_frequencies.py
get_shell_environment.py
get_unique_iterable_objects_in_order.py
get_variant_start_and_end_positions.py
get_variant_type.py
get_vcf_info.py
get_vcf_info_ann.py
get_vcf_sample_format.py
get_volume_name.py
group_and_apply_function_on_each_group_in_iterable.py
group_iterable.py
gsea.py
gzip_compress_file.py
gzip_decompress_and_bgzip_compress_file.py
gzip_decompress_file.py
have_program.py
hierarchical_consensus_cluster.py
hierarchical_consensus_cluster_with_ks.py
in_git_repository.py
index_gff3_df_by_name.py
infer.py
infer_assuming_independence.py
initialize_logger.py
install_and_activate_conda.py
install_python_libraries.py
is_inframe.py
is_valid_vcf_gz.py
load_gps_map.py
log_and_return_response.py
log_nd_array.py
make_categorical_colors.py
make_colorscale.py
make_colorscale_from_colors.py
make_comparison_panel.py
make_context_matrix.py
make_coordinates_for_reflection.py
make_file_name_from_str.py
make_maf_from_vcf.py
make_match_panel.py
make_match_panels.py
make_membership_df_from_categorical_series.py
make_mesh_grid_coordinates_per_axis.py
make_object_int_mapping.py
make_random_color.py
make_summary_match_panel.py
make_volume_dict.py
mds.py
merge_dicts_with_callable.py
mount_volume.py
multiprocess.py
nd_array_is_sorted.py
nmf_by_multiple_V_and_H.py
nmf_by_multiplicative_update.py
nmf_by_sklearn.py
nmf_consensus_cluster.py
nmf_consensus_cluster_with_ks.py
normalize_contig.py
normalize_df.py
normalize_nd_array.py
parse_vcf_row_and_make_variant_dict.py
plot_and_save.py
plot_bar.py
plot_bayesian_nomogram.py
plot_bubble_map.py
plot_color_text.py
plot_context.py
plot_distributions.py
plot_heat_map.py
plot_pie.py
plot_points.py
plot_table.py
plot_violin_or_box.py
process_feature_x_sample.py
read_copynumber_gistic2.py
read_correlate_copynumber_vs_mrnaseq.py
read_gct.py
read_gff3_gz.py
read_gmt.py
read_gmts.py
read_json.py
read_matrix_market.py
read_mutsignozzlereport2cv.py
read_vcf_gz_and_make_vcf_dict.py
reboot_machine.py
remove_path.py
remove_paths.py
replace_bad_objects_in_iterable.py
rescale_x_y_coordiantes_in_polar_coordiante.py
reverse_complement_dna_sequence.py
reverse_transcribe_rna_sequence.py
run_command.py
run_command_and_monitor.py
select_gene_symbol.py
select_series_indices.py
select_tcga_sample_by_sample_type_and_group.py
shuffle_each_2d_array_slice.py
shutdown_machine.py
single_sample_gsea.py
single_sample_gseas.py
solve_ax_equal_b.py
solve_for_H.py
split_codons.py
split_df.py
split_maf_by_tumor_sample_barcode.py
split_str_ignoring_inside_quotes.py
str_is_version.py
summarize_feature_x_sample.py
title_str.py
train_and_classify.py
train_and_regress.py
transcribe_dna_sequence.py
translate_nucleotide_sequence.py
untitle_str.py
update_variant_dict.py
write_dict.py
write_gct.py
write_gmt.py
write_json.py

In [5]:
with open("ccal/__init__.py", mode="w") as init_file:

    init_file.write(
        "\n".join(
            (
                "from os.path import abspath",
                'VERSION = "{}"'.format(version),
                'print("CCAL version {} @ {}".format(VERSION, abspath(__file__)))',
            )
        )
    )

    init_file.write("\n")

    init_file.writelines("\n".join(import_lines))

In [6]:
sys.path.insert(0, "..")

import ccal


CCAL version 0.9.1 @ /home/kwatme/ccal/ccal/__init__.py

In [7]:
print(len(dir(ccal)))

dir(ccal)


233
Out[7]:
['BAD_VARIANT_IDS',
 'CODON_TO_AMINO_ACID',
 'COLOR_CATEGORICAL',
 'COLOR_WHITE_BLACK',
 'COLOR_WHITE_BROWN',
 'GPSMap',
 'VARIANT_CLASSIFICATION_MUTSIG_EFFECT',
 'VARIANT_EFFECTS',
 'VCF_ANN_FIELDS',
 'VCF_COLUMNS',
 'VERSION',
 '__builtins__',
 '__cached__',
 '__doc__',
 '__file__',
 '__loader__',
 '__name__',
 '__package__',
 '__path__',
 '__spec__',
 '_anneal_node_and_element_positions',
 '_check_node_x_element',
 '_check_w_or_h',
 '_cluster_clustering_x_element_and_compute_ccc',
 '_compute_context_indices',
 '_compute_norm',
 '_count',
 '_describe_vcf_df',
 '_fit_skew_t_pdfs',
 '_get_coclustering_portion',
 '_get_target_grid_indices',
 '_get_triangulation_edges',
 '_gzip_compress',
 '_identify_what_to_count',
 '_ignore_bad_and_compute_euclidean_distance_between_2_1d_arrays',
 '_make_annotations',
 '_make_clean_vcf_df',
 '_make_context_matrix',
 '_make_element_x_dimension',
 '_make_grid_values_and_categorical_labels',
 '_make_variant_dict_consistent',
 '_match',
 '_match_randomly_sampled_target_and_data_to_compute_margin_of_errors',
 '_match_target_and_data',
 '_normalize_nd_array',
 '_permute_target_and_match_target_and_data',
 '_plot_2d',
 '_plot_gps_map',
 '_plot_mountain',
 '_print_and_run_command',
 '_process_target_or_data_for_plotting',
 '_single_sample_gseas',
 '_update_H_by_multiplicative_update',
 '_update_W_by_multiplicative_update',
 'abspath',
 'add_conda_to_path',
 'apply_function_on_2_1d_arrays',
 'apply_function_on_2_2d_arrays_slices',
 'cast_series_to_builtins',
 'cast_str_to_builtins',
 'check_nd_array_for_bad',
 'clean_and_write_df_to_tsv',
 'clean_git_url',
 'clean_name',
 'clean_path',
 'clip_nd_array_by_standard_deviation',
 'cluster_2d_array_slices',
 'compute_bandwidths',
 'compute_context',
 'compute_correlation_distance',
 'compute_empirical_p_value',
 'compute_empirical_p_values_and_fdrs',
 'compute_entropy',
 'compute_information_coefficient',
 'compute_information_distance',
 'compute_joint_probability',
 'compute_kullback_leibler_divergence',
 'compute_mutational_signature_enrichment',
 'compute_nd_array_margin_of_error',
 'compute_posterior_probability',
 'conda_is_installed',
 'copy_path',
 'correlate',
 'count_gene_impacts_from_variant_dicts',
 'count_vcf_gz_rows',
 'create_gitkeep',
 'cross_validate',
 'download',
 'download_and_parse_geo_data',
 'drop_df_slice',
 'drop_df_slice_greedily',
 'dump_gps_map',
 'echo_or_print',
 'establish_path',
 'estimate_kernel_density',
 'exit_',
 'fit_skew_t_pdf',
 'fit_skew_t_pdfs',
 'flatten_nested_iterable',
 'get_1d_array_unique_objects_in_order',
 'get_allelic_frequencies',
 'get_colormap_colors',
 'get_conda_environments',
 'get_conda_prefix',
 'get_function_name',
 'get_genotype',
 'get_gff3_attribute',
 'get_git_versions',
 'get_installed_pip_libraries',
 'get_intersections_between_2_1d_arrays',
 'get_machine',
 'get_maf_variant_classification',
 'get_now',
 'get_object_reference',
 'get_open_port',
 'get_population_allelic_frequencies',
 'get_shell_environment',
 'get_unique_iterable_objects_in_order',
 'get_variant_start_and_end_positions',
 'get_variant_type',
 'get_vcf_info',
 'get_vcf_info_ann',
 'get_vcf_sample_format',
 'get_volume_name',
 'group_and_apply_function_on_each_group_in_iterable',
 'group_iterable',
 'gsea',
 'gzip_compress_file',
 'gzip_decompress_and_bgzip_compress_file',
 'gzip_decompress_file',
 'have_program',
 'hierarchical_consensus_cluster',
 'hierarchical_consensus_cluster_with_ks',
 'in_git_repository',
 'index_gff3_df_by_name',
 'infer',
 'infer_assuming_independence',
 'initialize_logger',
 'install_and_activate_conda',
 'install_python_libraries',
 'is_inframe',
 'is_valid_vcf_gz',
 'load_gps_map',
 'log_and_return_response',
 'log_nd_array',
 'make_categorical_colors',
 'make_colorscale',
 'make_colorscale_from_colors',
 'make_comparison_panel',
 'make_context_matrix',
 'make_coordinates_for_reflection',
 'make_file_name_from_str',
 'make_maf_from_vcf',
 'make_match_panel',
 'make_match_panels',
 'make_membership_df_from_categorical_series',
 'make_mesh_grid_coordinates_per_axis',
 'make_object_int_mapping',
 'make_random_color',
 'make_summary_match_panel',
 'make_volume_dict',
 'mds',
 'merge_dicts_with_callable',
 'mount_volume',
 'multiprocess',
 'nd_array_is_sorted',
 'nmf_by_multiple_V_and_H',
 'nmf_by_multiplicative_update',
 'nmf_by_sklearn',
 'nmf_consensus_cluster',
 'nmf_consensus_cluster_with_ks',
 'normalize_contig',
 'normalize_df',
 'normalize_nd_array',
 'parse_vcf_row_and_make_variant_dict',
 'plot_and_save',
 'plot_bar',
 'plot_bayesian_nomogram',
 'plot_bubble_map',
 'plot_color_text',
 'plot_context',
 'plot_distributions',
 'plot_heat_map',
 'plot_pie',
 'plot_points',
 'plot_table',
 'plot_violin_or_box',
 'process_feature_x_sample',
 'read_copynumber_gistic2',
 'read_correlate_copynumber_vs_mrnaseq',
 'read_gct',
 'read_gff3_gz',
 'read_gmt',
 'read_gmts',
 'read_json',
 'read_matrix_market',
 'read_mutsignozzlereport2cv',
 'read_vcf_gz_and_make_vcf_dict',
 'reboot_machine',
 'remove_path',
 'remove_paths',
 'replace_bad_objects_in_iterable',
 'rescale_x_y_coordiantes_in_polar_coordiante',
 'reverse_complement_dna_sequence',
 'reverse_transcribe_rna_sequence',
 'run_command',
 'run_command_and_monitor',
 'select_gene_symbol',
 'select_series_indices',
 'select_tcga_sample_by_sample_type_and_group',
 'shuffle_each_2d_array_slice',
 'shutdown_machine',
 'single_sample_gsea',
 'single_sample_gseas',
 'solve_ax_equal_b',
 'solve_for_H',
 'split_codons',
 'split_df',
 'split_maf_by_tumor_sample_barcode',
 'split_str_ignoring_inside_quotes',
 'str_is_version',
 'summarize_feature_x_sample',
 'title_str',
 'train_and_classify',
 'train_and_regress',
 'transcribe_dna_sequence',
 'translate_nucleotide_sequence',
 'untitle_str',
 'update_variant_dict',
 'write_dict',
 'write_gct',
 'write_gmt',
 'write_json']