Python Programming PDF
Document Details
Uploaded by SensibleOctagon4462
Tags
Summary
This document discusses Python programming, including modules, packages, and importing. It also covers Biopython for sequence analysis, offering tools and examples. The document likely serves as educational material for students in computer science or biology courses.
Full Transcript
Python Modules - Softwares containing code for a specific function, keeps it readable and maintainable. In python, these modules are files with the.py extension, containing functions, variables and classes. To import code, name is used without extension. Python modules - math. Code to define a pa...
Python Modules - Softwares containing code for a specific function, keeps it readable and maintainable. In python, these modules are files with the.py extension, containing functions, variables and classes. To import code, name is used without extension. Python modules - math. Code to define a package (audio), containing two sub-packages (formats and effects). Formats package has two modules (mp3, and wav), effects package has the two modules (echo and fade). Import a module - Import module Attributes within the imported module can be accessed via dot syntax - Mymodule.variable mymodule.function() Pythons from function allows you to import specific attributes from a function: You can also import attributes using custom names, useful for shortening a module, function, or variable name, or to avoid conflicts in code. Aliasing does not impact functionality. help(math) gives an overview of modules contents Importing a package - Importing third party packages !pip install numpy Aliasing: Biopython - Import Bio From Bio.Seq import Seq Dna_sequence = Seq(“ATCG” Object- A fundamental building block that can hold data (properties) and functions (methods), numbers, complex data types. Class- A blueprint or template for creating new objects, a class allows us to group data and related functions together, defining how each instance (object) should behave. Seq - A class defined in the Bio.Seq module within Biopython, designed to handle biological sequences. help(dna_sequence) #gives an overview of function information. Common functions performed on strings. Replacing gaps -.replace() method Biopython offers tools for sequence analysis, with built in functions - DNA-RNA transcription using Biopython - Reversal process (RNA to DNA) is also supported - Bypass Seq class abstraction and transcribe strings directly - Alignment - Multiple Sequence Alignment is used to analyse