Skip to content

Instantly share code, notes, and snippets.

@mtekman
Last active October 25, 2020 22:25
Show Gist options
  • Save mtekman/21b4ffafee6ecbf7f3c99fa747e2d471 to your computer and use it in GitHub Desktop.
Save mtekman/21b4ffafee6ecbf7f3c99fa747e2d471 to your computer and use it in GitHub Desktop.
Automated mouse and keyboard events for a Galaxy intro video for scRNA-seq

Automating a galaxy intro video

This gist has migrated to GitLab

https://gitlab.com/mtekman/galaxy-snippets

(The copy here is archived. Please see the above link for the latest developments)

Please change the browser window to:

  • Width: 998
  • Height: 1078

Introduce GTN

wid=0x1200021
alias xdo-key="xdotool key --window $wid"
alias xdo-type="xdotool type --window $wid"
alias xdo-click="xdotool click --window $wid 1"
alias xdo-mousego="xdotool mousemove --window $wid"
function gotopage () {
    # the org-mode NAME CALL dynamic is not
    # tangled so we just use the function
    page=$1
    setxkbmap de
    [ "$2" == "" ] && xdo-key Ctrl+t
    xdo-key Ctrl+l &&
    xdo-type --delay 60 $page &&
    xdo-key Return
    ~/.config/xmodmap/setkeys.sh # reset my keys, not necessary on most systems
}
function moveslow () {
    dest_x=$1
    dest_y=$2
    interval=$3

    xmod=15
    ymod=15

    while :; do
        loc_data=$(xdotool getmouselocation)
        curr_x=$(echo "$loc_data" | sed -r 's|x\:([0-9]+)\s.*|\1|g')
        curr_y=$(echo "$loc_data" | sed -r 's|x.*y\:([0-9]+)\s.*|\1|g')

        grad_x=$(( $dest_x - $curr_x ))
        grad_y=$(( $dest_y - $curr_y ))

        #echo "$loc_data"
        #echo "$grad_x = $dest_x - $curr_x "
        #echo "$grad_y = $dest_y - $curr_y "

        case "$grad_x" in
            0)
                incr_x=0;;
            -[0-9]*)
                incr_x=-$xmod;;
            [0-9]*)
                incr_x=$xmod;;
            *) echo "Nope x:$grad_x"; return -1;;
        esac

        case "$grad_y" in
            0)
                incr_y=0;;
            -[0-9]*)
                incr_y=-$ymod;;
            [0-9]*)
                incr_y=$ymod;;
            *) echo "Nope y:$grad_y"; return -1;;
        esac

        xdotool mousemove_relative -c -- $incr_x $incr_y

        if [ $curr_x -eq $dest_x ] && [ $curr_y -eq $dest_y ]; then
            break
        fi

        [ ${grad_x#-} -lt 15 ] && xmod=1;
        [ ${grad_y#-} -lt 15 ] && ymod=1;

        sleep $interval
    done
}

Open GTN page

gotopage "https://training.galaxyproject.org/" nope

Open Transcriptomics (mouse)

# scroll down to show whole page, then back up to section
xdo-key Home
moveslow 489 418 0.001 &&
sleep 0.5 &&
xdo-key --repeat 25 --delay 70 Down &&
sleep 0.5 &&
xdo-key --repeat 17 --delay 70 Up &&
sleep 0.5 &&
# click on transcriptomics
moveslow 92 594 0.001 &&
xdo-click

Subselect singlecell topics

# scroll down to show whole page, then back up to section
xdo-key Home
moveslow 502 190 0.001 &&
sleep 0.5 &&
xdo-key --repeat 45 --delay 100 Down &&
#sleep 0.5 &&
#xdo-key --repeat 20 --delay 100 Down &&
## quick scroll back up
xdo-key --repeat 40 --delay 20 Up &&
sleep 0.5 &&
# click on transcriptomics
moveslow 77 469 0.01 &&
sleep 2   # wait for tooltip
xdo-click

Quick passover scRNA-seq tutorials

    ylev1=305
    ylev2=566
    ylev3=367
    ylev4=615
    xlev1=188
    xlev2=711
    moveslow 77 469
    xdo-key Home &&
    moveslow $xlev1 $ylev1 0 && sleep 0.1 &&
    moveslow $xlev2 $ylev1 0 && sleep 0.1 &&
  #  moveslow $xlev1 $ylev2 0 && sleep 0.1 &&
   # moveslow $xlev2 $ylev2 0 && sleep 0.1 &&
    xdo-key --repeat 10 --delay 50 Down &&
#    moveslow $xlev1 $ylev3 0 && sleep 0.1 &&
 #   moveslow $xlev2 $ylev3 0 && sleep 0.1 &&
  #  moveslow $xlev1 $ylev4 0 && sleep 0.1 &&
    sleep 1 &&
    #moveslow 246 879 0 &&
    #sleep 0.1 &&
    xdo-key --repeat 10 --delay 50 Up &&
    sleep 0.5 &&
    moveslow 110 460 0 &&
    sleep 0.5 &&
    xdo-click

Passthrough the PBMC tutorial

xdo-key Home
moveslow 185 293 0 &&
sleep 0.5 &&
xdo-key --delay 200 --repeat 71 Page_Down &&
sleep 0.5 &&
xdo-key End && sleep 1
xdo-key --delay 10 --repeat 81 Page_Up &&
#xdo-click

Chat Box

xdo-key Home
moveslow 185 293 0 &&
moveslow 899 769 0 && xdo-click && sleep 0.5 &&
moveslow 553 735 0 && xdo-click && sleep 0.5 &&
xdo-type --delay 50 "Hi there, " && sleep 0.5 &&
xdo-type --delay 50 "I could use a hand!" && sleep 1
moveslow 965 93 0 && xdo-click

Introduce Galaxy interface

Switch to Page

gotopage "https://usegalaxy.eu"

Show ScanPy tools

xdo-mousego 965 93 &&
moveslow 41 180 0 &&
xdo-click &&
sleep 1 &&
xdo-type --delay 100 scanpy &&
sleep 0.5 &&
moveslow 58 253 0 &&
sleep 0.5 &&
moveslow 137 574 0 &&
sleep 1 &&
moveslow 79 252 0 &&
xdo-click

Start History and Get Data

xdo-mousego 79 252 &&
moveslow 798 216 0 &&
sleep 1 &&
xdo-click &&
sleep 0.5 &&
moveslow 798 270 0 &&
sleep 0.5 &&
xdo-type --delay 100 "My Galaxy Analysis" &&
xdo-key Return
sleep 0.5 &&

Upload Data

# Click Load your own data
moveslow 813 337 0 &&
sleep 1 &&
xdo-click
sleep 0.5 &&
# Paste / Fetch
moveslow 595 616 0 &&
sleep 0.5 &&
xdo-click
moveslow 113 386 0 &&
xdo-click &&
xdo-type --delay 50 "https://zenodo.org/record/3581213/files/genes.tsv" &&
xdo-key Return && sleep 0.5 &&
xdo-type --delay 50 "https://zenodo.org/record/3581213/files/barcodes.tsv" &&
xdo-key Return && sleep 0.5 &&
xdo-type --delay 50 "https://zenodo.org/record/3581213/files/matrix.mtx" &&
moveslow 838 614 0 && xdo-click &&
moveslow 900 615 && xdo-click

Expand Windows

xdo-mousego 900 615 &&
# hide history
sleep 0.5 &&
moveslow 983 776 0 && sleep 0.5 && xdo-click
sleep 1 &&
# hide tools
moveslow 15 774 0 && sleep 0.5 && xdo-click
sleep 1
moveslow 15 774 0 && sleep 0.5 && xdo-click
#moveslow 983 776 0 && sleep 0.5 && xdo-click

Get shared history

#xdo-mousego 15 774 &&
#sleep 0.5 &&
#moveslow 556 99 0 && sleep 1.5 && xdo-click
#sleep 0.5 &&
#moveslow 549 174 0 && sleep 0.5 && xdo-click
xdo-mousego 549 174 &&
sleep 0.5 &&
moveslow 343 193 0 && sleep 0.5 && xdo-click
moveslow 343 220 0 &&
sleep 1 &&
xdo-type --delay 50 "Clustering 3K PBMCs with ScanPy" && xdo-key Return
sleep 1 &&
moveslow 377 306 0 && sleep 0.5 && xdo-click &&
sleep 1 &&
moveslow 957 144 0 && sleep 1 && xdo-click

Go to live.usegalaxy.eu

Later

gotopage "https://live.usegalaxy.eu/"

Video Edit

All video editing was done in blender

DRM-free audio was selected from Kevin Macleod’s repertoire at:

Edm Detection Mode by Kevin MacLeod Link: https://incompetech.filmmusic.io/song/4987-edm-detection-mode License: http://creativecommons.org/licenses/by/4.0/

To crop the video to size:

ffmpeg -i 0001-4394.mkv -filter:v "crop=1360:1080:0:0" -c:a copy out.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment