ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/osprai/osprai/trunk/converter.py
(Generate patch)
# Line 40 | Line 40
40      # examine the first line of the input file
41      # for SPRit output:"Elapsed Time (Seconds)  Average Intensity (Pixel Intensity)"
42      # for Plexera ICM output:
43 <    head_input1="Elapsed Time (Seconds)\tAverage Intensity (Pixel Intensity)\n"
43 >    head_input1="Elapsed Time (Seconds)\tAverage Intensity (Pixel Intensity)"
44      
45      Format_input = 0
46      # check file format  
47      Tmpstr = fp.readline()
48 <    if Tmpstr==head_input1:
48 >    if (head_input1 in Tmpstr):
49          Format_input=1      
50      elif Tmpstr[-1]=='\n' and Tmpstr[-2]=='\r' and Tmpstr.split(' ')[0].split('/')[2].startswith('20'):
51          Format_input=2
# Line 71 | Line 71
71      Tmpstr = fp.readline()
72      # check if the second line is BEGIN
73      TmpStr = fp.readline()
74 <    if TmpStr != "BEGIN\n":
75 <        print "Second line is not Begin. Break!"
76 <        #sys.exit(0)
74 >    if ("BEGIN" not in TmpStr):
75 >        print "Warning: Second line of data file is not 'BEGIN'"
76 >        ##sys.exit(0)
77      # count the lines of each data spot
78      TmpStr = fp.readline() # skip first "0.000000e+000"        
79      num_line = 1 # so we start to count from 1
# Line 456 | Line 456
456          print i['Name'],'\t', i['Concentration']
457      
458      return sampleinfo
459 <    
459 >
460 > def method_read_fake():
461 >    sampleinfo = []
462 >    sampleinfo.append({'Location':0, 'Name':0, 'Concentration':0, 'Duration':0, 'Flow Rate':0, 'Analyte Series':0, 'Buffer Blank Series':0})
463 >    return sampleinfo
464  
465  
466   def datafile_read(fname):
# Line 509 | Line 513
513          fprotocol = raw_input('Input the path of the analyte table: ')
514          sampleinfo = method_read(fprotocol)
515          dataobj.updateSampleinfo(sampleinfo)
516 <            
516 >    else:
517 >        dataobj.updateSampleinfo(method_read_fake())
518 >
519      return dataobj
520      
521  
# Line 751 | Line 757
757          os.chdir('..')        
758          try:
759              os.makedirs(DataDir)
760 <        except WindowsError:
760 >        ##except WindowsError:
761 >        except OSError:
762              pass
763          os.chdir(DataDir)
764      
# Line 826 | Line 833
833      dataobj = copy.deepcopy(obj)
834      data = dataobj.data
835      n_inj = len(dataobj.sampleinfo)
836 +    n_inj = max(n_inj, 1)  # Must have at least one injection.
837      ROIinfo = dataobj.ROIinfo
838      ROInum = dataobj.ROInum
839      sampleinfo = dataobj.sampleinfo
840      
841      data_out = np.zeros((2*n_inj,np.shape(data)[1]))
842 <    if ROI_out != ROIinfo[ROI_out-1]['IDcal']:
842 > ##  if ROI_out != ROIinfo[ROI_out-1]['IDcal']:
843 >    if (ROI_out != int(ROIinfo[ROI_out-1]['ID'])):
844          print 'Please check the ROI information.'
845          print ROI_out, ROIinfo[ROI_out-1]
846          return

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines