ZhengXia / dapars

DaPars(Dynamic analysis of Alternative PolyAdenylation from RNA-seq)
GNU General Public License v2.0
46 stars 33 forks source link

DaPars does not handle scientific notation in the wig file coverage field (field 4) #1

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
-Current version DaPars v0.9.0

-Description of error and relevant line number in the program
Using files converted to wiggles from bedgraphs or bigwigs, some of the 
coverage may be in scientific notation (i.e. 1.6e+06). 

-Example lines in input wiggle
chrM    1900    1901    1.15903e+06
chrM    1901    1902    1.24796e+06
chrM    1902    1903    1.31714e+06
chrM    1903    1904    1.40726e+06

-Produced error
Traceback (most recent call last):
  File "/home/dreyfusslab/Desktop/DaPars_APA_analysis/DaPars_main.py", line 548, in <module>
    De_Novo_3UTR_Identification_Loading_Target_Wig_for_TCGA_Multiple_Samples_Main(sys.argv)
  File "/home/dreyfusslab/Desktop/DaPars_APA_analysis/DaPars_main.py", line 154, in De_Novo_3UTR_Identification_Loading_Target_Wig_for_TCGA_Multiple_Samples_Main
    All_samples_Target_3UTR_coverages, All_samples_sequencing_depths, UTR_events_dict = Load_Target_Wig_files(All_Sample_files, Annotated_3UTR_file)
  File "/home/dreyfusslab/Desktop/DaPars_APA_analysis/DaPars_main.py", line 500, in Load_Target_Wig_files
    cur_sample_total_depth += int(fields[-1]) * (region_end - region_start)
ValueError: invalid literal for int() with base 10: '1.15903e+06'

-Relevant lines in DaPars_main.py
500:  cur_sample_total_depth += int(fields[-1]) * (region_end - region_start)
507:  
curr_sample_All_chroms_coverage_dict[chrom_name][1].append(int(fields[-1]))

-Proposed solution
One can use the command float() to convert the scientific notation to something 
that is then usable by int().  For example, an updated command for lines 500 
and 507 would be:
500:  cur_sample_total_depth += int(float(fields[-1])) * (region_end - 
region_start)
507:  
curr_sample_All_chroms_coverage_dict[chrom_name][1].append(int(float(fields[-1])
))

This does not produce any error.

Original issue reported on code.google.com by christop...@gmail.com on 9 Jul 2014 at 4:21

GoogleCodeExporter commented 9 years ago
Thank you, christopher,
    We have fixed this issue in our new version (V0.9.1).

Original comment by xiazheng...@gmail.com on 6 Feb 2015 at 10:42