Esempio n. 1
0
    def muscle(self):
        """Do an alignment with muscle.

        Its all done in memory -- no files are written.

        An alignment object is returned.

        The order of the sequences in the new alignment is made to be
        the same as the order in self.

        """
        flob = cStringIO.StringIO()
        self.writeFasta(fName=flob)
        p = Popen(["muscle"], stdin=PIPE, stdout=PIPE, stderr=PIPE)
        ret = p.communicate(input=flob.getvalue())
        flob.close()
        try:
            a = func.readAndPop(ret[0])
        except P4Error:
            print ret
            raise P4Error("Something didn't work ...")

        a.makeSequenceForNameDict()
        newSequenceList = []
        for sSelf in self.sequences:
            newSequenceList.append(a.sequenceForNameDict[sSelf.name])
        a.sequences = newSequenceList
        return a
Esempio n. 2
0
    def clustalo(self):
        """Do an alignment with clustalo.

        Its all done in memory -- no files are written.

        An alignment object is returned.

        The order of the sequences in the new alignment is made to be
        the same as the order in self.

        """
        flob = cStringIO.StringIO()
        self.writeFasta(fName=flob)
        p = Popen(["clustalo", "-i", "-"], stdin=PIPE, stdout=PIPE, stderr=PIPE)
        ret = p.communicate(input=flob.getvalue())
        # ret = p.communicate()
        if ret[1]:
            print ret
            raise P4Error("clustalo()  Something wrong here ...")
        flob.close()
        a = func.readAndPop(ret[0])
        a.makeSequenceForNameDict()
        newSequenceList = []
        for sSelf in self.sequences:
            newSequenceList.append(a.sequenceForNameDict[sSelf.name])
        a.sequences = newSequenceList
        return a
Esempio n. 3
0
    def clustalo(self):
        """Do an alignment with clustalo.

        Its all done in memory -- no files are written.

        An alignment object is returned.

        The order of the sequences in the new alignment is made to be
        the same as the order in self.

        """
        flob = cStringIO.StringIO()
        self.writeFasta(fName=flob)
        p = Popen(["clustalo", "-i", "-"],
                  stdin=PIPE,
                  stdout=PIPE,
                  stderr=PIPE)
        ret = p.communicate(input=flob.getvalue())
        #ret = p.communicate()
        #print ret
        flob.close()
        a = func.readAndPop(ret[0])
        a.makeSequenceForNameDict()
        newSequenceList = []
        for sSelf in self.sequences:
            newSequenceList.append(a.sequenceForNameDict[sSelf.name])
        a.sequences = newSequenceList
        return a