def test_faidx(self): cmdline = SamtoolsFaidxCommandline(samtools_exe) cmdline.set_parameter("reference", self.reference) stdout, stderr = cmdline() self.assertFalse( stderr, f"Samtools faidx failed:\n{cmdline}\nStderr:{stderr}") self.assertTrue(os.path.isfile(self.referenceindexfile))
def test_faidx(self): cmdline = SamtoolsFaidxCommandline(samtools_exe) cmdline.set_parameter("reference", self.reference) stdout, stderr = cmdline() self.assertFalse(stderr, "Samtools faidx failed:\n%s\nStderr:%s" % (cmdline, stderr)) self.assertTrue(os.path.isfile(self.referenceindexfile))
def gdcs_fai(sample, analysistype='GDCS'): """ GDCS analyses need to use the .fai file supplied in the targets folder rather than the one created following reverse baiting :param sample: sample object :param analysistype: current analysis being performed """ from Bio.Sequencing.Applications import SamtoolsFaidxCommandline try: # Find the .fai file in the target path sample[analysistype].faifile = glob(os.path.join(sample[analysistype].targetpath, '*.fai'))[0] except IndexError: target_file = glob(os.path.join(sample[analysistype].targetpath, '*.fasta'))[0] samindex = SamtoolsFaidxCommandline(reference=target_file) map(StringIO, samindex(cwd=sample[analysistype].targetpath)) sample[analysistype].faifile = glob(os.path.join(sample[analysistype].targetpath, '*.fai'))[0] # Get the fai file into a dictionary to be used in parsing results try: with open(sample[analysistype].faifile, 'r') as faifile: for line in faifile: data = line.split('\t') try: sample[analysistype].faidict[data[0]] = int(data[1]) except KeyError: sample[analysistype].faidict = dict() sample[analysistype].faidict[data[0]] = int(data[1]) except FileNotFoundError: pass
def test_index_target(variables): targetpath = os.path.join(variables.targetpath, 'bait') target_index = SamtoolsFaidxCommandline( reference=os.path.join(targetpath, 'baitedtargets.fa')) target_index() size = os.stat(os.path.join(targetpath, 'baitedtargets.fa.fai')) assert size.st_size > 0
def create_fasta_index(self): """Create index for reference fasta sequence.""" cmdline = SamtoolsFaidxCommandline(samtools_exe) cmdline.set_parameter("reference", self.reference) stdout, stderr = cmdline()
def create_fasta_index(self): """Creates index for reference fasta sequence.""" cmdline = SamtoolsFaidxCommandline(samtools_exe) cmdline.set_parameter("reference", self.reference) stdout, stderr = cmdline()