Exemplo n.º 1
0
    def test_residues_dependency(self, aToken):
        with open(os.path.join(self.statDir, '%sstat.csv' % aToken), 'w') as wr:
            wr.write('%s\n' %('file,%scount,%schars,size_st25,size_st26,r26vs25' %(aToken, aToken)))
            
            files = [f for f in os.listdir(self.inDir) if '.DS' not in f and f.startswith(aToken)]
            di = {}
            for f in files:
                c = St25To26Converter(os.path.join(self.inDir, f))
                xmlPath_large = c.generateXmlFile(self.outDir)
                xmlPath = cu.cleanAndWriteXmlFile(xmlPath_large)
                di[f] = xmlPath
            
            for f in sorted(di.keys()):
                fp = os.path.join(self.inDir, f)
                    
                currentSize_st25 = os.path.getsize(fp)
                currentSize_st26 = os.path.getsize(di[f])
                
                with open(fp, 'r') as f:
                    s = f.read()
                    l = s.split('<400>  1')
                    
                    item211 = re.search('<211>\s+(\d+)', s)
                    s1Length = int(item211.group(1))
                    
#                     print l[1]
                 
                wr.write('%s,%i,%i,%i,%i,%s\n' %(os.path.basename(fp), 
                                           s1Length,
                                        len(l[1]),
                                           currentSize_st25,
                                           currentSize_st26,
                                           '%0.1f' % (float(currentSize_st26)/currentSize_st25), 
                                           ))
Exemplo n.º 2
0
    def test_dependency(self, aToken, aTag):
        with open(os.path.join(self.statDir, '%sstat.csv' % aToken), 'w') as wr:
            wr.write('%s\n' %('file,%scount,size_st25,size_st26,r26vs25,incr_st25,incr_st26' % aToken))
            
            files = [f for f in os.listdir(self.inDir) if '.DS' not in f and f.startswith(aToken)]
            di = {}
            for f in files:
                c = St25To26Converter(os.path.join(self.inDir, f))
                xmlPath_large = c.generateXmlFile(self.outDir)
                xmlPath = cu.cleanAndWriteXmlFile(xmlPath_large)
                di[f] = xmlPath
            
            initialFile = files[0]
            
            prev_size_st25 = os.path.getsize(os.path.join(self.inDir, initialFile))
            prev_size_st26 = os.path.getsize(di[initialFile])
            
#             for f in sorted(di.keys(), key=lambda x: os.path.getsize(os.path.join(self.inDir, f))):
            if aToken == 'f_':
                currentList = self.featureTestFiles 
            elif aToken == 's_':
                currentList = self.sequenceTestFiles
            for fp in currentList:
#                 fp = os.path.join(self.inDir, f)
                with open(fp, 'r') as fr:
                    s = fr.read()
                    feature_count = s.count(aTag)
                
                currentSize_st25 = os.path.getsize(fp)
                bn = os.path.basename(fp)
                currentSize_st26 = os.path.getsize(di[bn])
                 
                wr.write('%s,%i,%i,%i,%s,%i,%i\n' %(bn, 
                                            feature_count, 
                                           currentSize_st25,
                                           currentSize_st26, 
                                           '%0.1f' % (float(currentSize_st26)/currentSize_st25),
                                           currentSize_st25 - prev_size_st25, 
                                           currentSize_st26 - prev_size_st26))
                 
                prev_size_st25 = currentSize_st25
                prev_size_st26 = currentSize_st26