@@ -235,6 +235,9 @@ def execute_vcf_registration(vcf_files, transaction):
235235 register_vcf (vcf , transaction )
236236
237237
238+ def log_duplicate_removal ():
239+ print (mtbutils .log_stardate ('This sample and its data already exist. Removing incoming duplicate.' ))
240+
238241def execute_fastq_registration (fastqs_normal , fastqs_tumor , transaction ):
239242 if len (fastqs_tumor ) < 2 or len (fastqs_normal ) < 2 :
240243 raise mtbutils .MTBdropboxerror ("Tumor/normal fastq dataset was not complete. Please check." )
@@ -394,6 +397,12 @@ def register_vcf(in_file, transaction):
394397 space = space , project = project , barcode = tumor_dna_sample_id )
395398 print (mtbutils .log_stardate ('Preparing sample and experiment creation for {sample} and {experiment}'
396399 .format (sample = new_sample_id , experiment = new_exp_id )))
400+
401+ # If this sample already exists, we log this to startup.log and return, removing the data
402+ if transaction .getSampleForUpdate (new_sample_id ):
403+ log_duplicate_removal ()
404+ return
405+
397406 new_ngs_experiment = transaction .createNewExperiment (new_exp_id , NGS_VARIANT_CALL )
398407 new_ngs_experiment .setPropertyValue ('Q_CURRENT_STATUS' , 'FINISHED' )
399408 new_ngs_sample = transaction .createNewSample (new_sample_id , NGS_VARIANT_CALL )
@@ -538,6 +547,11 @@ def registermtb(archive, transaction):
538547 space = space , project = project , barcode = tumor_dna_sample_id )
539548 print (mtbutils .log_stardate ('Preparing MTB sample and experiment creation for {sample} and {experiment}'
540549 .format (sample = new_sample_id , experiment = new_exp_id )))
550+
551+ # If this sample already exists, we log this to startup.log and return, removing the data
552+ if transaction .getSampleForUpdate (new_sample_id ):
553+ log_duplicate_removal ()
554+ return
541555 new_ngs_experiment = transaction .createNewExperiment (new_exp_id , MTB_EXP_TYPE )
542556 new_ngs_sample = transaction .createNewSample (new_sample_id , MTB_SAMPLE_TYPE )
543557 new_ngs_sample .setParentSampleIdentifiers ([tumor_dna_sample_id ])
@@ -554,7 +568,6 @@ def registermtb(archive, transaction):
554568 # Update sample location
555569 update_sample_location_to_qbic (tumor_dna_sample_id )
556570
557-
558571def submit (archive , transaction ):
559572 """Handles the archive parsing and submition
560573 to CentraXX"""
0 commit comments