You are on page 1of 2

Week 1 cheatsheet

Programming with Python (for Bioinformatics)

Jens Zentgraf, Johanna Schmitz

Winter 2022/23

Basic Bash Commands


• Absolute vs. relative path – mv day01.py Downloads: Moves day01.py
– Current folder is your home folder to the Downloads folder
– Downloads folder: – mv day01.py day02.py: Renames day01.py
∗ Relative path: Downloads to day02.py
∗ Absolute path: /home/username/Downloads • Copy a file cp:
– ~ is an alias for /home/username – cp source dest: Copies the source file to the
• Change directory cd: destination.
– cd or cd ~: Switch to your home folder – cp day01.py day02.py: Copies day01.py
– cd ..: Switch to parent directory and saves it as day02.py
– cd ../..: Go up two directories – cp -r aoc aoc2: Copies the folder aoc and
– cd Downloads: Switch into the Downloads saves it as aoc2. You need to add -r to recur-
folder sively copy all files in the folder.
You can use a relative or absolute path • touch filename create a file with the filename.
– cd -: Switch to the last directory – touch day01.py creates day01.py.
• Move/rename a file mv: • ls: Lists all files and folder in the current folder
– mv file target_path: Moves file to the tar- • ls folder: Lists all files and folders in folder
get folder • mkdir name: Creates a folder with the name.

Git Commands
Clone Course Repository • if xclip is not installed, open file and copy
the key manually
1. Create GitLab account: https://gitlab.com/users/s
• go to User Settings > SSH Keys to add
ign_in
the ssh key to your gitlab account
2. Add ssh key to your GitLab account
1. If you don’t have an ssh key on your machine 3. Go to course repository: https://gitlab.com/lamdv
(in ~/.ssh folder) 1/programming-with-python-2022
• open a terminal
4. Fork repository (your fork must be public !) Fork
• generate ssh key using the command
ssh-keygen -t ed25519 5. Open a terminal and change directory to your doc-
• press enter to save key in default location uments folder
• press again enter if you don’t want to add
6. Clone forked repository
a password to your key
2. Add key to your account git clone git@gitlab.com:<your account name>
• copy public key (if you used the default /programming-with-python-2022.git
location: ~/.ssh/id_ed25519.pub)

xclip -sel clip < ~/.ssh/id_ed25519.pub

1
Overview Git

Important Commands Undo Changes


• configure git • use git reset to reset repository to a previous commit
(all later commits will be deleted), e.g., git reset
git config --global user.name "your name" c4edd723 where c4edd723 is the commit hash (use
git config --global user.email "your email" git log to view git history)
• use git revert to reset repository to previous com-
• git add <filename> to add local changes to stag-
mit, but keeping the log intact (add as new commit,
ing area
commits in between stay intact)
• git commit -m "commit message" to create new
‘save point’ Advanced Information

• git push to add your commit to the remote repos- More information about git, like merging, branching etc.,
itory (pushed files are visible for us) can be found at https://git-scm.com/docs

• git status to get an overview about local changes

• if you work from multiple locations use git pull


to update your local files with the current status of
the remote repository (otherwise you might create
a merge conflict)

Miniconda
This description is intended for the pool computers. If 7. Close the terminal and start a new one.
you use a different system, adjust the steps accordingly. It should show you something like (base)
username@bioXX:~$.
Download miniconda: You are in the base environment.
8. conda --version should result in conda 4.12.0.
1. Go to https://docs.conda.io/en/latest/miniconda.
html Create an environment
2. Download Miniconda3 Linux 64-bit
3. Open a Terminal. • We want to create a new environment with Python
4. Go to Downloads cd Downloads. 3.10.
• You create a new environment using coda create
Install miniconda: -n $NAME [package_spec ...].
• Replace $NAME with the name for your environment,
1. Make Miniconda executable by chmod +x e.g.: pyprog.
Miniconda3-latest-Linux-x86_64.sh • Specify the Python version with python=3.10. This
2. Install Miniconda installs the latest version of Python 3.10 which is
compatible with all other packages.
./Miniconda3-latest-Linux-x86_64.sh
• conda create -n pyprog python=3.10 and ac-
3. Press enter to read the license agreement. cept the listed packages (y).
4. Type yes to accept. • To activate the new environment type conda
5. Press enter to accept the default location in your activate pyprog.
home folder. • The installed Python version (python --version)
6. Type yes to initialize conda. should be Python 3.10.6.

You might also like