Example #1
0
 def test_twoheaders(self):
     fmt = FastqFormat()
     with open_output(self.path, "w") as fw:
         fw.write(fmt.format(Sequence("name", "CCATA", "!#!#!", name2="name")))
         fw.write(fmt.format(Sequence("name2", "HELLO", "&&&!&", name2="name2")))
     with open(self.path) as t:
         assert t.read() == '@name\nCCATA\n+name\n!#!#!\n@name2\nHELLO\n+name2\n&&&!&\n'
Example #2
0
 def test_write_sequence_object(self):
     fmt = FastaFormat()
     with open_output(self.path, "w") as fw:
         fw.write(fmt.format(Sequence("name", "CCATA")))
         fw.write(fmt.format(Sequence("name2", "HELLO")))
     with open(self.path) as t:
         assert t.read() == '>name\nCCATA\n>name2\nHELLO\n'
Example #3
0
 def test(self):
     fmt = FastqFormat()
     with open_output(self.path, "w") as fw:
         fw.write(fmt.format_entry("name", "CCATA", "!#!#!"))
         fw.write(fmt.format_entry("name2", "HELLO", "&&&!&&"))
     with open(self.path) as t:
         assert t.read() == '@name\nCCATA\n+\n!#!#!\n@name2\nHELLO\n+\n&&&!&&\n'
Example #4
0
 def test_autodetect_fastq_format(self):
     path = os.path.join(self._tmpdir, 'tmp.fastq')
     fmt = get_format(path)
     with open_output(path, "w") as f:
         for seq in simple_fastq:
             f.write(fmt.format(seq))
     assert list(openseq(path)) == simple_fastq
Example #5
0
	def test_twoheaders(self):
		fmt = FastqFormat()
		with open_output(self.path, "w") as fw:
			fw.write(fmt.format(Sequence("name", "CCATA", "!#!#!", name2="name")))
			fw.write(fmt.format(Sequence("name2", "HELLO", "&&&!&", name2="name2")))
		with open(self.path) as t:
			assert t.read() == '@name\nCCATA\n+name\n!#!#!\n@name2\nHELLO\n+name2\n&&&!&\n'
Example #6
0
	def test(self):
		fmt = FastqFormat()
		with open_output(self.path, "w") as fw:
			fw.write(fmt.format_entry("name", "CCATA", "!#!#!"))
			fw.write(fmt.format_entry("name2", "HELLO", "&&&!&&"))
		with open(self.path) as t:
			assert t.read() == '@name\nCCATA\n+\n!#!#!\n@name2\nHELLO\n+\n&&&!&&\n'
Example #7
0
	def test_write_sequence_object(self):
		fmt = FastaFormat()
		with open_output(self.path, "w") as fw:
			fw.write(fmt.format(Sequence("name", "CCATA")))
			fw.write(fmt.format(Sequence("name2", "HELLO")))
		with open(self.path) as t:
			assert t.read() == '>name\nCCATA\n>name2\nHELLO\n'
Example #8
0
	def test_autodetect_fastq_format(self):
		path = os.path.join(self._tmpdir, 'tmp.fastq')
		fmt = get_format(path)
		with open_output(path, "w") as f:
			for seq in simple_fastq:
				f.write(fmt.format(seq))
		assert list(openseq(path)) == simple_fastq
Example #9
0
 def test_write_qualities_to_fasta(self):
     path = os.path.join(self._tmpdir, 'tmp.fasta')
     fmt = get_format(path, qualities=True)
     assert isinstance(fmt, FastaFormat)
     with open_output(path, "w") as f:
         for seq in simple_fastq:
             f.write(fmt.format(seq))
     assert list(openseq(path)) == simple_fasta
Example #10
0
	def test_write_qualities_to_fasta(self):
		path = os.path.join(self._tmpdir, 'tmp.fasta')
		fmt = get_format(path, qualities=True)
		assert isinstance(fmt, FastaFormat)
		with open_output(path, "w") as f:
			for seq in simple_fastq:
				f.write(fmt.format(seq))
		assert list(openseq(path)) == simple_fasta
Example #11
0
 def test_linelength(self):
     fmt = FastaFormat(line_length=3)
     with open_output(self.path, "w") as fw:
         fw.write(fmt.format_entry("r1", "ACG"))
         fw.write(fmt.format_entry("r2", "CCAT"))
         fw.write(fmt.format_entry("r3", "TACCAG"))
     with open(self.path) as t:
         x=t.read()
         print(x)
         assert x == '>r1\nACG\n>r2\nCCA\nT\n>r3\nTAC\nCAG\n'
Example #12
0
	def test_linelength(self):
		fmt = FastaFormat(line_length=3)
		with open_output(self.path, "w") as fw:
			fw.write(fmt.format_entry("r1", "ACG"))
			fw.write(fmt.format_entry("r2", "CCAT"))
			fw.write(fmt.format_entry("r3", "TACCAG"))
		with open(self.path) as t:
			x=t.read()
			print(x)
			assert x == '>r1\nACG\n>r2\nCCA\nT\n>r3\nTAC\nCAG\n'