def _set_version(self): self.version = None if self.debug: print(self.name, '- checking version ...') if not self.in_path(): if self.debug: print(' ... not in path so cannot get version', flush=True) return cmd = self.exe() + ' ' + self.version_cmd if self.debug: print('Running this command to get version:', cmd) cmd_output = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() cmd_output = common.decode(cmd_output[0]).split('\n')[:-1] + common.decode(cmd_output[1]).split('\n')[:-1] if self.debug: print('__________ (begin output from ', cmd, ')___________', sep='') print(*cmd_output, sep='\n') print('__________ (end of output from ', cmd, ')___________', sep='') print('Looking far a match to the regex "', self.version_regex.pattern, '" in the above output', sep='', flush=True) for line in cmd_output: hits = self.version_regex.search(line) if hits: if self.debug: print('Match to this line:', line) print('Got version:', hits.group(1), flush=True) self.version = hits.group(1) break else: if self.debug: print('No match found to the regex', flush=True)
def version(self): '''Returns version. If not in path, or in path but can't get the version, returns None''' if not self.in_path(): return None cmd = self.exe() + ' ' + self.version_cmd cmd_output = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() cmd_output = common.decode(cmd_output[0]).split('\n')[:-1] + common.decode(cmd_output[1]).split('\n')[:-1] for line in cmd_output: hits = self.version_regex.search(line) if hits: return hits.group(1) return None
def _set_version(self): self.version = None if self.debug: print(self.name, '- checking version ...') if not self.in_path(): if self.debug: print(' ... not in path so cannot get version', flush=True) return cmd = self.exe() + ' ' + self.version_cmd if self.debug: print('Running this command to get version:', cmd) cmd_output = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() cmd_output = common.decode( cmd_output[0]).split('\n')[:-1] + common.decode( cmd_output[1]).split('\n')[:-1] if self.debug: print('__________ (begin output from ', cmd, ')___________', sep='') print(*cmd_output, sep='\n') print('__________ (end of output from ', cmd, ')___________', sep='') print('Looking far a match to the regex "', self.version_regex.pattern, '" in the above output', sep='', flush=True) for line in cmd_output: hits = self.version_regex.search(line) if hits: if self.debug: print('Match to this line:', line) print('Got version:', hits.group(1), flush=True) self.version = hits.group(1) break else: if self.debug: print('No match found to the regex', flush=True)
def aligned_read_to_read(read, revcomp=True, qual=None, ignore_quality=False): '''Returns Fasta or Fastq sequence from pysam aligned read''' if read.qual is None or ignore_quality: if qual is None or ignore_quality: seq = pyfastaq.sequences.Fasta(read.qname, common.decode(read.seq)) else: seq = pyfastaq.sequences.Fastq(read.qname, common.decode(read.seq), qual * read.query_length) else: if qual is None: seq = pyfastaq.sequences.Fastq(read.qname, common.decode(read.seq), common.decode(read.qual)) else: seq = pyfastaq.sequences.Fastq(read.qname, common.decode(read.seq), qual * read.query_length) if read.is_reverse and revcomp: seq.revcomp() return seq
def version(self): '''Returns version. If not in path, or in path but can't get the version, returns None''' if not self.in_path(): return None cmd = self.exe() + ' ' + self.version_cmd cmd_output = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() cmd_output = common.decode( cmd_output[0]).split('\n')[:-1] + common.decode( cmd_output[1]).split('\n')[:-1] for line in cmd_output: hits = self.version_regex.search(line) if hits: return hits.group(1) return None