Unconfigured Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • larsgt
    Junior Member
    • Jun 2012
    • 6

    Generating UCSC screen dumps in batch

    Hello,

    Is there a good way of dumping images from UCSC in batch?

    Probably going to use some form of web testing tool but I was
    wondering if there was an easier way.

    /Lars
  • rfilbert
    Member
    • Dec 2012
    • 43

    #2
    You could script almost anything. Can you be more specific what is in your "batch"?

    Comment

    • larsgt
      Junior Member
      • Jun 2012
      • 6

      #3
      Generating UCSC screen dumps in batch Reply to Thread

      Originally posted by rfilbert View Post
      You could script almost anything. Can you be more specific what is in your "batch"?
      Sorry for being a bit unclear.

      What I want to do is write a script that takes in a number of regions say
      chr1:234234234-2342424234 and gives me back a PNG/JPG/whatever of
      the UCSC browser with a few tracks and a custom track.

      /Lars

      Comment

      • Richard Finney
        Senior Member
        • Feb 2009
        • 701

        #4
        (I tought it would be hard in that I thought the individual tracks had separate images)
        Set up your session by hand. Set up the tracks you want and the track mode (squish, full, dense, whatever). Set up your custom track.
        Cut the URL for an initial query to hgTracks (the genome you want and any old position).
        You'll need an "hgsid" variable. Make sure you have this in your URL. Your command line wget will mimick
        the user you are in a browser by using this hgsid variable.
        Use that as base URL to hack. Hack position parameter as needed ...

        Here's an example, you can parameterize the position using your favorite shell code ...

        wget "http://genome.ucsc.edu/cgi-bin/hgTracks?hgHubConnect.destUrl=..%2Fcgi-bin%2FhgTracks&clade=mammal&org=Human&db=hg19&position=chr21%3A33%2C031%2C597-33%2C041%2C570&hgt.positionInput=chr21%3A33%2C031%2C597-33%2C041%2C570&hgt.suggestTrack=knownGene&Submit=submit&hgsid=317627943&pix=1180" -O x
        grep png x | grep trash | grep png | sed 's/src=...//' | tr -d "'" | grep png | awk 'BEGIN{p=0};{print "wget \"http://genome.ucsc.edu/" $3"\" -O "p"\.png"; p++}' | grep 3.png > tmp.get.job
        . ./tmp.get.job
        cp 3.png final.png


        # I thought the images were in chunks , but they are not, third image will do.
        #the following code using imagemagick are not necessary to "concatenate images".
        #odds=`ls 3.png 5.png 7.png 9.png 11.png 13.png 15.png 17.png 19.png 21.png 22.png 23.png 25.png 27.png`
        #evens=`ls 2.png 4.png 6.png 8.png 10.png 12.png 14.png 16.png 18.png 20.png 22.png 24.png 26.png`
        #convert $odds -append left.png
        #convert $evens -append right.png
        #convert left.png right.png +append final.png

        This just wgets the URL to a file called "x" and gets the third (4th ?) png in the resulting file which you can then wget. The final.png is the file you want to look at. You can rename it as necessary, perhaps using a parameter to your script.

        There are likely more elegant ways, but what the heck it's a hack that works.

        Regardless this should be a good enough hint for some wizard to fix up.

        Resulting image may need alpha channel removed. I think. I"m not sure. It looks transparent in gimp but appears okay in browser.
        Use imagemagick for this .
        Last edited by Richard Finney; 12-17-2012, 07:26 PM.

        Comment

        • jiaco
          Member
          • May 2010
          • 35

          #5
          Yeah, something fun to do first thing this morning. Despite the functional hack by R Finney, here is another that gets you the image in pdf format.


          Put the first code block in wgetUcscPdfs.sh and chmod +x it

          Be sure to change the hgsid to a value from your browser session
          Code:
          #!/bin/bash
          
          baseurl="http://genome.ucsc.edu/"
          hgsid=12345678
          
          cat $1 | while read chr beg end;
          do
          	position=$chr":"$beg"-"$end;
          	pdf_fname="auto_"$chr"_"$beg"_"$end".pdf";
          
          	s=$baseurl"cgi-bin/hgTracks?hgt.psOutput=on&hgsid="$hgsid"&position="$position
          	wget $s -O XXX
          	s2=`grep 'hgt_genome.*.pdf' XXX | sed 's/.*hgt_genome/hgt_genome/' | sed 's/[.]pdf.*/.pdf/'`
          	tgt=$baseurl"/trash/hgt/"$s2
          	wget $tgt -O $pdf_fname
          done
          Here is a sample input, albeit a stupid one, the regions are all Ns

          Code:
          chr1	50000	50100
          chr22	100000	100100
          And the command line to make it happen.
          Code:
          ./wget_UcscPdfs.sh test_wgetUcscPdfs.txt
          You can make the file names how you want and even clean up url escaping if you like. It uses 2 rounds of wget but in the end you can get pdfs of each region.

          Comment

          • frozenlyse
            Senior Member
            • Sep 2008
            • 135

            #6
            A blog about Tips and Tricks for Unix, Perl, R, HTML, Javascript, Google API and mostly Bioinformatics

            Comment

            Latest Articles

            Collapse

            • SEQadmin2
              Nine Things a Sample Prep Scientist Thinks About Before Sequencing
              by SEQadmin2


              I’m not a sequencing expert. I’m a purification scientist who uses NGS to evaluate workflows my group develops. With this perspective, we think about the sample first and the NGS workflow second. The sequencer is an exceptionally honest reporter, but it can only report on what you give it, so whether you get clean, interpretable data from an NGS workflow is largely determined before you begin.

              Here are nine questions we think about, in roughly the order they matter, before...
              06-18-2026, 07:11 AM
            • SEQadmin2
              From Collection to Sequencing: Why Sample Preparation and Preservation Define Sequencing Data
              by SEQadmin2


              Data variability is still an issue in sequencing technologies despite the advances in reproducibility and accuracy of these platforms. But the problem does not originate in the sequencing itself, but in the previous steps, before the sample reaches the sequencer.


              The first step is collection, followed by preservation and sample preparation for analysis. Most scientists overlook those steps, but not being careful might just be skewing the experiment’s results.
              ...
              06-02-2026, 10:05 AM

            ad_right_rmr

            Collapse

            News

            Collapse

            Topics Statistics Last Post
            Started by SEQadmin2, Yesterday, 11:10 AM
            0 responses
            7 views
            0 reactions
            Last Post SEQadmin2  
            Started by SEQadmin2, 06-17-2026, 06:09 AM
            0 responses
            42 views
            0 reactions
            Last Post SEQadmin2  
            Started by SEQadmin2, 06-09-2026, 11:58 AM
            0 responses
            104 views
            0 reactions
            Last Post SEQadmin2  
            Started by SEQadmin2, 06-05-2026, 10:09 AM
            0 responses
            125 views
            0 reactions
            Last Post SEQadmin2  
            Working...