Protein factory method.

        Iterates through a list of SearchIO hit objects, matches
        the accession against SeqRecord features for each organism.
        If there is a match, the new Protein object is created and
        stored in the protein list of that Organism.

        Args
            orgprot_list: a list Biopython SearchIO hit objects (I think).

def add_protein_to_organisms(self, orgprot_list):

        '''
        Protein factory method.

        Iterates through a list of SearchIO hit objects, matches
        the accession against SeqRecord features for each organism.
        If there is a match, the new Protein object is created and
        stored in the protein list of that Organism.

        Args
            orgprot_list: a list Biopython SearchIO hit objects (I think).

        '''

        for org in self.organisms:

            handle = open(org.genome_path, "rU")
            print 'adding proteins to organism', org.accession
            try:
                seq_record = SeqIO.read(handle, "genbank")

                feature_list = []

                for id in orgprot_list:
                    org_id = id.split(',')[0]
                    prot_id = id.split(',')[1]

                    if org.accession == org_id:
                        for feature in seq_record.features:
                            if feature.type == 'CDS':
                                feat_prot_acc = feature.qualifiers['protein_id'][0]
                                if feat_prot_acc == prot_id:
                                    #print 'appending', hit_prot_acc
                                    org.proteins.append(Protein(feature))

                del(seq_record)

            except ValueError,e:
                print 'error for ', org.accession, str(e)

            except AssertionError,e:
                print 'error for ', org.accession, str(e)

            except UnboundLocalError,e:
                print 'error for ', org.accession, str(e)

            except KeyError,e:
                print 'error for ', org.accession, str(e)

            handle.close()