Mercurial > repos > tiagoantao > clone_filter
annotate STACKS_clone_filter.py @ 9:89b911668f1d draft
planemo upload commit 4d00a0b7a4b859b642eceb3c7cd4adb1453903a0-dirty
author | tiagoantao |
---|---|
date | Thu, 04 Feb 2016 08:14:48 -0500 |
parents | a8b87bc0c3ad |
children | 92ba49d68ef1 |
rev | line source |
---|---|
0
42e64fbf4609
planemo upload commit 60a090d1dc89c2eb383feeb35cd6078b9130e0e5-dirty
tiagoantao
parents:
diff
changeset
|
1 #!/usr/bin/python |
42e64fbf4609
planemo upload commit 60a090d1dc89c2eb383feeb35cd6078b9130e0e5-dirty
tiagoantao
parents:
diff
changeset
|
2 # -*- coding: utf-8 -*- |
42e64fbf4609
planemo upload commit 60a090d1dc89c2eb383feeb35cd6078b9130e0e5-dirty
tiagoantao
parents:
diff
changeset
|
3 |
5
1a5ebb16aaea
planemo upload commit 4d00a0b7a4b859b642eceb3c7cd4adb1453903a0-dirty
tiagoantao
parents:
0
diff
changeset
|
4 import argparse |
1a5ebb16aaea
planemo upload commit 4d00a0b7a4b859b642eceb3c7cd4adb1453903a0-dirty
tiagoantao
parents:
0
diff
changeset
|
5 import glob |
1a5ebb16aaea
planemo upload commit 4d00a0b7a4b859b642eceb3c7cd4adb1453903a0-dirty
tiagoantao
parents:
0
diff
changeset
|
6 import os |
0
42e64fbf4609
planemo upload commit 60a090d1dc89c2eb383feeb35cd6078b9130e0e5-dirty
tiagoantao
parents:
diff
changeset
|
7 import subprocess |
5
1a5ebb16aaea
planemo upload commit 4d00a0b7a4b859b642eceb3c7cd4adb1453903a0-dirty
tiagoantao
parents:
0
diff
changeset
|
8 import shutil |
0
42e64fbf4609
planemo upload commit 60a090d1dc89c2eb383feeb35cd6078b9130e0e5-dirty
tiagoantao
parents:
diff
changeset
|
9 |
42e64fbf4609
planemo upload commit 60a090d1dc89c2eb383feeb35cd6078b9130e0e5-dirty
tiagoantao
parents:
diff
changeset
|
10 |
42e64fbf4609
planemo upload commit 60a090d1dc89c2eb383feeb35cd6078b9130e0e5-dirty
tiagoantao
parents:
diff
changeset
|
11 def __main__(): |
42e64fbf4609
planemo upload commit 60a090d1dc89c2eb383feeb35cd6078b9130e0e5-dirty
tiagoantao
parents:
diff
changeset
|
12 parser = argparse.ArgumentParser() |
8
a8b87bc0c3ad
planemo upload commit 4d00a0b7a4b859b642eceb3c7cd4adb1453903a0-dirty
tiagoantao
parents:
5
diff
changeset
|
13 |
a8b87bc0c3ad
planemo upload commit 4d00a0b7a4b859b642eceb3c7cd4adb1453903a0-dirty
tiagoantao
parents:
5
diff
changeset
|
14 #files (single or pair) |
0
42e64fbf4609
planemo upload commit 60a090d1dc89c2eb383feeb35cd6078b9130e0e5-dirty
tiagoantao
parents:
diff
changeset
|
15 parser.add_argument('-f', type=str) |
42e64fbf4609
planemo upload commit 60a090d1dc89c2eb383feeb35cd6078b9130e0e5-dirty
tiagoantao
parents:
diff
changeset
|
16 parser.add_argument('-fwd', type=str) |
42e64fbf4609
planemo upload commit 60a090d1dc89c2eb383feeb35cd6078b9130e0e5-dirty
tiagoantao
parents:
diff
changeset
|
17 parser.add_argument('-rev', type=str) |
42e64fbf4609
planemo upload commit 60a090d1dc89c2eb383feeb35cd6078b9130e0e5-dirty
tiagoantao
parents:
diff
changeset
|
18 |
8
a8b87bc0c3ad
planemo upload commit 4d00a0b7a4b859b642eceb3c7cd4adb1453903a0-dirty
tiagoantao
parents:
5
diff
changeset
|
19 #oligos |
a8b87bc0c3ad
planemo upload commit 4d00a0b7a4b859b642eceb3c7cd4adb1453903a0-dirty
tiagoantao
parents:
5
diff
changeset
|
20 parser.add_argument('-oligo_len_1', type=int) |
a8b87bc0c3ad
planemo upload commit 4d00a0b7a4b859b642eceb3c7cd4adb1453903a0-dirty
tiagoantao
parents:
5
diff
changeset
|
21 parser.add_argument('-oligo_len_2', type=int) |
a8b87bc0c3ad
planemo upload commit 4d00a0b7a4b859b642eceb3c7cd4adb1453903a0-dirty
tiagoantao
parents:
5
diff
changeset
|
22 |
a8b87bc0c3ad
planemo upload commit 4d00a0b7a4b859b642eceb3c7cd4adb1453903a0-dirty
tiagoantao
parents:
5
diff
changeset
|
23 #options (allways there) |
a8b87bc0c3ad
planemo upload commit 4d00a0b7a4b859b642eceb3c7cd4adb1453903a0-dirty
tiagoantao
parents:
5
diff
changeset
|
24 parser.add_argument('-opt', type=str) |
a8b87bc0c3ad
planemo upload commit 4d00a0b7a4b859b642eceb3c7cd4adb1453903a0-dirty
tiagoantao
parents:
5
diff
changeset
|
25 |
0
42e64fbf4609
planemo upload commit 60a090d1dc89c2eb383feeb35cd6078b9130e0e5-dirty
tiagoantao
parents:
diff
changeset
|
26 #parser.add_argument('-k', action='store_true') |
42e64fbf4609
planemo upload commit 60a090d1dc89c2eb383feeb35cd6078b9130e0e5-dirty
tiagoantao
parents:
diff
changeset
|
27 |
42e64fbf4609
planemo upload commit 60a090d1dc89c2eb383feeb35cd6078b9130e0e5-dirty
tiagoantao
parents:
diff
changeset
|
28 options = parser.parse_args() |
42e64fbf4609
planemo upload commit 60a090d1dc89c2eb383feeb35cd6078b9130e0e5-dirty
tiagoantao
parents:
diff
changeset
|
29 |
42e64fbf4609
planemo upload commit 60a090d1dc89c2eb383feeb35cd6078b9130e0e5-dirty
tiagoantao
parents:
diff
changeset
|
30 # create the working dir |
42e64fbf4609
planemo upload commit 60a090d1dc89c2eb383feeb35cd6078b9130e0e5-dirty
tiagoantao
parents:
diff
changeset
|
31 os.mkdir('job_outputs') |
42e64fbf4609
planemo upload commit 60a090d1dc89c2eb383feeb35cd6078b9130e0e5-dirty
tiagoantao
parents:
diff
changeset
|
32 os.chdir('job_outputs') |
42e64fbf4609
planemo upload commit 60a090d1dc89c2eb383feeb35cd6078b9130e0e5-dirty
tiagoantao
parents:
diff
changeset
|
33 |
42e64fbf4609
planemo upload commit 60a090d1dc89c2eb383feeb35cd6078b9130e0e5-dirty
tiagoantao
parents:
diff
changeset
|
34 # create the populations command input line |
42e64fbf4609
planemo upload commit 60a090d1dc89c2eb383feeb35cd6078b9130e0e5-dirty
tiagoantao
parents:
diff
changeset
|
35 cmd_line=['clone_filter'] |
42e64fbf4609
planemo upload commit 60a090d1dc89c2eb383feeb35cd6078b9130e0e5-dirty
tiagoantao
parents:
diff
changeset
|
36 if options.f is not None: |
42e64fbf4609
planemo upload commit 60a090d1dc89c2eb383feeb35cd6078b9130e0e5-dirty
tiagoantao
parents:
diff
changeset
|
37 cmd_line.extend(['-f', options.f]) |
42e64fbf4609
planemo upload commit 60a090d1dc89c2eb383feeb35cd6078b9130e0e5-dirty
tiagoantao
parents:
diff
changeset
|
38 else: |
42e64fbf4609
planemo upload commit 60a090d1dc89c2eb383feeb35cd6078b9130e0e5-dirty
tiagoantao
parents:
diff
changeset
|
39 cmd_line.extend(['-1', options.fwd]) |
42e64fbf4609
planemo upload commit 60a090d1dc89c2eb383feeb35cd6078b9130e0e5-dirty
tiagoantao
parents:
diff
changeset
|
40 cmd_line.extend(['-2', options.rev]) |
42e64fbf4609
planemo upload commit 60a090d1dc89c2eb383feeb35cd6078b9130e0e5-dirty
tiagoantao
parents:
diff
changeset
|
41 |
8
a8b87bc0c3ad
planemo upload commit 4d00a0b7a4b859b642eceb3c7cd4adb1453903a0-dirty
tiagoantao
parents:
5
diff
changeset
|
42 if options.oligo_len_1 > -1: |
a8b87bc0c3ad
planemo upload commit 4d00a0b7a4b859b642eceb3c7cd4adb1453903a0-dirty
tiagoantao
parents:
5
diff
changeset
|
43 cmd_line.extend(['--oligo_len_1', options.oligo_len_1]) |
a8b87bc0c3ad
planemo upload commit 4d00a0b7a4b859b642eceb3c7cd4adb1453903a0-dirty
tiagoantao
parents:
5
diff
changeset
|
44 if options.oligo_len_2 > -1: |
a8b87bc0c3ad
planemo upload commit 4d00a0b7a4b859b642eceb3c7cd4adb1453903a0-dirty
tiagoantao
parents:
5
diff
changeset
|
45 cmd_line.extend(['--oligo_len_2', options.oligo_len_2]) |
a8b87bc0c3ad
planemo upload commit 4d00a0b7a4b859b642eceb3c7cd4adb1453903a0-dirty
tiagoantao
parents:
5
diff
changeset
|
46 cmd_line.append('--' + options.oligo_len_2) |
a8b87bc0c3ad
planemo upload commit 4d00a0b7a4b859b642eceb3c7cd4adb1453903a0-dirty
tiagoantao
parents:
5
diff
changeset
|
47 |
0
42e64fbf4609
planemo upload commit 60a090d1dc89c2eb383feeb35cd6078b9130e0e5-dirty
tiagoantao
parents:
diff
changeset
|
48 print "[CMD]:"+' '.join(cmd_line) |
42e64fbf4609
planemo upload commit 60a090d1dc89c2eb383feeb35cd6078b9130e0e5-dirty
tiagoantao
parents:
diff
changeset
|
49 subprocess.call(cmd_line) |
42e64fbf4609
planemo upload commit 60a090d1dc89c2eb383feeb35cd6078b9130e0e5-dirty
tiagoantao
parents:
diff
changeset
|
50 |
42e64fbf4609
planemo upload commit 60a090d1dc89c2eb383feeb35cd6078b9130e0e5-dirty
tiagoantao
parents:
diff
changeset
|
51 # postprocesses |
5
1a5ebb16aaea
planemo upload commit 4d00a0b7a4b859b642eceb3c7cd4adb1453903a0-dirty
tiagoantao
parents:
0
diff
changeset
|
52 clean_files = glob.glob('*.fq*') |
0
42e64fbf4609
planemo upload commit 60a090d1dc89c2eb383feeb35cd6078b9130e0e5-dirty
tiagoantao
parents:
diff
changeset
|
53 if options.f is not None: |
42e64fbf4609
planemo upload commit 60a090d1dc89c2eb383feeb35cd6078b9130e0e5-dirty
tiagoantao
parents:
diff
changeset
|
54 shutil.copy(clean_files[0], 'clean.fq') |
42e64fbf4609
planemo upload commit 60a090d1dc89c2eb383feeb35cd6078b9130e0e5-dirty
tiagoantao
parents:
diff
changeset
|
55 else: |
42e64fbf4609
planemo upload commit 60a090d1dc89c2eb383feeb35cd6078b9130e0e5-dirty
tiagoantao
parents:
diff
changeset
|
56 shutil.copy(clean_files[0], 'fwd.fq') |
42e64fbf4609
planemo upload commit 60a090d1dc89c2eb383feeb35cd6078b9130e0e5-dirty
tiagoantao
parents:
diff
changeset
|
57 shutil.copy(clean_files[1], 'rev.fq') |
42e64fbf4609
planemo upload commit 60a090d1dc89c2eb383feeb35cd6078b9130e0e5-dirty
tiagoantao
parents:
diff
changeset
|
58 |
42e64fbf4609
planemo upload commit 60a090d1dc89c2eb383feeb35cd6078b9130e0e5-dirty
tiagoantao
parents:
diff
changeset
|
59 |
42e64fbf4609
planemo upload commit 60a090d1dc89c2eb383feeb35cd6078b9130e0e5-dirty
tiagoantao
parents:
diff
changeset
|
60 if __name__ == '__main__': |
42e64fbf4609
planemo upload commit 60a090d1dc89c2eb383feeb35cd6078b9130e0e5-dirty
tiagoantao
parents:
diff
changeset
|
61 __main__() |