Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Document preview thumbnail
Preview 2 out of 10 pages
Summary

Summary Bioinformatics cheatsheet

Document preview thumbnail
Preview 2 out of 10 pages

Bioinformatics cheatsheet to use for the exam. It includes all the exercises and additional information on certain codes. It is separated in the different steps, so only copy paste and variable adjustments should be made.

Content preview

Exam_cheatsheet

March 22, 2025


1 Exam cheatsheet

1.1 Prepare data

[ ]: from Bio.Blast import NCBIWWW, NCBIXML
from Bio import Entrez, SeqIO, Phylo, AlignIO
import pandas as pd
import time, os, alv, re
from IPython.display import Image #optional

[ ]: %load_ext rpy2.ipython

[ ]: %%R
library("ape")
library("adephylo")
library("phytools")

[ ]: baseName = ""
#can add additional baseName, then number them and do not forget to add them in␣
,→downstream (see SARS excersise)

folderName = "exercise_"

#change baseName to the file with everything before .fasta
#change folderName to excercise_baseName (the variable you name your baseName)
#e.g. baseName= HIV_virus folderName= exercise_HIV_virus

[ ]: %Rpush baseName folderName

[ ]: %%bash -s "$folderName"
mkdir ${1} # if folder already exists and you wish to overwrite, you can try␣
,→$mkdir -p ${1}



Move the uploaded file into the folder for this exercise. You can also directly upload the sequence
file to today’s exercise folder. In that case, skip the next cell.
[ ]: %%bash -s "$baseName" "$folderName"
cp ${1}.fasta ${2}/${1}.fasta


1

, #if multiple files need to be moved
cp $1.#fileFormat $2/$1.#fileFormat

[ ]: os.chdir(folderName)



1.2 BlastN search (session01)

[ ]: inputFile = baseName+'.fasta'
query = SeqIO.read(inputFile, format="fasta")
search_type = "blastn"
database = "nt"
max_nr_hits = 100
before = round(time.time(), ndigits=0)
blast_stream = NCBIWWW.qblast(program = search_type,
database = database,
sequence = query.seq,
alignments = 1,
hitlist_size = max_nr_hits)
after = round(time.time(), ndigits=0)
text = f"The BLAST search took {after - before} seconds."
print(text)

Save result BlastN
[ ]: blastn_result_file = baseName+".blastn.result.xml"
with open(blastn_result_file, 'w') as file:
file.write(blast_stream.read())

[ ]: blastn_result_file = baseName+".blastn.result.xml"

Extract the sequences in fasta format from the BLAST search results
[ ]: all_data_fasta = baseName+".blastn.result.fasta"

with open(blastn_result_file) as result_handle:
blast_records = NCBIXML.parse(result_handle)
with open(all_data_fasta, 'w') as fasta_handle:
for blast_record in blast_records:
for alignment in blast_record.alignments:
for hsp in alignment.hsps:
db_seq = hsp.sbjct
db_id = alignment.accession
fasta_handle.write(f">{db_id}\n{db_seq}\n")




2

Document information

Study
Uploaded on
March 22, 2025
Number of pages
10
Written in
2024/2025
Type
Summary
$16.41

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
sisivorst
4.0
(2)
Sold
47
Followers
4
Items
20
Last sold
3 weeks ago




Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions