1794
Comment:
|
13779
|
Deletions are marked like this. | Additions are marked like this. |
Line 1: | Line 1: |
== IronPython == IronPython is [http://hugunin.net/index.html JimHugunin's] implementation of Python on the .NET CLR. The project has a [http://www.gotdotnet.com/workspaces/workspace.aspx?id=ad7acff7-ab1e-4bcb-99c0-57ac5a3a9742 workspace] where you can get news and download the latest version. An older site, http://ironpython.com/ appears to be unmaintained. (He didn't have enough time to do it properly without funding -- so Microsoft hired him. As of January 2006, Microsoft has released a Beta version, and the expectation is betas roughly every three weeks, and a final within 10 betas.) Early results are promising, showing great performance, even better than CPython 2.3 on the Pystone benchmark, but remember this is an early prototype, not a full implementation. These results caused a flurry of discussion, which has since died down, pending more information from Jim. * http://www.python.org/~jeremy/weblog/031209a.html * http://www.hole.fi/jajvirta/weblog/20031210T0901.html * http://primates.ximian.com/~miguel/archive/2003/Dec-09.html == Other Python-Like Languages for .NET/Mono == Some other Python-like languages for .NET and Mono include: * BooLanguage - Syntax is very similar to Python's, yet the language is statically compiled. It implements many features that have been suggested for ["Python3.0"]. See [http://boo.codehaus.org/Gotchas+for+Python+Users Gotchas for Python Users] for specific comparisons between boo and CPython. * [http://www.prothon.org/ Prothon] - now defunct == Accessing .NET from CPython == [http://www.zope.org/Members/Brian/PythonNet/index_html Python for .NET] is the reverse of IronPython, it lets you access .NET assemblies from CPython. ---- See also: PythonAndParrot, LoGix, IronPython IDE |
# Reads: SLAllSort.csv # # Writes to: # DBTestM.csv # CalcList.csv # MultList.txt # MultSummary.txt import os,sys from Tkinter import * from string import * from Permute import * class FileCombo(Frame): def __init__(self,parent=None): Frame.__init__(self,parent) print 'Choices are:' print ' 1. Convert Sorted Combined list to Species No. and Subspecies No' print ' creates DBTestM.csv ' print ' 2. Make two lists: All species detected - Species and All sites detected - Sites.' print ' Then Adds data from CDMS (Intensity,Smu2 and Einstein A) from DBTestM.csv' print ' creates CalcList.csv ' print ' 3. Reads CalcList.csv and identifies all lines in a site that have 3 or more lines' print ' creates MultList.txt and a Summary MultSummary.txt. ' print ' 4. Run each in sequence' ## Sel=raw_input('Choice') Ch=eval(Sel) if Ch==1: self.XDBAccess() exit() if Ch==2: self.MakeSiteList() self.CalculationList() quit() if Ch==3: self.FindMultiples() quit() if Ch==4: self.XDBAccess() self.MakeSiteList() self.CalculationList() self.FindMultiples() quit() def XDBAccess(self): # GoodCombineAllSorted is a combination of the three SLCombine files cleaned for errors. Sorted by: Species, RestF site. # Two columns are added at the beginning of each line of the form shown below. # The result is saved in Lines F1='/home/ghurtig3/Desktop/NewASAP_09/DATA/GoodCombineAllSorted.csv' FL1=open(F1,'r') sa=FL1.readlines() Lines2=[] la=len(sa) print len(sa) #Strip whitespaces i=0 while i < la: sb=sa[i].strip() Lines2.append(sb) i=i+1 continue Lines=[] #print len(Lines2) # Create a csv file Starting with [ 1, 0, Site, .....] i=0 for line in Lines2: line=line.split("\t") #line1=line[0][0:-1] #print line #Lis1="1"+","+"0"+"," Lis1= "0" line.insert(0,Lis1) Lis1="1" line.insert(0,Lis1) #print line #raw_input("Pause1") #Lines1=Lis1.split(",") #Now creatine file Lines Lines.append(line) i=i+1 continue #Lines[x][0]=Specie # #Lines[x][1]=Sub Specie #Lines[x][2]=Site #Lines[x][3]=Specie #Lines[x][4]=Rest Freq #Lines[x][5]=Obs Freq #Lines[x][6]=DelF #Lines[x][7]=Intensity #Lines[x][8]=FWHM #Lines[x][9]=DelV #Lines[x][10]=Area #Lines[x][11]=Offset #Lines[x][12]=Normalize FL1.close() #print i #raw_input("Pause2") # A sub specie is added to the masterdatabase and written to 'DBTestM.csv' i=0 #Line # LL=len(Lines) #print Lines #print LL #print Lines[LL-2] k=0 #SubSpecie # m=0 #Specie # while i< LL-3: #Line # #print "i= ",i if Lines[i][3]==Lines[i+1][3]: #Tests for specie change: Lines[i+1][1]=0 Lines[i][0]=m Lines[i+1][0]=m if Lines[i][4]==Lines[i+1][4]:#Tests for sub specie change Lines[i][1]=k Lines[i+1][1]=k else: Lines[i][1]=k Lines[i+1][1]=k+1 k=k+1 i=i+1 continue else: Lines[i+1][0]=m+1 Lines[i][1]=k k=0 Lines[i+1][1]=k m=m+1 k=k+1 i=i+1 #Lines[i][1]=k #k=0 continue print i, k, m raw_input("Pause3") F6='/home/ghurtig3/Desktop/NewASAP_09/DATA/DBTestM.csv' FL6=open(F6,'w') j=0 while j< LL-3: FR=str(Lines[j][0])+','+str(Lines[j][1])+','+str(Lines[j][2])+','+str(Lines[j][3])+','+str(Lines[j][4])+','+str(Lines[j][5])+','+str(Lines[j][6])+','+str(Lines[j][7])+','+str(Lines[j][8])+','+str(Lines[j][9])+','+str(Lines[j][10])+','+str(Lines[j][11])+"\n" FL6.write(FR) #print FR #print j #print Lines[j] #raw_input('Pause') j=j+1 continue FL6.close() return def MakeSiteList(self): # This creates two internal lists from DBTestM.csv. Species is # all of the species detected and Sites is all of the sites read. F1='/home/ghurtig3/Desktop/NewASAP_09/DATA/DBTestM.csv' FL1=open(F1,'r') Lines=[] Sites=[] Species=[] i=0 for line in FL1: line=line.split(',') Lines.append(line) if line[2] in Sites: i=i+1 continue else: Sites.append(line[2]) i=i+1 continue FL1.close() F1='/home/ghurtig3/Desktop/NewASAP_09/DATA/DBTestM.csv' FL1=open(F1,'r') i=0 for line in FL1: line=line.split(',') Lines.append(line) if line[3] in Species: i=i+1 continue else: Species.append(line[3]) i=i+1 continue FL1.close() self.Sites=Sites self.Species=Species print Sites print Species return def CalculationList(self): #This def takes the observation data that has been cleaned and put #into DBTestM.csv and combines each specie and sub-specie with the #data from CDMS (Intensity, Smu2 and Einsteins A. Puts data into # CalcList.csv. T1=[] F3='/home/ghurtig3/Desktop/NewASAP_09/DATA/DBTestM.csv' FL3=open(F3,'r') F2='/home/ghurtig3/Desktop/NewASAP_09/DATA/CalcList.csv' FL2=open(F2,'w') Lines=[] for line in FL3: T1.append("0") line1=line.split(',') Lines.append(line1) LL=len(Lines) print LL Sites=self.Sites A="" B="" print type(Sites) for Si in Sites: H1='Site= '+Si for Sp in self.Species: Head=' Species= '+Sp+'\n' i=1 while i< LL-1: if (Lines[i][2]==Si) and (Lines[i][3]==Sp): if (Lines[i][2] == A) is False: print '***** ',Lines[i][2],' *****' print Lines[i][3] Freq=eval(Lines[i][4]) L=Lines[i] E=L.pop() E=E[:-2] L.append(E) B=Lines[i][3] if((Lines[i][3]==B))is False: print Lines[i][3] Freq=eval(Lines[i][4]) L=Lines[i] E=L.pop() E=E[:-2] L.append(E) DBLine=self.ReadCDMS(Freq) print Freq if DBLine==None: DBLine=['Not in CDBMS'] print DBLine T1[i]=L+DBLine Ln=Lines[i] A=Lines[i][2] B=Lines[i][3] Ln=str(Ln) FL2.write(str(T1[i])+'\n') i=i+1 continue else: i=i+1 continue FL3.close() FL2.close() #Lines[x][0]=Specie # #Lines[x][1]=Sub Specie #Lines[x][2]=Site #Lines[x][3]=Specie #Lines[x][4]=Rest Freq #Lines[x][5]=Obs Freq #Lines[x][6]=DelF #Lines[x][7]=Intensity #Lines[x][8]=FWHM #Lines[x][9]=DelV #Lines[x][10]=Area #Lines[x][11]=Offset #Lines[x][12]=Normalize #Lines[x][13]=Rest Freq #Lines[x][14]=log(intensity) #Lines[x][15]=log(Smu2) #Lines[x][16]=log(A) #Lines[x][17]=El #Lines[x][18]=gup #Lines[x][19]=Quant Nos #Lines[x][20]=Species #Lines[x][21]=Vt #Lines[x][22]=V def FindMultiples(self): #This def is created by DBA.py and reads CalcList.csv #and then identifies all species that have 3 or more #lines in a site.It writes these in MultList.txt and #summarizes the data in MultSummary.txt #Species is entered at tests are reported. SP=raw_input('Species? ') F1='/home/ghurtig3/Desktop/NewASAP_09/DATA/MultList.txt' FL1=open(F1,'w') F2='/home/ghurtig3/Desktop/NewASAP_09/DATA/CalcList.csv' FL2=open(F2,'r') F3='/home/ghurtig3/Desktop/NewASAP_09/DATA/MultSummary.txt' FL3=open(F3,'w') F4='/home/ghurtig3/Desktop/NewASAP_09/DATA/MultLines.txt' FL4=open(F4,'w') Lines=[] Lines=FL2.readlines() LL=len(Lines) print LL L2=Lines[0].split(',') #print L2[2] N1=[] L4=[] N3=[] i=1 k=1 while i<LL: L1=Lines[i].split(',') if L1[12]==" ''": #Checks for a ratio. i=i+1 continue if L1[3]==L2[3]: k=k+1 if k==3: N1=[] FL1.write(Lines[i-2]+'\n') FL1.write(Lines[i-1]+'\n') FL1.write(Lines[i]+'\n') LM2=Lines[i-2].split(',') LM1=Lines[i-1].split(',') LM0=Lines[i].split(',') N6=LM2[12] N7=N6[1:] N7=N7[:-2] if N7 != "'Not in CDBMS'": N6=N6[1:] N6=eval(N6) N1.append(N6) N6=LM1[12] N7=N6[1:] N7=N7[:-2] if N7 != "'Not in CDBMS'": N6=N6[1:] N6=eval(N6) N1.append(N6) N6=LM0[12] N7=N6[1:] N7=N7[:-2] if N7 != "'Not in CDBMS'": N6=N6[1:] N6=eval(N6) N1.append(N6) if k>3: FL1.write(Lines[i]+'\n') #LM=Lines[i].split(',') N6=L1[12] N7=N6[1:] N7=N7[:-2] if N7 != "'Not in CDBMS'": N6=N6[1:] N6=eval(N6) N1.append(N6) L2=L1 i=i+1 continue else: if k>2: FL3.write(L2[2]+','+L2[3]+','+str(k)+'\n') L3=L2[3][2:] L3=L3[:-1] if L3==SP: N2=L2[2] N2=N2.replace('.','') N2=N2.replace('gau','') L4.append(N2) #L4 is a list of sites containing SP N3.append(N1) #N3 is a list of intensities for each site. k=1 L2=L1 i=i+1 continue FL1.close() FL2.close() FL3.close() #Perm(L4,N3)#Calculates pair statistics exit() def ReadCDMS(self,Freq): Lines1=[] Lines1=self.ReadCDMSData() DBLine=self.FindLine(Freq, Lines1) return DBLine def ReadCDMSData(self): F1='CDMS_ISA.txt' FL1=open(F1, 'r') Lines1=[] i=0 for line in FL1: line=capwords((line)) line=line.split(',') if line[0]=="": continue else: Lines1.append(line) i=i+1 continue return Lines1 def FindLine(self,Fr1,Lines1): #finds a line in the CDMS for a particular frequency. i=1 while i < len(Lines1): if abs(eval(Lines1[i][0])-Fr1)<0.25: #print Lines[i] return Lines1[i] else: i=i+1 continue #raw_input('P') return if __name__ == '__main__': FileCombo().mainloop() |
# # Writes to: # DBTestM.csv # CalcList.csv # MultList.txt # MultSummary.txt
import os,sys from Tkinter import * from string import * from Permute import *
class FileCombo(Frame):
def init(self,parent=None):
Frame.init(self,parent) print 'Choices are:' print ' 1. Convert Sorted Combined list to Species No. and Subspecies No' print ' creates DBTestM.csv ' print ' 2. Make two lists: All species detected - Species and All sites detected - Sites.' print ' Then Adds data from CDMS (Intensity,Smu2 and Einstein A) from DBTestM.csv' print ' creates CalcList.csv ' print ' 3. Reads CalcList.csv and identifies all lines in a site that have 3 or more lines' print ' creates MultList.txt and a Summary MultSummary.txt. ' print ' 4. Run each in sequence'
- Sel=raw_input('Choice') Ch=eval(Sel) if Ch==1:
- self.XDBAccess() exit()
self.MakeSiteList() self.CalculationList() quit()
self.FindMultiples() quit()
- self.XDBAccess()
self.MakeSiteList() self.CalculationList() self.FindMultiples() quit()
- def XDBAccess(self):
# GoodCombineAllSorted is a combination of the three SLCombine files cleaned for errors. Sorted by: Species, RestF site. # Two columns are added at the beginning of each line of the form shown below. # The result is saved in Lines F1='/home/ghurtig3/Desktop/NewASAP_09/DATA/GoodCombineAllSorted.csv' FL1=open(F1,'r') sa=FL1.readlines() Lines2=[] la=len(sa) print len(sa) #Strip whitespaces i=0 while i < la:
- sb=sa[i].strip() Lines2.append(sb) i=i+1 continue
- line=line.split("\t") #line1=line[0][0:-1] #print line #Lis1="1"+","+"0"+"," Lis1= "0" line.insert(0,Lis1) Lis1="1" line.insert(0,Lis1) #print line #raw_input("Pause1") #Lines1=Lis1.split(",") #Now creatine file Lines Lines.append(line) i=i+1 continue #Lines[x][0]=Specie # #Lines[x][1]=Sub Specie #Lines[x][2]=Site #Lines[x][3]=Specie #Lines[x][4]=Rest Freq #Lines[x][5]=Obs Freq #Lines[x][6]=DelF #Lines[x][7]=Intensity #Lines[x][8]=FWHM #Lines[x][9]=DelV #Lines[x][10]=Area #Lines[x][11]=Offset #Lines[x][12]=Normalize
k=0 #SubSpecie # m=0 #Specie # while i< LL-3: #Line #
- #print "i= ",i if Lines[i][3]==Lines[i+1][3]: #Tests for specie change:
- Lines[i+1][1]=0 Lines[i][0]=m Lines[i+1][0]=m if Lines[i][4]==Lines[i+1][4]:#Tests for sub specie change
- Lines[i][1]=k Lines[i+1][1]=k
- Lines[i][1]=k Lines[i+1][1]=k+1 k=k+1
- Lines[i+1][0]=m+1 Lines[i][1]=k k=0 Lines[i+1][1]=k m=m+1 k=k+1 i=i+1
- Lines[i+1][1]=0 Lines[i][0]=m Lines[i+1][0]=m if Lines[i][4]==Lines[i+1][4]:#Tests for sub specie change
while j< LL-3:
- FR=str(Lines[j][0])+','+str(Lines[j][1])+','+str(Lines[j][2])+','+str(Lines[j][3])+','+str(Lines[j][4])+','+str(Lines[j][5])+','+str(Lines[j][6])+','+str(Lines[j][7])+','+str(Lines[j][8])+','+str(Lines[j][9])+','+str(Lines[j][10])+','+str(Lines[j][11])+"\n" FL6.write(FR) #print FR #print j #print Lines[j] #raw_input('Pause') j=j+1 continue
def MakeSiteList(self):
# This creates two internal lists from DBTestM.csv. Species is # all of the species detected and Sites is all of the sites read.
- F1='/home/ghurtig3/Desktop/NewASAP_09/DATA/DBTestM.csv' FL1=open(F1,'r') Lines=[] Sites=[] Species=[] i=0 for line in FL1:
- line=line.split(',') Lines.append(line) if line[2] in Sites:
- i=i+1 continue
- Sites.append(line[2]) i=i+1
- line=line.split(',') Lines.append(line) if line[3] in Species:
- i=i+1 continue
- Species.append(line[3]) i=i+1
- line=line.split(',') Lines.append(line) if line[2] in Sites:
def CalculationList(self):
#This def takes the observation data that has been cleaned and put #into DBTestM.csv and combines each specie and sub-specie with the #data from CDMS (Intensity, Smu2 and Einsteins A. Puts data into # CalcList.csv.
- T1=[] F3='/home/ghurtig3/Desktop/NewASAP_09/DATA/DBTestM.csv' FL3=open(F3,'r') F2='/home/ghurtig3/Desktop/NewASAP_09/DATA/CalcList.csv' FL2=open(F2,'w') Lines=[] for line in FL3:
- T1.append("0") line1=line.split(',') Lines.append(line1)
- H1='Site= '+Si for Sp in self.Species:
- Head=' Species= '+Sp+'\n' i=1
while i< LL-1:
- if (Lines[i][2]==Si) and (Lines[i][3]==Sp):
- if (Lines[i][2] == A) is False:
- print print print '***** ',Lines[i][2],' *****' print Lines[i][3] Freq=eval(Lines[i][4]) L=Lines[i] E=L.pop() E=E[:-2] L.append(E) B=Lines[i][3]
- print print Lines[i][3]
- DBLine=['Not in CDBMS'] print DBLine
- i=i+1 continue
- if (Lines[i][2] == A) is False:
- if (Lines[i][2]==Si) and (Lines[i][3]==Sp):
- Head=' Species= '+Sp+'\n' i=1
def FindMultiples(self):
#This def is created by DBA.py and reads CalcList.csv #and then identifies all species that have 3 or more #lines in a site.It writes these in MultList.txt and #summarizes the data in MultSummary.txt #Species is entered at tests are reported.
- SP=raw_input('Species? ') F1='/home/ghurtig3/Desktop/NewASAP_09/DATA/MultList.txt' FL1=open(F1,'w') F2='/home/ghurtig3/Desktop/NewASAP_09/DATA/CalcList.csv' FL2=open(F2,'r') F3='/home/ghurtig3/Desktop/NewASAP_09/DATA/MultSummary.txt' FL3=open(F3,'w') F4='/home/ghurtig3/Desktop/NewASAP_09/DATA/MultLines.txt' FL4=open(F4,'w') Lines=[] Lines=FL2.readlines() LL=len(Lines) print LL L2=Lines[0].split(',') #print L2[2] N1=[] L4=[] N3=[] i=1 k=1
while i<LL:
- L1=Lines[i].split(',')
if L1[12]==" ": #Checks for a ratio.
- i=i+1 continue
- k=k+1 if k==3:
- N1=[] FL1.write(Lines[i-2]+'\n') FL1.write(Lines[i-1]+'\n') FL1.write(Lines[i]+'\n') LM2=Lines[i-2].split(',') LM1=Lines[i-1].split(',') LM0=Lines[i].split(',') N6=LM2[12] N7=N6[1:] N7=N7[:-2] if N7 != "'Not in CDBMS'":
- N6=N6[1:] N6=eval(N6) N1.append(N6)
- N6=N6[1:] N6=eval(N6) N1.append(N6)
- N6=N6[1:] N6=eval(N6) N1.append(N6)
if k>3:
- FL1.write(Lines[i]+'\n') #LM=Lines[i].split(',') N6=L1[12] N7=N6[1:] N7=N7[:-2] if N7 != "'Not in CDBMS'":
- N6=N6[1:] N6=eval(N6) N1.append(N6)
- N1=[] FL1.write(Lines[i-2]+'\n') FL1.write(Lines[i-1]+'\n') FL1.write(Lines[i]+'\n') LM2=Lines[i-2].split(',') LM1=Lines[i-1].split(',') LM0=Lines[i].split(',') N6=LM2[12] N7=N6[1:] N7=N7[:-2] if N7 != "'Not in CDBMS'":
if k>2:
- FL3.write(L2[2]+','+L2[3]+','+str(k)+'\n') L3=L2[3][2:] L3=L3[:-1] if L3==SP:
- N2=L2[2]
N2=N2.replace('.',
- N2=L2[2]
- FL3.write(L2[2]+','+L2[3]+','+str(k)+'\n') L3=L2[3][2:] L3=L3[:-1] if L3==SP:
- L1=Lines[i].split(',')
- def ReadCDMS(self,Freq):
- Lines1=[] Lines1=self.ReadCDMSData()
DBLine=self.FindLine(Freq, Lines1) return DBLine
- F1='CDMS_ISA.txt' FL1=open(F1, 'r') Lines1=[] i=0 for line in FL1:
- line=capwords((line)) line=line.split(',') if line[0]=="":
- continue
- Lines1.append(line) i=i+1 continue
- line=capwords((line)) line=line.split(',') if line[0]=="":
def FindLine(self,Fr1,Lines1): #finds a line in the CDMS for a particular frequency.
- i=1
while i < len(Lines1):
if abs(eval(Lines1[i][0])-Fr1)<0.25:
- #print Lines[i] return Lines1[i]
- i=i+1 continue
- Lines1=[] Lines1=self.ReadCDMSData()
if name == 'main':
FileCombo().mainloop()