remote control of IGV to jump to any number of loci in a file and screenshot the locus to a file
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@3375 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
3c022e4b0c
commit
43544cfdf9
|
|
@ -0,0 +1,74 @@
|
|||
# Echo server program
|
||||
import socket, re
|
||||
from os.path import join
|
||||
from time import sleep
|
||||
|
||||
from farm_commands2 import *
|
||||
import os.path
|
||||
import sys
|
||||
from optparse import OptionParser
|
||||
from datetime import date
|
||||
import glob
|
||||
import operator
|
||||
import faiReader
|
||||
import math
|
||||
import shutil
|
||||
import string
|
||||
from madPipelineUtils import *
|
||||
|
||||
HOST = 'vm0e0-052.broadinstitute.org' # Symbolic name meaning the local host
|
||||
PORT = 60151 # Arbitrary non-privileged port
|
||||
LOCAL_DIR = "/Users/depristo/Desktop/IGV_screenshots"
|
||||
|
||||
def main():
|
||||
global OPTIONS
|
||||
usage = """usage: %prog [options] sites
|
||||
Automatically captures IGV PNG screenshots at each site in the file sites (of the form chrX:start-stop or chrX:pos) by connecting to
|
||||
an IGV session. See http://www.broadinstitute.org/igv/?q=PortCommands. Make sure you enable ports in the IGV preferences"""
|
||||
parser = OptionParser(usage=usage)
|
||||
parser.add_option("-w", "--wait", dest="wait",
|
||||
action='store_true', default=False,
|
||||
help="If provided, instead of taking screenshots we will prompt the user on the command line to press return and then jump to the new location")
|
||||
parser.add_option("", "--host", dest="host",
|
||||
type='string', default=HOST,
|
||||
help="The host running the port enabled IGV server")
|
||||
parser.add_option("-d", "--dir", dest="dir",
|
||||
type='string', default=LOCAL_DIR,
|
||||
help="The local directory on the host machine that screenshots should be written to")
|
||||
parser.add_option("-s", "--sort", dest="sort",
|
||||
type='string', default="base",
|
||||
help="The sort order for the bases, currently can be one of base, position, strand, quality, sample, and readGroup.")
|
||||
|
||||
(OPTIONS, args) = parser.parse_args()
|
||||
if len(args) != 1:
|
||||
parser.error("incorrect number of arguments")
|
||||
|
||||
sites = args[0]
|
||||
#It might ignore the first line..
|
||||
print "Be sure to turn on ports"
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
|
||||
def sendCommand(cmd):
|
||||
s.send(cmd)
|
||||
print s.recv(512).trim()
|
||||
|
||||
s.connect((OPTIONS.host, PORT))
|
||||
sendCommand("snapshotDirectory " + OPTIONS.dir + "\n")
|
||||
c = 0
|
||||
for line in open(sites):
|
||||
site = line.split()[0]
|
||||
print site
|
||||
c+=1
|
||||
sendCommand("goto %s\n" % site)
|
||||
sendCommand("sort " + OPTIONS.sort + "\n")
|
||||
if OPTIONS.wait:
|
||||
raw_input("Enter To Continue")
|
||||
else:
|
||||
sendCommand("snapshot\n") # %s.png\n" % re.sub("-","_",re.sub(':', '_', site)))
|
||||
print c
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
|
||||
Loading…
Reference in New Issue