>>> import os
>>> import datetime
>>> file = "my_file.txt"
>>> os.stat(file).st_ctime
1483323862.8774118
>>> os.path.getmtime(file)
1483323862.873167
>>> os.path.getmtime(os.path.getmtime(file))
KeyboardInterrupt
Homebrew
# paste of some of the things I've installed
brew install python
brew install pip
brew install pyenv
brew install pip --upgrade
{ | |
"color_scheme": "Packages/Monokai Extended/Monokai Extended.tmTheme", | |
"draw_white_space": "all", | |
"font_size": 18, | |
"ignored_packages": | |
[ | |
"Vintage" | |
], | |
"ignored_words": | |
[ |
The codes:
# system info
system("uname -srv", intern = TRUE)
# dir
system('pwd',intern=T)
# date time
paste this inside your script for debugging, to start a Python interactive terminal shell session at that point in the script, super useful for debugging since it lets you explore the Python environment and access objects and variables as they are at that point in the script.
import readline # optional, will allow Up/Down/History in the console
import code
vars = globals().copy()
vars.update(locals())
Here are some handy commands for connecting to servers and copying files about. These are all for Linux terminal / bash shell
Do cool things with ssh; log in & run command, find files in dir
# log into server
ssh [email protected] -Y
# -X Enables X11 forwarding. <- use this to enable X11 graphical windows, but this will eventually time out & you'll lose the X11 connection
# -Y Enables trusted X11 forwarding. <- this one preserves your X11 connection while you're logged in
You can use IGV to automatically & programmatically load genomic datasets and take snapshots of regions of interest. This is very handy and helps you avoid taking many screenshots manually.
Manual page here:
http://software.broadinstitute.org/software/igv/batch
These commands are also available:
http://software.broadinstitute.org/software/igv/PortCommands
- Convert multipage PDF into single page PNG files with GhostScript
gs -o /path/to/output_page_%03d.png -sDEVICE=png16m -r150 /path/to/input.pdf
- Convert multiple single-page PDF files into one multi-page PDF file
http://stackoverflow.com/questions/6190331/can-i-do-an-ordered-default-dict-in-python
# from collections import OrderedDict, defaultdict
import collections
class OrderedDefaultDict(collections.OrderedDict, collections.defaultdict):
def __init__(self, default_factory=None, *args, **kwargs):
#in python3 you can omit the args to super
super(OrderedDefaultDict, self).__init__(*args, **kwargs)
self.default_factory = default_factory
$ cat data/depth13Genome.depth.summary2.averages_sd.txt | cut -f1
chr1
chr10
chr11
chr12
chr13
chr14
chr15
chr16