Skip to content

NameError: name 'randint' is not defined during panphlan_profiling.py #5

@fconstancias

Description

@fconstancias

Hey there,

I am encountering the following error when running the panphlan_profiling.py script:

...
STEP 2. Create coverage matrix
 [I] Reading mapping result file: MP3_TONGUE_DNA_Rothia_dentocariosa.csv.bz2
 [I] Reading mapping result file: K5_TONGUE_DNA_Rothia_dentocariosa.csv.bz2
 [I] Reading mapping result file: MP3_SUB_DNA_Rothia_dentocariosa.csv.bz2
 [I] Reading mapping result file: MP8_TONGUE_DNA_Rothia_dentocariosa.csv.bz2
 [I] Reading mapping result file: MP8_SUB_DNA_Rothia_dentocariosa.csv.bz2
 [I] Gene family normalization for DNA sample K5_TONGUE_DNA_Rothia_dentocariosa.csv.bz2...
 [I] Gene family normalization for DNA sample MP3_SUB_DNA_Rothia_dentocariosa.csv.bz2...
 [I] Gene family normalization for DNA sample MP3_TONGUE_DNA_Rothia_dentocariosa.csv.bz2...
 [I] Gene family normalization for DNA sample MP8_SUB_DNA_Rothia_dentocariosa.csv.bz2...
 [I] Gene family normalization for DNA sample MP8_TONGUE_DNA_Rothia_dentocariosa.csv.bz2...
Gene families coverage matrix has been printed in /datadrive05/Flo/Saliva/Saliva2/panphlan/prof/Rothia_dentocariosa/Rothia_dentocariosa_o_covmat.csv

STEP 3: Strain presence/absence filter based on coverage plateau curve...
 [I] Minimum median coverage threshold: 1.0
 [I] Left maximum plateau threshold: 1.7
 [I] Right minimum plateau threshold: 0.3
 [I] Maximum zero non-plateau threshold (multistrain detection): 0.2
 [I] K5_TONGUE_DNA_Rothia_dentocariosa.csv.bz2 median coverage: 0.68; left-side cov: 1.82; right-side cov: 0.58; out-plateau cov: 0.0
        K5_TONGUE_DNA_Rothia_dentocariosa.csv.bz2: no strain detected, sample below MIN COVERAGE threshold
 [I] MP3_SUB_DNA_Rothia_dentocariosa.csv.bz2 median coverage: 0.25; left-side cov: 1.87; right-side cov: 0.0; out-plateau cov: 0.0
        MP3_SUB_DNA_Rothia_dentocariosa.csv.bz2: no strain detected, sample below MIN COVERAGE threshold
 [I] MP3_TONGUE_DNA_Rothia_dentocariosa.csv.bz2 median coverage: 1.43; left-side cov: 1.43; right-side cov: 0.71; out-plateau cov: 0.0
         MP3_TONGUE_DNA_Rothia_dentocariosa.csv.bz2 OK - strain detected
 [I] MP8_SUB_DNA_Rothia_dentocariosa.csv.bz2 median coverage: 2.06; left-side cov: 1.32; right-side cov: 0.73; out-plateau cov: 0.0
         MP8_SUB_DNA_Rothia_dentocariosa.csv.bz2 OK - strain detected
 [I] MP8_TONGUE_DNA_Rothia_dentocariosa.csv.bz2 median coverage: 1.13; left-side cov: 1.6; right-side cov: 0.62; out-plateau cov: 0.0
         MP8_TONGUE_DNA_Rothia_dentocariosa.csv.bz2 OK - strain detected
Traceback (most recent call last):
  File "/datadrive05/Flo/tools/panphlan/panphlan_profiling.py", line 760, in <module>
    main()
  File "/datadrive05/Flo/tools/panphlan/panphlan_profiling.py", line 727, in main
    plot_dna_coverage(norm_samples_coverages, sample_stats, avg_genome_length, args, normalized = True)
  File "/datadrive05/Flo/tools/panphlan/panphlan_profiling.py", line 481, in plot_dna_coverage
    color, reset = random_color(used_colors)
  File "/datadrive05/Flo/tools/panphlan/misc.py", line 47, in random_color
    return (available[randint(0, len(available) - 1)], reset)
NameError: name 'randint' is not defined

I obtain the --o_covmat outputs, no --o_matrix nor --o_covplot_normed nor --o_idx and I am actually able to obtain the other outputs removing the -o_covplot_normed argument.

I am using the following command:

/datadrive05/Flo/tools/panphlan/panphlan_profiling.py --pangenome ${db_dir}/${taxa}/${taxa}_pangenome.tsv \
                -i ${map_dir}/${taxa}/ \
                --min_coverage 1 --left_max 1.70 --right_min 0.30 \
                --o_matrix ${out_dir_prof}/${taxa}/${taxa}_o_matrix.csv \
                --o_covmat ${out_dir_prof}/${taxa}/${taxa}_o_covmat.csv \
                --o_covplot_normed ${out_dir_prof}/${taxa}/${taxa}_o_covplot_normed \
                --o_idx ${out_dir_prof}/${taxa}/${taxa}_o_idx.csv \
                --add_ref \
                --verbose

I have created a conda env with the necessary packages and installed panphlan using git: git clone -b 3.0 https://github.com/SegataLab/panphlan.git

I had no issue with panphlan_download_pangenome.py & panphlan_map.py steps.

Thanks !

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions