Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 12th, 2012  |  syntax: None  |  size: 1.35 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/bin/env python3
  2.  
  3. import os
  4. import re
  5. import sys
  6.  
  7. if len(sys.argv)<2:
  8.         print('This script extracts insert size information from Cufflinks logs.',file=sys.stderr);
  9.         print('Usage: getinsertsize [cufflinks log file]',file=sys.stderr);
  10.         print('Note: you may specify different log files using filename wildcards.',file=sys.stderr);
  11.         sys.exit();
  12.  
  13.  
  14. flist=sys.argv[1:];
  15.  
  16.  
  17. print('File\tMapMass\tReadLength\tMean\tStd');
  18.  
  19. for fof in sorted(flist):
  20.         jobid=re.findall('e(\d+)',fof)[0];
  21.         ispassed=False;
  22.         nline=0;
  23.         mpms='';
  24.         rtype='';
  25.         dmean='';
  26.         dstd='';
  27.         for lines in open(fof):
  28.                 if lines.startswith('>  '):
  29.                         r1=re.findall('Total Map Mass: ([\d\.]+)',lines);
  30.                         r2=re.findall('Read Type: ([\d]+)bp',lines);
  31.                         r3=re.findall('Estimated Mean: ([\d\.]+)',lines);
  32.                         r4=re.findall('Estimated Std Dev: ([\d\.]+)',lines);
  33.                         if len(r1)>0: mpms=r1[0];
  34.                         if len(r2)>0: rtype=r2[0];
  35.                         if len(r3)>0: dmean=r3[0];
  36.                         if len(r4)>0: dstd=r4[0];
  37.                         ispassed=True;
  38.                 else:
  39.                         if ispassed: break;
  40.         print(fof+'\t'+str(mpms)+'\t'+str(rtype)+'\t'+str(dmean)+'\t'+str(dstd));