Пример #1
0
    def run(self):
        """
		"""
        if self.debug:
            import pdb
            pdb.set_trace()

        if not os.path.isfile(self.inputFname):
            sys.stderr.write("Error: file, %s,  is not a file.\n" %
                             (self.inputFname))
            sys.exit(3)

        inputFile = utils.openGzipFile(self.inputFname, 'r')
        outputPolymorphismFile = PolymorphismTableFile(self.outputFname, openMode='w', isPhased=1, \
                    ploidy=self.ploidy)
        outputChromosomeSequenceFile = open(self.outputChromosomeSequenceFname,
                                            "w")

        commandline = inputFile.next().strip()
        outputPolymorphismFile.addAttribute('commandline',
                                            value=commandline,
                                            overwrite=True,
                                            tableName='polymorphism')

        for line in inputFile:
            if self.iterationPattern.search(
                    line):  #one iteration is regarded as one species
                self.outputOneIteration(inputFile=inputFile, iterationLine=line, outputPolymorphismFile=outputPolymorphismFile,\
                     outputChromosomeSequenceFile=outputChromosomeSequenceFile, ploidy=self.ploidy)

        inputFile.close()
        outputPolymorphismFile.close()
        outputChromosomeSequenceFile.close()
    def run(self):
        """
		input looks like (inputFileFormat=1)
				msHOT-lite 2 1 -t 4781.50413187402 -r 790.4466018 ...
				//
				segsites: 40567
				
				positions: 0.0002 0.0003
				001001101011011001...
				101001010100101111...
				...
			
			./msHOT-lite 2 1 -t 84989.8346003745 -r 34490.1412746802 30000000 -l -en 0.0013 1 0.0670 -en 0.0022 1 0.3866 -en 0.0032 1 0.3446 -en 0.0044 1 0.21
				79 -en 0.0059 1 0.1513 -en 0.0076 1 0.1144 -en 0.0096 1 0.0910 -en 0.0121 1 0.0757 -en 0.0150 1 0.0662 -en 0.0184 1 0.0609 -en 0.0226 1 0.0583 -en
				 0.0275 1 0.0572 -en 0.0333 1 0.0571 -en 0.0402 1 0.0577 -en 0.0485 1 0.0589 -en 0.0583 1 0.0603 -en 0.0700 1 0.0615 -en 0.0839 1 0.0624 -en 0.100
				5 1 0.0632 -en 0.1202 1 0.0641 -en 0.1437 1 0.0651 -en 0.1716 1 0.0663 -en 0.2048 1 0.0678 -en 0.2444 1 0.0696 -en 0.2914 1 0.0719 -en 0.3475 1 0.
				0752 -en 0.4935 1 0.0794 
				//
				@begin 6422
				
				30000000
				1100    01
				6074    10
				
				29966899        10
				29971027        01
				29973740        01
				29982767        01
				29985696        10
				@end
		"""
        if self.debug:
            import pdb
            pdb.set_trace()

        if not os.path.isfile(self.inputFname):
            sys.stderr.write("Error: file, %s,  is not a file.\n" %
                             (self.inputFname))
            sys.exit(3)

        inputFile = utils.openGzipFile(self.inputFname, 'r')
        outputPolymorphismFile = PolymorphismTableFile(self.outputFname, openMode='w', isPhased=1, \
                    ploidy=self.ploidy)

        commandline = inputFile.next().strip()
        outputPolymorphismFile.addAttribute('commandline',
                                            value=commandline,
                                            overwrite=True,
                                            tableName='polymorphism')

        self._convert(inputFile=inputFile,
                      outputPolymorphismFile=outputPolymorphismFile,
                      ploidy=self.ploidy)

        inputFile.close()
        outputPolymorphismFile.close()