100% tevredenheidsgarantie Direct beschikbaar na je betaling Lees online óf als PDF Geen vaste maandelijkse kosten 4.2 TrustPilot
logo-home
Samenvatting

Samenvatting commando's Python - Bio informatica (B-KUL-U09B1B)

Beoordeling
-
Verkocht
-
Pagina's
5
Geüpload op
10-02-2025
Geschreven in
2023/2024

Dit is een samenvatting van alle commando's gebruikt op Python, samen in één document. Commando en wat het doet staat duidelijk geschreven. Er staan ook voorbeelden in van hoe een bepaald commando te gebruiken.

Instelling
Vak









Oeps! We kunnen je document nu niet laden. Probeer het nog eens of neem contact op met support.

Geschreven voor

Instelling
Studie
Vak

Documentinformatie

Geüpload op
10 februari 2025
Aantal pagina's
5
Geschreven in
2023/2024
Type
Samenvatting

Onderwerpen

Voorbeeld van de inhoud

Commando’s python
1. Go to jupyter notebook  log in
a. String = sequence of characters
b. Error: SyntaxError (eg. No “”) & NameError (eg. prin > print)

Print(‘x’) Printing a message to the screen
Print(“x”) x = argument
Print(“he said, ‘x’”)
Print(‘he said, “x”’) The function print() can take either a string or
a number (integer) as argument
#comments A comment will be ingored by the computer
\n New line
\t Tab
my_dna = “ATGC” Assigning a string (“ATGC”) to a variable
(my_dna) = Giving a name to something
print(my_dna) Output: ATGC
print(“my_dna”) Output: my_dna
Variable name are arbitrary Rules:
- Only letters, numbers and underscore
- Can not start with a number
- Con not use a word that is built in to
the Python language, eg. print
- Case sensitive
+ Concatenating string
My_dna = “AATT” + “GGCC”
Print (My_dna) Output: AATTGGCC
Upstream = “AAAA”
My_dna = upstream + “ATGC”
Print(My_dna) Output: AAAAATGC
The result of concatenating strings is itself a
string
len(“x”) Length of a sequence

dna_length = len(“AGTC”) (of
len(“varable”) Output: 4
print(dna_length) The return value of len() is a number (an
integer)
You can not use strings & integers mixed up in the same command: functions str() and
int()
str() String (argument)

Vb. print(“AT content is “ + Output: AT content is 4
str(at_content))
 at_content is a number Integer to string: when you need to
concatenate or format numbers as part of a
string
int() Integer (number)

Vb. int(‘4’) Int(expression) als expression een getal is

Vb. number = 3 + int(dna_length)
Print(number) Output: 9 (if dna_length = len(“AATCGA’) = 6)

, String to integer: when you receive numerical
input as a string and need to perform
numerical operations
Only usable with variables that are strings – methods that belong to the string type
x.lower() Lowercase
print(my_dna.lower()) Doesn’t change the variable, they
return an copy
x.upper() Uppercase
print(my_dna.upper()) Doesn’t change the variable, they
return an copy
x.replace(“x”,”y”) Replacing x by y

print(protein.replace(“v”,”y”) It returns a copy of the variable where
all occurrences of the first string are
replaced by the second string
Extracting part of a string (taking a substring)
x[1:6] Number 1 until 5 (incl. 1, excl. 6)
- Position starts at zero
- Inclusive start
- Exclusive stop
x[0:] From begin to end
Counting substring
x.count(‘y’) In take 1 argument (the substring), it returns
the number of occurrences of the substring in
the string
Vb. my_dna.count(‘X’) We will count how many times X is in the
variable ‘my_dna’
x.find(‘y’) Finding substrings
It takes 1 argument (the substring), it returns
the position of the first occurrence of the
substring in the string
vb. protein.find(‘p’) We will find the position where ‘p’ stands the
first time in the variable ‘protein’
- Of the output is -1: ‘p’ is not in protein
- The positions start counting at zero
Order of count() and find()
My_dna.count(“A”) ≠ A.count(my_dna)

Working with files
open(“x.txt”) Opening a file
- Argument = string
Vb. data_file = open(“data_2024.csv”)
NOT: my_file_name = “dna.txt”
My_contancts = #fout: read() werkt niet op strings
my_file_name.read()

NOT: print(data_file) #fout: print het bestandobject, niet de inhoud
x.read() Read the contents of the file
- x = file objects (not name of variable)
dna_file = open(“dna.txt”)
my_dna = dna_file.read()
x.rstrip(“y”) To remove a character
- my_file_contents = my_file.read()
my_dna = my_file_contents.rstrip(“\n”)
€7,26
Krijg toegang tot het volledige document:

100% tevredenheidsgarantie
Direct beschikbaar na je betaling
Lees online óf als PDF
Geen vaste maandelijkse kosten

Maak kennis met de verkoper
Seller avatar
margauxvanw

Maak kennis met de verkoper

Seller avatar
margauxvanw Katholieke Universiteit Leuven
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
0
Lid sinds
9 maanden
Aantal volgers
0
Documenten
7
Laatst verkocht
-

0,0

0 beoordelingen

5
0
4
0
3
0
2
0
1
0

Recent door jou bekeken

Waarom studenten kiezen voor Stuvia

Gemaakt door medestudenten, geverifieerd door reviews

Kwaliteit die je kunt vertrouwen: geschreven door studenten die slaagden en beoordeeld door anderen die dit document gebruikten.

Niet tevreden? Kies een ander document

Geen zorgen! Je kunt voor hetzelfde geld direct een ander document kiezen dat beter past bij wat je zoekt.

Betaal zoals je wilt, start meteen met leren

Geen abonnement, geen verplichtingen. Betaal zoals je gewend bent via iDeal of creditcard en download je PDF-document meteen.

Student with book image

“Gekocht, gedownload en geslaagd. Zo makkelijk kan het dus zijn.”

Alisha Student

Veelgestelde vragen