annotate zinbra.py @ 6:7d532e820976

Support comparison in zinbra. 3fba761
author oleg@oleg-desktop.times.labs.intellij.net
date Wed, 28 Oct 2015 20:08:20 +0300
parents 0eb50728861a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
5f97f28e65ca Initial commit
Oleg Shpynov <oleg.shpynov@gmail.com>
parents:
diff changeset
1 #!/usr/bin/env python
5f97f28e65ca Initial commit
Oleg Shpynov <oleg.shpynov@gmail.com>
parents:
diff changeset
2 """
5f97f28e65ca Initial commit
Oleg Shpynov <oleg.shpynov@gmail.com>
parents:
diff changeset
3 Python wrapper for zinbra.xml
5f97f28e65ca Initial commit
Oleg Shpynov <oleg.shpynov@gmail.com>
parents:
diff changeset
4 """
5f97f28e65ca Initial commit
Oleg Shpynov <oleg.shpynov@gmail.com>
parents:
diff changeset
5
5f97f28e65ca Initial commit
Oleg Shpynov <oleg.shpynov@gmail.com>
parents:
diff changeset
6 import os
5f97f28e65ca Initial commit
Oleg Shpynov <oleg.shpynov@gmail.com>
parents:
diff changeset
7 import sys
5f97f28e65ca Initial commit
Oleg Shpynov <oleg.shpynov@gmail.com>
parents:
diff changeset
8 import subprocess
5f97f28e65ca Initial commit
Oleg Shpynov <oleg.shpynov@gmail.com>
parents:
diff changeset
9
5f97f28e65ca Initial commit
Oleg Shpynov <oleg.shpynov@gmail.com>
parents:
diff changeset
10 argv = sys.argv[1:]
5f97f28e65ca Initial commit
Oleg Shpynov <oleg.shpynov@gmail.com>
parents:
diff changeset
11 print 'Arguments {0}'.format(argv)
6
7d532e820976 Support comparison in zinbra. 3fba761
oleg@oleg-desktop.times.labs.intellij.net
parents: 2
diff changeset
12
7d532e820976 Support comparison in zinbra. 3fba761
oleg@oleg-desktop.times.labs.intellij.net
parents: 2
diff changeset
13 # Check command
7d532e820976 Support comparison in zinbra. 3fba761
oleg@oleg-desktop.times.labs.intellij.net
parents: 2
diff changeset
14 if len(argv) == 5:
7d532e820976 Support comparison in zinbra. 3fba761
oleg@oleg-desktop.times.labs.intellij.net
parents: 2
diff changeset
15 genome, bin, fdr, action, bed = argv
7d532e820976 Support comparison in zinbra. 3fba761
oleg@oleg-desktop.times.labs.intellij.net
parents: 2
diff changeset
16 assert action == "analyze"
7d532e820976 Support comparison in zinbra. 3fba761
oleg@oleg-desktop.times.labs.intellij.net
parents: 2
diff changeset
17 else:
7d532e820976 Support comparison in zinbra. 3fba761
oleg@oleg-desktop.times.labs.intellij.net
parents: 2
diff changeset
18 genome, bin, fdr, action, bed1, bed2 = argv
7d532e820976 Support comparison in zinbra. 3fba761
oleg@oleg-desktop.times.labs.intellij.net
parents: 2
diff changeset
19 assert action == "compare"
0
5f97f28e65ca Initial commit
Oleg Shpynov <oleg.shpynov@gmail.com>
parents:
diff changeset
20
5f97f28e65ca Initial commit
Oleg Shpynov <oleg.shpynov@gmail.com>
parents:
diff changeset
21 # Configure main jar path
2
0eb50728861a Released version:
oleg@oleg-desktop.times.labs.intellij.net
parents: 1
diff changeset
22 jar = os.environ.get("INTEGRATION_JAR")
1
8cbb06892b62 Release version:
Oleg Shpynov <oleg.shpynov@gmail.com>
parents: 0
diff changeset
23 print 'Using JAR distributive file {0}'.format(jar)
0
5f97f28e65ca Initial commit
Oleg Shpynov <oleg.shpynov@gmail.com>
parents:
diff changeset
24
1
8cbb06892b62 Release version:
Oleg Shpynov <oleg.shpynov@gmail.com>
parents: 0
diff changeset
25 cmd = 'java -cp {0} org.jetbrains.bio.genestack.FastaToTwoBitCLA {1} reference.2bit'.format(jar, genome)
8cbb06892b62 Release version:
Oleg Shpynov <oleg.shpynov@gmail.com>
parents: 0
diff changeset
26 print 'Converting reference genome fasta to 2bit: {0}'.format(cmd)
8cbb06892b62 Release version:
Oleg Shpynov <oleg.shpynov@gmail.com>
parents: 0
diff changeset
27 subprocess.check_call(cmd, cwd=None, shell=True)
0
5f97f28e65ca Initial commit
Oleg Shpynov <oleg.shpynov@gmail.com>
parents:
diff changeset
28
5f97f28e65ca Initial commit
Oleg Shpynov <oleg.shpynov@gmail.com>
parents:
diff changeset
29 # See https://github.com/JetBrains-Research/zinbra for command line options
6
7d532e820976 Support comparison in zinbra. 3fba761
oleg@oleg-desktop.times.labs.intellij.net
parents: 2
diff changeset
30 if action == "analyze":
7d532e820976 Support comparison in zinbra. 3fba761
oleg@oleg-desktop.times.labs.intellij.net
parents: 2
diff changeset
31 cmd = 'java -cp {0} org.jetbrains.bio.zinbra.ZinbraCLA ' \
7d532e820976 Support comparison in zinbra. 3fba761
oleg@oleg-desktop.times.labs.intellij.net
parents: 2
diff changeset
32 'analyze -i {1} -bed result.bed -r reference.2bit -b {3} -fdr {4}'.format(jar, bed, bin, fdr)
7d532e820976 Support comparison in zinbra. 3fba761
oleg@oleg-desktop.times.labs.intellij.net
parents: 2
diff changeset
33 else:
7d532e820976 Support comparison in zinbra. 3fba761
oleg@oleg-desktop.times.labs.intellij.net
parents: 2
diff changeset
34 cmd = 'java -cp {0} org.jetbrains.bio.zinbra.ZinbraCLA ' \
7d532e820976 Support comparison in zinbra. 3fba761
oleg@oleg-desktop.times.labs.intellij.net
parents: 2
diff changeset
35 'compare -1 {1} -2 {2} -bed result.bed -r reference.2bit -b {3} -fdr {4}'.format(jar, bed1, bed2, bin, fdr)
0
5f97f28e65ca Initial commit
Oleg Shpynov <oleg.shpynov@gmail.com>
parents:
diff changeset
36 print 'Launching zinbra: {0}'.format(cmd)
5f97f28e65ca Initial commit
Oleg Shpynov <oleg.shpynov@gmail.com>
parents:
diff changeset
37 subprocess.check_call(cmd, cwd=None, shell=True)