Exemple #1
0
    def instantiate_test(self, alignment, record):
        """
        Create a test instance, populate the attributes, and append it to the test list
        :param alignment:
        :param record
        """
        test = Test()

        pdb_id = ParseAlignment.get_alignment_pdb_id(alignment)
        chain_id = ParseAlignment.get_alignment_pdb_chain(alignment)

        # set the pdb_id
        test.set_pdb_id(pdb_id)

        # determine coverage & identity
        coverage, identity = ParseAlignment.coverage_and_identity(alignment, record)

        # set the test sequence
        test.set_sequence(pdb_id, chain_id)

        # set the coverage & identity values
        test.set_coverage(coverage)
        test.set_identity(identity)

        # get the experimental method
        test.set_expt_method()

        # parse the pdb and pull out the resolution
        test.set_resolution()

        # parse the pdb and pull ligand information
        test.set_ligands()

        self.test_list.append(test)
Exemple #2
0
    def run_blast(self, pdb_db):
        """
        Run BLASTP
        :return:
        """
        # this will only work for the simplest monomer case....add functionality for oligomer
        for key in self.sequences.keys():
            # write a fasta file
            fasta_file = key + '.fasta' # want this to be pdb_id.chain_id.fasta add error checking
            SeqIO.write(self.sequences[key], fasta_file, "fasta")
            #FastaIO.write_fasta(fasta_file, self.sequences[key])

            # run blastp
            cline = NcbiblastpCommandline(cmd='blastp', query=fasta_file, db=pdb_db, evalue=0.001, outfmt=5)
            std_out, std_err = cline()

            # parse the output
            blast_records = NCBIXML.parse(StringIO(std_out))
            record = next(blast_records)

            # iterate over the test alignments
            # 1) verify the D3R criteria are satisfied
            # 2) create a test object & add it to the test_list
            for alignment in record.alignments:
                # check D3R criteria for each test alignment
                if not ParseAlignment.filter_blast_result(alignment, record):
                    continue
                else:
                    # extract pdb_id and a list of pdb_ids already assigned
                    pdb_id = ParseAlignment.get_alignment_pdb_id(alignment)

                    if not self.test_list:
                        self.instantiate_test(alignment,record)
                    else:
                        assigned = [x.get_pdb_id() for x in self.test_list]
                        # if the test object exists then append the sequence
                        if pdb_id in assigned:
                            chain_id = ParseAlignment.get_alignment_pdb_chain(alignment)
                            index = assigned.index(pdb_id)
                            self.test_list[index].set_sequence(pdb_id, chain_id)
                        # if it doesn't exist, instantiate the object and add it to the list
                        else:
                            self.instantiate_test(alignment,record)
            os.remove(fasta_file)