Back to index

python-biopython  1.60
Public Member Functions
test_SeqIO_FastaIO.TitleFunctions Class Reference

List of all members.

Public Member Functions

def simple_check
def multi_check
def test_no_name

Detailed Description

Cunning unit test where methods are added at run time.

Definition at line 65 of file test_SeqIO_FastaIO.py.


Member Function Documentation

def test_SeqIO_FastaIO.TitleFunctions.multi_check (   self,
  filename,
  alphabet 
)
Basic test for parsing multi-record FASTA files.

Definition at line 88 of file test_SeqIO_FastaIO.py.

00088 
00089     def multi_check(self, filename, alphabet):
00090         """Basic test for parsing multi-record FASTA files."""
00091         re_titled = list(FastaIterator(open(filename), alphabet, title_to_ids))
00092         default = list(SeqIO.parse(open(filename), "fasta", alphabet))
00093         self.assertEqual(len(re_titled), len(default))
00094         for old, new in zip(default, re_titled):
00095             idn, name, descr = title_to_ids(old.description)
00096             self.assertEqual(new.id, idn)
00097             self.assertEqual(new.name, name)
00098             self.assertEqual(new.description, descr)
00099             self.assertEqual(str(new.seq), str(old.seq))
00100             self.assertEqual(new.seq.alphabet, old.seq.alphabet)
00101         #Uncomment this for testing the methods are calling the right files:
00102         #print "{%s done}" % filename,

Here is the call graph for this function:

def test_SeqIO_FastaIO.TitleFunctions.simple_check (   self,
  filename,
  alphabet 
)
Basic test for parsing single record FASTA files.

Definition at line 67 of file test_SeqIO_FastaIO.py.

00067 
00068     def simple_check(self, filename, alphabet):
00069         """Basic test for parsing single record FASTA files."""
00070         title, seq = read_title_and_seq(filename) #crude parser
00071         #First check using Bio.SeqIO.FastaIO directly with title function,
00072         record = read_single_with_titles(filename, alphabet)
00073         idn, name, descr = title_to_ids(title)
00074         self.assertEqual(record.id, idn)
00075         self.assertEqual(record.name, name)
00076         self.assertEqual(record.description, descr)
00077         self.assertEqual(str(record.seq), seq)
00078         self.assertEqual(record.seq.alphabet, alphabet)
00079         #Now check using Bio.SeqIO (default settings)
00080         record = SeqIO.read(open(filename), "fasta", alphabet)
00081         self.assertEqual(record.id, title.split()[0])
00082         self.assertEqual(record.name, title.split()[0])
00083         self.assertEqual(record.description, title)
00084         self.assertEqual(str(record.seq), seq)
00085         self.assertEqual(record.seq.alphabet, alphabet)
00086         #Uncomment this for testing the methods are calling the right files:
00087         #print "{%s done}" % filename,

Here is the call graph for this function:

Test FASTA record with no identifier.

Definition at line 103 of file test_SeqIO_FastaIO.py.

00103 
00104     def test_no_name(self):
00105         """Test FASTA record with no identifier."""
00106         handle = StringIO(">\nACGT")
00107         record = SeqIO.read(handle, "fasta")
00108         handle.close()
00109         self.assertEqual(str(record.seq), "ACGT")
00110         self.assertEqual("", record.id)
00111         self.assertEqual("", record.name)
00112         self.assertEqual("", record.description)
00113 


The documentation for this class was generated from the following file: