コード例 #1
0
ファイル: models.py プロジェクト: billyziege/pipeline_project
 def __generate_flowcell_report_text__(self,config,mockdb,report_type="subset_report"):
     """
     Creates the outlier table, saves it to a file, and fills the
     subject and body of the report.
     """
     dictionary = {}
     for k,v in self.__dict__.iteritems():
         dictionary.update({k:str(v)})
     pdf_report = initialize_standard_doc(self.report_pdf)
     pdf_elements = []
     outlier_table = produce_outlier_table(config,mockdb,self.current_report)
     if outlier_table is None:
         template_subject = os.path.join(config.get('Common_directories','template'),config.get('Flowcell_reports_email_templates',report_type + '_subject'))
         template_body = os.path.join(config.get('Common_directories','template'),config.get('Flowcell_reports_email_templates',report_type + '_no_outliers_body'))
     else:
         outlier_table += "\n"
         outlier_table_for_pdf(config,mockdb,pdf_elements,self.current_report)
         template_subject = os.path.join(config.get('Common_directories','template'),config.get('Flowcell_reports_email_templates',report_type + '_subject'))
         template_body = os.path.join(config.get('Common_directories','template'),config.get('Flowcell_reports_email_templates',report_type + '_body'))
     image_files = []
     image_files.append(self.concordance_jpeg)
     image_files.append(self.hethomratio_jpeg)
     image_files.append(self.dbsnp_jpeg)
     image_files.append(self.greater_than_10x_jpeg)
     image_files.append(self.zero_coverage_jpeg)
     pdf_elements.extend(add_square_images(image_files))
     pdf_report.build(pdf_elements)
     sample_keys = self.sample_keys.split(";")
     number_samples = len(sample_keys)
     dictionary.update({'number_samples': str(number_samples)})
     subject = fill_template(template_subject,dictionary)
     body = fill_template(template_body,dictionary)
     return subject, body
コード例 #2
0
ファイル: models.py プロジェクト: billyziege/pipeline_project
 def __generate_repeated_error_text__(self,configs,failed_files):
     template_subject = os.path.join(configs['system'].get('Common_directories','template'),configs['pipeline'].get('Backup_email_templates','repeated_subject'))
     template_body = os.path.join(configs['system'].get('Common_directories','template'),configs['pipelibe'].get('Backup_email_templates','repeated_body'))
     dictionary = {}
     for k,v in self.__dict__.iteritems():
         dictionary.update({k:str(v)})
     dictionary.update({'failed_files': "\n".join(failed_files)})
     subject = fill_template(template_subject,dictionary)
     body = fill_template(template_body,dictionary)
     return subject, body
コード例 #3
0
ファイル: models.py プロジェクト: billyziege/pipeline_project
 def __generate_storage_error_text__(self,config,storage_device):
     template_subject = os.path.join(config.get('Common_directories','template'),config.get('Backup_email_templates','storage_subject'))
     template_body = os.path.join(config.get('Common_directories','template'),config.get('Backup_email_templates','storage_body'))
     dictionary = {}
     for k,v in self.__dict__.iteritems():
         dictionary.update({k:str(v)})
     dictionary.update({'available': str(storage_device.available)})
     subject = fill_template(template_subject,dictionary)
     body = fill_template(template_body,dictionary)
     return subject, body
コード例 #4
0
ファイル: models.py プロジェクト: billyziege/pipeline_project
 def __generate_full_error_text__(self,configs,storage_device):
     template_subject = os.path.join(configs['system'].get('Common_directories','template'),configs['pipeline'].get('Backup_email_templates','full_subject'))
     template_body = os.path.join(configs['system'].get('Common_directories','template'),configs['pipeline'].get('Backup_email_templates','full_body'))
     dictionary = {}
     for k,v in self.__dict__.iteritems():
         dictionary.update({k:str(v)})
     dictionary.update({'available': str(storage_device.available)})
     dictionary.update({'required_fastq_size': str(configs['pipeline'].get('Storage','required_fastq_size'))})
     subject = fill_template(template_subject,dictionary)
     body = fill_template(template_body,dictionary)
     return subject, body
コード例 #5
0
ファイル: models.py プロジェクト: billyziege/pipeline_project
 def __fill_qsub_file__(self,configs):
     """
     Since some of the information for the qsub file is pulled from the config file,
     this finds that information and writes out the qsub file. 
     """
     template_file= os.path.join(configs['system'].get('Common_directories','template'),configs['pipeline'].get('Template_files','snp_stats'))
     dictionary = {}
     for k,v in self.__dict__.iteritems():
         dictionary.update({k:str(v)})
     dictionary.update({'vcf_conversion_script':configs['pipeline'].get('Concordance','vcf_conversion_script')})
     dictionary.update({'filter_file':configs['pipeline'].get('Filenames','snp_filter_file')})
     with open(self.qsub_file,'w') as f:
         f.write(fill_template(template_file,dictionary))
コード例 #6
0
ファイル: models.py プロジェクト: billyziege/pipeline_project
 def __fill_qsub_file__(self,configs):
     """
     Fills the qsub file from a template.  Since not all information is archived in the parent object, 
     the function also gets additional information on the fly for the qsub file.
     """
     template_file= os.path.join(configs['system'].get('Common_directories','template'),configs['pipeline'].get('Template_files','flowcell_report'))
     dictionary = {}
     for k,v in self.__dict__.iteritems():
         dictionary.update({k:str(v)})
     dictionary.update({'post_pipeline':configs['pipeline'].get('Db_reports','post_pipeline')})
     dictionary.update({'concord_script':configs['pipeline'].get('Flowcell_reports','concord_script')})
     dictionary.update({'dbsnp_script':configs['pipeline'].get('Flowcell_reports','dbsnp_script')})
     dictionary.update({'tenx_script':configs['pipeline'].get('Flowcell_reports','tenx_script')})
     dictionary.update({'zero_script':configs['pipeline'].get('Flowcell_reports','zero_script')})
     dictionary.update({'hethom_script':configs['pipeline'].get('Flowcell_reports','hethom_script')})
     dictionary.update({'reads_script':configs['pipeline'].get('Flowcell_reports','reads_script')})
     with open(self.qsub_file,'w') as f:
         f.write(fill_template(template_file,dictionary))
コード例 #7
0
ファイル: models.py プロジェクト: billyziege/pipeline_project
 def __fill_qsub_file__(self,configs):
     """
     This handles the qsub file which gathers the results of the scattered
     processes.
     """
     template_file= os.path.join(configs['system'].get('Common_directories','template'),configs['pipeline'].get('Template_files','concord_search'))
     list_files = configs['pipeline'].get('Concordance','split_lists').split(',')
     dictionary = {}
     for k,v in self.__dict__.iteritems():
         dictionary.update({k:str(v)})
     individual_search_outputs = []
     for list_file in list_files:
         name = re.sub('.ls','',os.path.basename(list_file))
         output_file = self.sub_qsub_file_front + name + '.con'
         individual_search_outputs.append(output_file)
     dictionary.update({'split_files':" ".join(individual_search_outputs)})
     with open(self.qsub_file,'w') as f:
         f.write(fill_template(template_file,dictionary))
コード例 #8
0
ファイル: models.py プロジェクト: billyziege/pipeline_project
 def __fill_qsub_file__(self,configs,template_config=None):
     """
     Simply fills process_name template with appropriate info. 
     """
     if configs["system"].get("Logging","debug") is "True":
         print "Trying to fill " + self.qsub_file
     if template_config is None:
         print configs['system'].get('Common_directories','template')
         print self.process_name
         print configs['pipeline'].get('Template_files',self.process_name)
         template_file= os.path.join(configs['system'].get('Common_directories','template'),configs['pipeline'].get('Template_files',self.process_name))
     else:
         template_file= os.path.join(configs['system'].get('Common_directories','template'),template_config.get('Template_files',self.process_name))
     if configs["system"].get("Logging","debug") is "True":
        print  "Template file " + template_file
     with open(self.qsub_file,'w') as f:
         if configs["system"].get("Logging","debug") is "True":
             print "Filling qsub with " + str(self.__dict__)
         f.write(fill_template(template_file,self.__dict__))
コード例 #9
0
ファイル: models.py プロジェクト: billyziege/pipeline_project
 def __fill_qsub_file__(self,configs):
     """
     Fills the qsub file from a template.  Since not all information is archived in the parent object, 
     the function also gets additional information on the fly for the qsub file.
     """
     template_file= os.path.join(configs['system'].get('Common_directories','template'),configs['pipeline'].get('Template_files',self.process_name))
     r1_list = [ os.path.join(self.input_dir,f) for f in os.listdir(self.input_dir) if re.search("R1[\.,\w]*\.fastq",f) ]
     r1_list.sort()
     list_of_r1_files = " ".join(r1_list)
     r2_list = [ os.path.join(self.input_dir,f) for f in os.listdir(self.input_dir) if re.search("R2[\.,\w]*\.fastq",f) ]
     r2_list.sort()
     list_of_r2_files = " ".join(r2_list)
     dictionary = {}
     for k,v in self.__dict__.iteritems():
         dictionary.update({k:str(v)})
     dictionary.update({'list_of_r1_files':list_of_r1_files})
     dictionary.update({'list_of_r2_files':list_of_r2_files})
     with open(self.qsub_file,'w') as f:
         f.write(fill_template(template_file,dictionary))
コード例 #10
0
ファイル: models.py プロジェクト: billyziege/pipeline_project
 def __fill_template__(self,template_file,output_fname):
     """
     Since the bcbio object does not retain all the information necessary for 
     some of the templates, this finds and adds the additional information and
     then fills the template file and writes as the output file.
     """
     dictionary = {}
     for k,v in self.__dict__.iteritems():
         if k == 'sample_key':
             try:
                 int(v)
                 new_sample_key = "Sample_" + str(v)
                 dictionary.update({k:new_sample_key})
                 continue
             except ValueError:
                 pass
         dictionary.update({k:str(v)})
     dictionary.update({'restats_tail': self.restats_file + '.tail'})
     with open(output_fname,'w') as f:
         string = fill_template(template_file,dictionary)
         f.write(string)
コード例 #11
0
ファイル: models.py プロジェクト: billyziege/pipeline_project
 def __fill_sub_qsub_files__(self,configs):
     """
     This handles scattering the search across nodes.
     """
     template_file= os.path.join(configs['system'].get('Common_directories','template'),configs['pipeline'].get('Template_files','individual_search'))
     list_files = configs['pipeline'].get('Concordance','split_lists').split(',')
     dictionary = {}
     for k,v in self.__dict__.iteritems():
         dictionary.update({k:str(v)})
     for list_file in list_files:
         name = re.sub('.ls','',os.path.basename(list_file))
         qsub_file = self.sub_qsub_file_front + name + '.sh'
         output_file = self.sub_qsub_file_front + name + '.con'
         complete_file = self.sub_qsub_file_front + name + '.complete'
         dictionary.update({'search_list':list_file})
         dictionary.update({'output_file':output_file}) #Overwrites the object's output file (not saved)
         dictionary.update({'complete_file':complete_file}) #Overwrites the object's complete file (not saved)
         dictionary.update({'vcf_conversion_script':configs['pipeline'].get('Concordance','vcf_conversion_script')})
         dictionary.update({'filter_file':configs['pipeline'].get('Filenames','snp_filter_file')})
         with open(qsub_file,'w') as f:
             f.write(fill_template(template_file,dictionary))
コード例 #12
0
ファイル: models.py プロジェクト: billyziege/pipeline_project
 def __fill_qsub_file__(self,configs,r_list=None):
     """
     Fills the qsub file from a template.  Since not all information is archived in the parent object, 
     the function also gets additional information on the fly for the qsub file.
     """
     template_file= os.path.join(configs['system'].get('Common_directories','template'),'generic_qsub.template')
     if r_list is None:
         r_list = [ fname for fname in os.listdir(self.input_dir) if re.search("R[1,2]\w*\.fastq",fname) ]
     dictionary = {}
     for k,v in self.__dict__.iteritems():
         dictionary.update({k:str(v)})
     commands = ""
     copy = configs['pipeline'].get('Backup','copy')
     keygen = configs['pipeline'].get('Backup','generate_key')
     for fname in r_list:
         key_in = os.path.join(configs['pipeline'].get('Backup','key_repository'),fname + configs['pipeline'].get('Backup','key_extension'))
         key_out = os.path.join(self.output_dir,fname + configs['pipeline'].get('Backup','key_extension'))
         commands += "cd " + self.input_dir + "\n" + copy   + " " + fname + " " + self.output_dir + "\n"
         commands += "cd " + self.input_dir + "\n" + keygen + " " + fname + " > " + key_in + "\n"
         commands += "cd " + self.output_dir + "\n" + keygen + " " + fname + " > " + key_out + "\n"
     dictionary.update({'commands': commands})
     with open(self.qsub_file,'w') as f:
         f.write(fill_template(template_file,dictionary))
コード例 #13
0
ファイル: models.py プロジェクト: billyziege/pipeline_project
 def __fill_qsub_file__(self,configs,template_config=None):
     """
     Simply fills process_name template with appropriate info. Needed to detangle the masks.
     """
     if configs["system"].get("Logging","debug") is "True":
         print "Trying to fill " + self.qsub_file
     if template_config is None:
         print configs['system'].get('Common_directories','template')
         print self.process_name
         print configs['pipeline'].get('Template_files',self.process_name)
         template_file= os.path.join(configs['system'].get('Common_directories','template'),configs['pipeline'].get('Template_files',self.process_name))
     else:
         template_file= os.path.join(configs['system'].get('Common_directories','template'),template_config.get('Template_files',self.process_name))
     if configs["system"].get("Logging","debug") is "True":
        print  "Template file " + template_file
     with open(self.qsub_file,'w') as f:
         dictionary = {}
         for key, value in self.__dict__.iteritems():
             if key == 'mask':
                 value, number = re.subn('-',',',value)
             dictionary[key] = value
         if configs["system"].get("Logging","debug") is "True":
             print "Filling qsub with " + str(dictionary)
         f.write(fill_template(template_file,dictionary))
コード例 #14
0
ファイル: test.py プロジェクト: billyziege/pipeline_project
import sys
from mako.template import Template
from template.scripts import find_fields,fill_template

fname = '/mnt/iscsi_speed/zerbeb/qc_pipeline_project/qc_pipeline/storage/templates/zcat.template'
keys = '/mnt/iscsi_speed/zerbeb/qc_pipeline_project/qc_pipeline/keys'
#with open(fname,'r') as f:
#    print "\n".join(set(find_fields(f.read())))
d = {}
with open(keys,'r') as f:
    for line in f:
        k,v = line.split()
        d.update({k:v})
print fill_template(fname,d)

#fields = ['list_of_r1_files', 'out_dir', 'r1_file', 'stderr', 'list_of_r2_files', 'r2_file', 'complete_file','extra']
#vals = ['r1_list', 'output', 'r1_file', 'stderr_file', 'r2_list', 'r2_file', 'complete', 'nowhere']
#tmpl = Template(filename=fname)
#dictionary = dict(zip(fields, vals))
#print fill_template(tmpl,dictionary)
コード例 #15
0
ファイル: models.py プロジェクト: billyziege/pipeline_project
 def __generate_general_error_text__(self,config):
     template_subject = os.path.join(config.get('Common_directories','template'),config.get('Bcbio_email_templates','general_subject'))
     template_body = os.path.join(config.get('Common_directories','template'),config.get('Bcbio_email_templates','general_body'))
     subject = fill_template(template_subject,self.__dict__)
     body = fill_template(template_body, self.__dict__)
     return subject, body