Created
January 29, 2018 14:41
-
-
Save philippbayer/b96dacf30c70700b496b40f38b6c1e86 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import subprocess | |
| run_command = 'find . -maxdepth 2 -name evm.out' | |
| process = subprocess.Popen(run_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) | |
| for c in iter(lambda: process.stdout.readline(), ''): | |
| out = open(c.rstrip().replace('.out','_nonRNARemoved.out'), 'w') | |
| this_gene = [] | |
| for line in open(c.rstrip()): | |
| if line.startswith('!!'): | |
| out.write(line) | |
| continue | |
| if line.startswith('#'): | |
| if this_gene: | |
| # check whether this_gene has RNASeq in it | |
| keep = False | |
| for l in this_gene: | |
| if 'Cufflinks' in l: | |
| keep = True | |
| break | |
| if not keep: continue | |
| for l in this_gene: | |
| out.write(l) | |
| this_gene = [line] | |
| else: | |
| this_gene.append(line) | |
| # the last gene still has to be printed | |
| if this_gene: | |
| keep = False | |
| for l in this_gene: | |
| if 'Cufflinks' in l: | |
| keep = True | |
| break | |
| if not keep: continue | |
| for l in this_gene: | |
| out.write(l) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment