Ejemplo n.º 1
0
    def __init__(self, inFile):
#         print inFile 
        self.isSeql = False
        self.charEncoding = 'not known'
        
        try:
            with open(inFile, 'r') as f:
                self.charEncoding = chardet.detect(f.read())['encoding']
            
            self.seqlGenerator = su.generateChunks(inFile, pa)
            generalInformationString = self.seqlGenerator.next()['chunk']
            generalInformationUnicode = generalInformationString.decode(self.charEncoding)
#             self.generalInformation = GeneralInformation(generalInformationString)
            self.generalInformation = GeneralInformation(generalInformationUnicode)

            if self.generalInformation.genInfoPatternFound:
                self.isSeql = True

            # print 'SequenceListing initialised for file', inFile
        except IOError:
            # self.logger.exception("Invalid input file: %s" % self.in_file_name)
            print 'Invalid file name', inFile
            
        self.quantity_nuc = 0
        self.quantity_prt = 0
        self.quantity_mix = 0
Ejemplo n.º 2
0
    def __init__(self, inFile):
#         print inFile 
        self.isSeql = False
        try:
            self.seqlGenerator = su.generateChunks(inFile, pa)
            generalInformationString = self.seqlGenerator.next()['chunk']
            self.generalInformation = GeneralInformation(generalInformationString)

            if self.generalInformation.genInfoPatternFound:
                self.isSeql = True

            # print 'SequenceListing initialised for file', inFile
        except IOError:
            # self.logger.exception("Invalid input file: %s" % self.in_file_name)
            print 'Invalid file name', inFile
Ejemplo n.º 3
0
    def getSequenceFromFile(cls, aFile, aSeqIdNo):
        '''
        Return the Sequence instance corresponding to aSeqIdNo in aFile.
        The assumption is that seqIdNo = actualSeqIdNo.

        :param aFile: a sequence listing file
        :param aSeqIdNo: int representing the seq id no
        :return: Sequence
        '''
        # TODO: test it
        listOfChunks = []
        for c in su.generateChunks(aFile, pa):
            listOfChunks.append(c)


        inputString = listOfChunks[aSeqIdNo]['chunk']

        seq = Sequence(inputString)
        seq.actualSeqIdNo = aSeqIdNo#TODO: to see if this is OK

        return seq
Ejemplo n.º 4
0
    def getSequenceFromFile(cls, aFile, aSeqIdNo):
        '''
        Return the Sequence instance corresponding to aSeqIdNo in aFile.
        The assumption is that seqIdNo = actualSeqIdNo.

        :param aFile: a sequence listing file
        :param aSeqIdNo: int representing the seq id no
        :return: Sequence
        '''
        # TODO: test it, unicode it!
        listOfChunks = []
        for c in su.generateChunks(aFile, pa):
            listOfChunks.append(c)


        inputString = listOfChunks[aSeqIdNo]['chunk']

        seq = Sequence(inputString)
        seq.actualSeqIdNo = aSeqIdNo#TODO: to see if this is OK

        return seq