Beispiel #1
0
    def alignment_similarity(self, seq1, seq2, homopolymer_correction) :
        # write out
        f = open(System.tempfilename(ext='cluster'), 'w')

        print >> f, seq1.fasta()
        print >> f, seq2.fasta()

        f.close()

        # align
        aligned = []
        if homopolymer_correction :
            fq = Pagan().get_454_alignment(f.name)
        else :
            fq = Pagan().get_alignment(f.name)
        
        fq.open()

        for seq in fq :
            if seq.id == ">consensus" :
                continue

            aligned.append(seq.sequence)

        fq.close()

        # delete tmp files
        os.remove(f.name)
        os.remove(fq.get_filename())

        # if things are really dissimilar they do not align
        # so just give up here for this cluster
        if len(aligned) != 2 :
            return 0.0

        return self.distance2(aligned, homopolymer_correction)