def test_missing_fai_error_message(self): outdir = tempfile.mkdtemp(suffix="dataset-unittest") inFas = os.path.join(outdir, 'infile.fasta') # copy fasta reference to hide fai and ensure FastaReader is used shutil.copyfile( ReferenceSet(data.getXml(8)).toExternalFiles()[0], inFas) rs1 = ContigSet(inFas) with pytest.raises(IOError) as cm: rs1.assertIndexed() assert str(cm) == ( "Companion FASTA index (.fai) file not found or malformatted! " "Use 'samtools faidx' to generate FASTA index.")
def test_missing_fai_error_message(self): outdir = tempfile.mkdtemp(suffix="dataset-unittest") inFas = os.path.join(outdir, 'infile.fasta') # copy fasta reference to hide fai and ensure FastaReader is used backticks('cp {i} {o}'.format( i=ReferenceSet(data.getXml(9)).toExternalFiles()[0], o=inFas)) rs1 = ContigSet(inFas) with self.assertRaises(IOError) as cm: rs1.assertIndexed() self.assertEqual( str(cm.exception), ( "Companion FASTA index (.fai) file not found or malformatted! " "Use 'samtools faidx' to generate FASTA index."))
def test_missing_fai_error_message(self): outdir = tempfile.mkdtemp(suffix="dataset-unittest") inFas = os.path.join(outdir, 'infile.fasta') # copy fasta reference to hide fai and ensure FastaReader is used backticks('cp {i} {o}'.format(i=ReferenceSet( data.getXml(9)).toExternalFiles()[0], o=inFas)) rs1 = ContigSet(inFas) with self.assertRaises(IOError) as cm: rs1.assertIndexed() self.assertEqual( str(cm.exception), ("Companion FASTA index (.fai) file not found or malformatted! " "Use 'samtools faidx' to generate FASTA index."))
def n_reads_in_contigset(contigset_file): """Return number of reads in a contigset""" cs = ContigSet(contigset_file) cs.assertIndexed() return int(cs.numRecords)