Thanks. I tried to use 'for' instead of 'while' as both of you suggested. It's running well as my previous version but breaks completely instead of just skipping the empty file. I suspect the reason is that this part is inside another 'for' so it stops everything. I just want to it to break only one 'for', that is go back to 5th line in the example code (directory C has one empty file):

receptors = ['A', 'B', 'C']
for x in receptors:
  print x
  for i in range(3):
      for r in (7, 9, 11, 13, 15, 17):
f = open('c:/Linux/Dock_method_validation/%s/validation/ligand_ran_line_%s_%sA_secondary_scored.mol2' %(x,i,r), 'r')
          line = f.readline()[:-1]
out_file = open('c:/Linux/Dock_method_validation/%s/validation/pockets.out' %(x),'a')
          out_file.write('%s ' %i)
          out_file.write('%s ' %r)
          # skip to scores
          j=0
          for line in f:
              line = line.rstrip()
              if "PRIMARY" not in line:
                  j += 1
                  if j == 20:
                      break
              else:
                  for line in f:
                      if "TRIPOS" not in line:
                          line = line.rstrip()
                          out_file.write(line)
                      else:
                          break
          f.close()
          out_file.close()

Any suggestions as for how to control the "extent of break"? should I do something else instead? Thank you!
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to