jhrf / telomerecat

Telomerecat: The telomere computational analysis tool
GNU General Public License v3.0
14 stars 2 forks source link

Parabam undefined variable? #2

Open brainstorm opened 6 years ago

brainstorm commented 6 years ago

Today I found another small defect while running another sample through, this time in parabam, probably that code path is not being hit that often?:

Traceback (most recent call last):
  File "parabam/core.pyx", line 49, in parabam.core.CmdLineInterface.handle (parabam/core.c:3184)
  File "/data/cephfs/punim0010/projects/Valls_10X_Telomeres/telomerecat/bam2length.py", line 42, in run_cmd
    simulator_n=self.cmd_args.simulator_runs)
  File "/data/cephfs/punim0010/projects/Valls_10X_Telomeres/telomerecat/bam2length.py", line 80, in run
    correct_f2a=correct_f2a)
  File "/data/cephfs/punim0010/projects/Valls_10X_Telomeres/telomerecat/telbam2length.py", line 945, in run
    vital_stats = vital_stats_finder.get_vital_stats(sample_path)
  File "/data/cephfs/punim0010/projects/Valls_10X_Telomeres/telomerecat/telbam2length.py", line 466, in get_vital_stats
    vital_stats_csv = self.__run_vital_rule__(sample_path)
  File "/data/cephfs/punim0010/projects/Valls_10X_Telomeres/telomerecat/telbam2length.py", line 524, in __run_vital_rule__
    struc_blueprint=structures)
  File "parabam/command/stat.pyx", line 372, in parabam.command.stat.Stat.run (parabam/command/stat.c:12807)
  File "parabam/command/core.pyx", line 564, in parabam.command.core.Interface.run (parabam/command/core.c:14362)
  File "parabam/core.pyx", line 575, in parabam.core.Leviathan.run (parabam/core.c:14519)
  File "parabam/core.pyx", line 913, in parabam.core.ParentAlignmentFile.__init__ (parabam/core.c:21961)
UnboundLocalError: local variable 'parent' referenced before assignment

At this point I would suggest to start putting in place a small functional testsuite to spot/catch those early ;)

adamcweiner commented 4 years ago

I was getting the same error code but then realized that I was only an issue whenever the telbam file was empty (i.e. no telomeric reads found in the given BAM file). It would be nice to have some try-except magic incorporated into both bam2length and telbam2length so that a default CSV is created for samples with this error case.