Example #1
0
 def set_meta( self, dataset, **kwd ):
     Text.set_meta(self, dataset, **kwd )
     data_dir = dataset.extra_files_path
     ## search data_dir/genome_version for files
     regulation_pattern = 'regulation_(.+).bin'
     #  annotation files that are included in snpEff by a flag
     annotations_dict = {'nextProt.bin' : '-nextprot','motif.bin': '-motif'}
     regulations = []
     annotations = []
     if data_dir and os.path.isdir(data_dir):
         for root, dirs, files in os.walk(data_dir):
             for fname in files:
                 if fname.startswith('snpEffectPredictor'):
                     # if snpEffectPredictor.bin download succeeded
                     genome_version = os.path.basename(root)
                     dataset.metadata.genome_version = genome_version
                 else:
                     m = re.match(regulation_pattern,fname)
                     if m:
                         name = m.groups()[0]
                         regulations.append(name)
                     elif fname in annotations_dict:
                         value = annotations_dict[fname]
                         name = value.lstrip('-')
                         annotations.append(name)
         dataset.metadata.regulation = regulations
         dataset.metadata.annotation = annotations
Example #2
0
 def set_meta(self, dataset, **kwd):
     Text.set_meta(self, dataset, **kwd)
     data_dir = dataset.extra_files_path
     # search data_dir/genome_version for files
     regulation_pattern = 'regulation_(.+).bin'
     #  annotation files that are included in snpEff by a flag
     annotations_dict = {
         'nextProt.bin': '-nextprot',
         'motif.bin': '-motif',
         'interactions.bin': '-interaction'
     }
     regulations = []
     annotations = []
     genome_version = None
     snpeff_version = None
     if data_dir and os.path.isdir(data_dir):
         for root, dirs, files in os.walk(data_dir):
             for fname in files:
                 if fname.startswith('snpEffectPredictor'):
                     # if snpEffectPredictor.bin download succeeded
                     genome_version = os.path.basename(root)
                     dataset.metadata.genome_version = genome_version
                     # read the first line of the gzipped snpEffectPredictor.bin file to get the SnpEff version
                     snpeff_version = self.getSnpeffVersionFromFile(
                         os.path.join(root, fname))
                     if snpeff_version:
                         dataset.metadata.snpeff_version = snpeff_version
                 else:
                     m = re.match(regulation_pattern, fname)
                     if m:
                         name = m.groups()[0]
                         regulations.append(name)
                     elif fname in annotations_dict:
                         value = annotations_dict[fname]
                         name = value.lstrip('-')
                         annotations.append(name)
         dataset.metadata.regulation = regulations
         dataset.metadata.annotation = annotations
         try:
             with open(dataset.file_name, 'w') as fh:
                 fh.write(
                     "%s\n" %
                     genome_version if genome_version else 'Genome unknown')
                 fh.write("%s\n" % snpeff_version
                          if snpeff_version else 'SnpEff version unknown')
                 if annotations:
                     fh.write("annotations: %s\n" % ','.join(annotations))
                 if regulations:
                     fh.write("regulations: %s\n" % ','.join(regulations))
         except Exception:
             pass
Example #3
0
 def set_meta( self, dataset, **kwd ):
     Text.set_meta(self, dataset, **kwd )
     data_dir = dataset.extra_files_path
     # search data_dir/genome_version for files
     regulation_pattern = 'regulation_(.+).bin'
     #  annotation files that are included in snpEff by a flag
     annotations_dict = {'nextProt.bin' : '-nextprot', 'motif.bin': '-motif'}
     regulations = []
     annotations = []
     genome_version = None
     snpeff_version = None
     if data_dir and os.path.isdir(data_dir):
         for root, dirs, files in os.walk(data_dir):
             for fname in files:
                 if fname.startswith('snpEffectPredictor'):
                     # if snpEffectPredictor.bin download succeeded
                     genome_version = os.path.basename(root)
                     dataset.metadata.genome_version = genome_version
                     # read the first line of the gzipped snpEffectPredictor.bin file to get the SnpEff version
                     snpeff_version = self.getSnpeffVersionFromFile(os.path.join(root, fname))
                     if snpeff_version:
                         dataset.metadata.snpeff_version = snpeff_version
                 else:
                     m = re.match(regulation_pattern, fname)
                     if m:
                         name = m.groups()[0]
                         regulations.append(name)
                     elif fname in annotations_dict:
                         value = annotations_dict[fname]
                         name = value.lstrip('-')
                         annotations.append(name)
         dataset.metadata.regulation = regulations
         dataset.metadata.annotation = annotations
         try:
             fh = file(dataset.file_name, 'w')
             fh.write("%s\n" % genome_version if genome_version else 'Genome unknown')
             fh.write("%s\n" % snpeff_version if snpeff_version else 'SnpEff version unknown')
             if annotations:
                 fh.write("annotations: %s\n" % ','.join(annotations))
             if regulations:
                 fh.write("regulations: %s\n" % ','.join(regulations))
             fh.close()
         except:
             pass
Example #4
0
 def set_meta(self, dataset, **kwd):
     Text.set_meta(self, dataset, **kwd)
     data_dir = dataset.extra_files_path
     ## search data_dir/genome_version for files
     regulation_pattern = "regulation_(.+).bin"
     #  annotation files that are included in snpEff by a flag
     annotations_dict = {"nextProt.bin": "-nextprot", "motif.bin": "-motif"}
     regulations = []
     annotations = []
     if data_dir and os.path.isdir(data_dir):
         for root, dirs, files in os.walk(data_dir):
             for fname in files:
                 if fname.startswith("snpEffectPredictor"):
                     # if snpEffectPredictor.bin download succeeded
                     genome_version = os.path.basename(root)
                     dataset.metadata.genome_version = genome_version
                 else:
                     m = re.match(regulation_pattern, fname)
                     if m:
                         name = m.groups()[0]
                         regulations.append(name)
                     elif fname in annotations_dict:
                         value = annotations_dict[fname]
                         name = value.lstrip("-")
                         annotations.append(name)
         dataset.metadata.regulation = regulations
         dataset.metadata.annotation = annotations
         try:
             fh = file(dataset.file_name, "w")
             fh.write("%s\n" % genome_version)
             if annotations:
                 fh.write("annotations: %s\n" % ",".join(annotations))
             if regulations:
                 fh.write("regulations: %s\n" % ",".join(regulations))
             fh.close()
         except:
             pass