def set_ref_data(self): """Write the reference sequence to a fasta file for this specific target if it does not exist. Args: None Returns: None Raise: None """ # Write reference fasta file if needed. for i in range(len(self.files['target_ref_fn'])): fn = self.files['target_ref_fn'][i] direction = "forward" if fn.find("forward") != -1 else "reverse" utils.log(self.loggingName, 'info', 'Extracting refseq sequence and writing %s' % fn) utils.extract_refseq_fa(self.values, self.paths['ref_data'], self.params.get_param('reference_fasta'), direction, fn) # If using blatn for target realignment, the db must be available. blastn = self.params.get_param('blast') if blastn is not None: # Check if blast db files are available for each target. if not os.path.isfile(self.files['target_ref_fn'][0] + '.nin'): makedb = os.path.join(os.path.split(blastn)[0], 'makeblastdb') # Create blast db cmd = "%s -in %s -dbtype 'nucl' -out %s" % (makedb, self.files['target_ref_fn'][0], self.files['target_ref_fn'][0]) utils.log(self.loggingName, 'info', 'Creating blast db files for target %s with reference file %s' % (self.name, self.files['target_ref_fn'][0])) p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) output, errors = p.communicate() if errors != '': utils.log(self.loggingName, 'debug', 'Failed to make blast db files using reference file %s' % self.files['target_ref_fn'][0])
def set_ref_data(self): ''' ''' # Write rmask bed file if needed. # if not self.params.opts['keep_repeat_regions'] and 'repeat_mask_file' in self.params.opts: # self.logger.info('Extracting repeat mask regions for target gene %s.' % self.name) # self.repeat_mask = setup_rmask(self.get_values(), self.paths['ref_data'], self.params.opts['repeat_mask_file']) # Write reference fasta file if needed. for target_refseq_fn in self.files['target_ref_fn']: direction = "forward" if target_refseq_fn.find("forward") == -1: direction = "reverse" utils.log(self.logging_name, 'info', 'Extracting refseq sequence and writing %s' % target_refseq_fn) utils.extract_refseq_fa(self.get_values(), self.paths['ref_data'], self.params.get_param('reference_fasta'), direction, target_refseq_fn, self.params.get_param('buffer_size'))
def set_ref_data(self): """Write the reference sequence to a fasta file for this specific target if it does not exist. Args: None Returns: None Raise: None """ # Write reference fasta file if needed. for i in range(len(self.files['target_ref_fn'])): fn = self.files['target_ref_fn'][i] direction = "forward" if fn.find("forward") != -1 else "reverse" utils.log(self.loggingName, 'info', 'Extracting refseq sequence and writing %s' % fn) utils.extract_refseq_fa(self.values, self.paths['ref_data'], self.params.get_param('reference_fasta'), direction, fn) # If using blatn for target realignment, the db must be available. blastn = self.params.get_param('blast') if blastn is not None: # Check if blast db files are available for each target. if not os.path.isfile(self.files['target_ref_fn'][0] + '.nin'): makedb = os.path.join(os.path.split(blastn)[0], 'makeblastdb') # Create blast db cmd = "%s -in %s -dbtype 'nucl' -out %s" % ( makedb, self.files['target_ref_fn'][0], self.files['target_ref_fn'][0]) utils.log( self.loggingName, 'info', 'Creating blast db files for target %s with reference file %s' % (self.name, self.files['target_ref_fn'][0])) p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) output, errors = p.communicate() if errors != '': utils.log( self.loggingName, 'debug', 'Failed to make blast db files using reference file %s' % self.files['target_ref_fn'][0])