Back to index

python-biopython  1.60
Classes | Functions | Variables
test_SeqIO_FastaIO Namespace Reference

Classes

class  TitleFunctions

Functions

def title_to_ids
def read_single_with_titles
def read_title_and_seq
def funct

Variables

list single_nucleic_files
list multi_dna_files = ['Quality/example.fasta']
list single_amino_files
list multi_amino_files = ['Fasta/f002', 'Fasta/fa01']
tuple name = filename.split(".")
tuple runner = unittest.TextTestRunner(verbosity = 2)

Function Documentation

Definition at line 128 of file test_SeqIO_FastaIO.py.

00128 
00129     def funct(fn):
00130         f = lambda x : x.simple_check(fn, generic_nucleotide)
00131         f.__doc__ = "Checking nucleotide file %s" % fn
        return f
def test_SeqIO_FastaIO.read_single_with_titles (   filename,
  alphabet 
)

Definition at line 41 of file test_SeqIO_FastaIO.py.

00041 
00042 def read_single_with_titles(filename, alphabet):
00043     global title_to_ids
00044     iterator = FastaIterator(open(filename), alphabet, title_to_ids)
00045     record = iterator.next()
00046     try:
00047         second = iterator.next()
00048     except StopIteration:
00049         second = None
00050     assert record is not None and second is None
00051     return record

Here is the call graph for this function:

Here is the caller graph for this function:

Crude parser that gets the first record from a FASTA file.

Definition at line 52 of file test_SeqIO_FastaIO.py.

00052 
00053 def read_title_and_seq(filename):
00054     """Crude parser that gets the first record from a FASTA file."""
00055     handle = open(filename)
00056     title = handle.readline().rstrip()
00057     assert title.startswith(">")
00058     seq = ""
00059     for line in handle:
00060         if line.startswith(">") : break
00061         seq += line.strip()
00062     handle.close()
00063     return title[1:], seq
00064 

Here is the call graph for this function:

Here is the caller graph for this function:

Function to convert a title into the id, name, and description.

This is just a quick-n-dirty implementation, and is definately not meant
to handle every FASTA title line case.

Definition at line 14 of file test_SeqIO_FastaIO.py.

00014 
00015 def title_to_ids(title):
00016     """Function to convert a title into the id, name, and description.
00017 
00018     This is just a quick-n-dirty implementation, and is definately not meant
00019     to handle every FASTA title line case.
00020     """
00021     # first split the id information from the description
00022     # the first item is the id info block, the rest is the description
00023     all_info = title.split(" ")
00024     id_info = all_info[0]
00025     rest = all_info[1:]
00026     descr = " ".join(rest)
00027 
00028     # now extract the ids from the id block
00029     # gi|5690369|gb|AF158246.1|AF158246
00030     id_info_items = id_info.split("|")
00031     if len(id_info_items) >=4:
00032         assert id_info_items[2] in ["gb", "emb", "dbj", "pdb"], title
00033         id = id_info_items[3] # the id with version info
00034         name = id_info_items[4] # the id without version info
00035     else:
00036         #Fallback:
00037         id = id_info_items[0]
00038         name = id_info_items[0]
00039 
00040     return id, name, descr

Here is the caller graph for this function:


Variable Documentation

list test_SeqIO_FastaIO.multi_amino_files = ['Fasta/f002', 'Fasta/fa01']

Definition at line 124 of file test_SeqIO_FastaIO.py.

list test_SeqIO_FastaIO.multi_dna_files = ['Quality/example.fasta']

Definition at line 119 of file test_SeqIO_FastaIO.py.

tuple test_SeqIO_FastaIO.name = filename.split(".")

Definition at line 127 of file test_SeqIO_FastaIO.py.

tuple test_SeqIO_FastaIO.runner = unittest.TextTestRunner(verbosity = 2)

Definition at line 163 of file test_SeqIO_FastaIO.py.

Initial value:
00001 ['Fasta/aster.pro', 'Fasta/rosemary.pro',
00002                       'Fasta/rose.pro', 'Fasta/loveliesbleeding.pro']

Definition at line 121 of file test_SeqIO_FastaIO.py.

Initial value:
00001 ['Fasta/lupine.nu', 'Fasta/elderberry.nu',
00002                         'Fasta/phlox.nu', 'Fasta/centaurea.nu',
00003                         'Fasta/wisteria.nu', 'Fasta/sweetpea.nu',
00004                         'Fasta/lavender.nu', 'Fasta/f001']

Definition at line 114 of file test_SeqIO_FastaIO.py.