jajclement / hotSSDS

2 stars 1 forks source link

check_design.py can result in an unbound variable error #6

Open andpet0101 opened 2 years ago

andpet0101 commented 2 years ago

When running the pipeline on a single sample, e.g.:

group,replicate,fastq_1,fastq_2,antibody,control
Library,1,Library_R1.fastq.gz,Library_R2.fastq.gz,,

the script check_design.py results in an unbound variable error python error at line 172:

    ## WRITE SAMPLE TO CONTROL MAPPING FILE
    if wcontrol == 1 : 
        fout = open(ControlMappingFile,'w')
        fout.write(','.join(['sample_id','control_id','antibody','replicatesExist','multipleGroups']) + '\n')
        for antibody in sorted(antibodyGroupDict.keys()):

The reason is that in this particular situation wcontrol was never defined before. The fix here would be to just initialize it with zero at the beginning of the function ( wcontrol = 0).

Andreas

andpet0101 commented 2 years ago

I just realised that when I have a antibody/input sample pair and another (stand-alone antibody) sample, the script will also not work. Consider this samples.csv:

group,replicate,fastq_1,fastq_2,antibody,control
Input-AG,1,Input-AG_R1.fastq.gz,Input-AG_R2.fastq.gz,,
DMC1-AG,1,DMC1-AG_R1.fastq.gz,DMC1-AG_R2.fastq.gz,DMC1,Input-AG
Other_AB,1,Other_AB_R1.fastq.gz,Other_AB_R2.fastq.gz,AB,

After parsing the second line, the wcontrol variable in the script check_design.py would be set to 1 meaning that the file design_controls.csv would be written at the end (which is intended right). But when parsing the third line wcontrol will be set back to 0 and the file will no produced?

My fix for now would be to remove wcontrol = 0at line 98 in the script and see what will happen.

Andreas