Beställningsvara. Skickas inom 7-10 vardagar. Fri frakt för medlemmar vid köp för minst 249 kr.
Enables scientists and researchers to efficiently use one of the most popular programming languages in their day-to-day work Streamlining Your Research Laboratory with Python covers the Python programming language and its ecosystem of tools applied to tasks encountered by laboratory scientists and technicians working in the life sciences. After opening with the basics of Python, the chapters move through working with and analyzing data, generating reports, and automating the lab environment. The book includes example processes within chapters and code listings on nearly every page along with schematics and plots that can clearly illustrate Python at work in the lab. The book also explores some real-world examples of Python’s application in research settings, demonstrating its potential to streamline processes, improve productivity, and foster innovation. Streamlining Your Research Laboratory with Python includes information on: Language basics including the interactive console, data types, variables and literals, strings, and expressions using operatorsCustom functions and exceptions such as arguments and parameters, names and scope, and decoratorsConditional and repeated execution as methods to control the flow of a programTools such as JupyterLab, Matplotlib, NumPy, pandas DataFrame, and SciPyReport generation in Microsoft Word and PowerPoint, PDF report generation, and serving results through HTTP and email automaticallyWhether you are a biologist analyzing genetic data, a chemist scouting synthesis routes, an engineer optimizing machine parameters, or a social scientist studying human behavior, Streamlining Your Research Laboratory with Python serves as a logical and practical guide to add Python to your research toolkit.
Mark F. Russo, PhD is currently on the faculty in the Department of Computer Science at The College of New Jersey. Previously, he had a multi-decade professional career in biotech and pharma with a focus on scientific computing, automation, and scientific data. William Neil is currently at Bristol Myers Squibb and has been working in the pharmaceutical industry since 1995.
Preface xv1 Introduction 11.1 Python Implementations 11.2 Installing the Python Toolkit 21.3 Python 3 vs. Python 2 21.4 Python Package Index 31.5 Programming Editors 51.6 Notebook Editors 51.7 Using the Jupyter Notebook Interface 71.8 JupyterLite 81.9 Things Change 91.10 Key Takeaways 92 Language Basics 112.1 Python Interactive Console 112.2 Data Types 112.3 Variables and Literals 142.4 Strings 152.4.1 Simple Strings 152.4.2 Multi-Line Strings 162.4.3 Escape Characters in a String 162.4.4 Raw Strings 182.4.5 Formatted Strings 182.4.6 Strings as Objects 192.4.7 Characters and Encodings 212.5 Expressions Using Operators 222.5.1 Arithmetic Operators 222.5.2 Assignment Operators 242.5.3 Comparison Operators 252.5.4 Boolean Operators 262.5.5 Chaining Comparisons 282.5.6 Comparing Floating-Point Numbers 292.6 Functions and How to Use Them 292.6.1 Invoking Functions 302.6.2 Built-in Functions 312.6.3 The math Module for Additional Mathematical Functions 312.6.4 The random Module for Pseudo-Random Number Generation 332.6.5 The time and datetime Modules for Handling Dates and Times 362.6.6 The sys Module for System Interactions 392.6.7 Scope and Namespace 402.7 Your First Python Program 412.8 Key Takeaways 423 Data Structures 453.1 Lists 453.1.1 Introducing Lists 453.1.2 Global Functions That Operate on Lists 463.1.3 Accessing List Elements 463.1.4 Slicing Lists 473.1.5 Lists Operators 493.1.6 Lists as Objects 513.2 Tuples 553.2.1 Introducing Tuples 553.3 Dictionaries 563.3.1 Introducing Dictionaries 563.3.2 Global Functions That Operate on Dictionaries 573.3.3 Accessing Dictionary Items 573.3.4 Dictionary Operators 583.3.5 Dictionaries as Objects 593.4 Sets 613.4.1 Introducing Sets 613.4.2 Global Functions That Operate on Sets 623.4.3 Accessing Set Elements 623.4.4 Set Operators 623.4.5 Sets as Objects 643.5 Destructuring Assignment 653.6 Key Takeaways 664 Controlling the Flow of a Program 674.1 Conditional Execution 674.1.1 If-Statements 674.1.2 If-Else Statements 684.1.3 If-Elif-Else Statements 704.1.4 If-Statement Strategies 714.1.5 Truthy and Falsy Values 744.1.6 Conditional Expressions 754.2 Repeated Execution 764.2.1 While-Statements 764.2.2 For-Statements 814.2.3 For-Statements with Range 834.2.4 Break and Continue 844.2.5 Comprehensions 854.3 Key Takeaways 875 Custom Functions and Exceptions 895.1 Defining Custom Functions 895.2 Arguments and Parameters 945.3 Names and Scope 975.3.1 Local vs. Global 975.3.2 Built-in and Nonlocal Scope 995.4 Scope vs. Namespace 1005.5 Organizing Your Code with Modules 1025.6 Decorators 1045.7 How Things Go Wrong 1065.8 Python Exceptions 1065.9 Handling Exceptions 1075.10 Raising Your Own Exceptions 1105.11 Key Takeaways 1126 Regular Expressions 1156.1 Matching Literal Text 1156.2 Alternation 1166.3 Defining and Matching Character Classes 1166.4 Metaclasses 1176.5 Pattern Sequences 1176.6 Repeating Patterns with Quantifiers 1186.7 Anchors 1196.8 Capturing Groups 1206.9 Regular Expressions in Python 1226.10 Project – A Formula Mass Calculator 1236.11 Key Takeaways 1307 Working with Data 1317.1 A File System Primer 1317.2 Text Files 1337.3 Reading and Writing Text Files 1347.4 Working with Comma-Separated Values (CSV) Files 1397.5 The csv Module 1447.6 Reading and Writing Excel Spreadsheet 1457.6.1 openpyxl Workbook Object 1467.6.2 openpyxl Worksheet Object 1477.6.3 openpyxl Cell Object 1487.7 Project – Generate a Random Sample Layout in a Spreadsheet 1487.8 Project – Forecast Monthly Sample Processing 1507.9 Managing the File System 1547.9.1 The Path Object 1557.9.2 Path Properties 1557.9.3 Path Attributes 1567.9.4 Operating On a Path 1577.9.5 Combining Paths 1587.9.6 The shutil Module for High-Level File Operations 1597.10 Walking a File System Tree 1597.11 Project – Find Duplicate Files 1617.12 Working with Zip Files 1637.12.1 ZipFile Object 1637.12.2 zipfile Path Object 1637.12.3 Creating Zip Archives 1647.13 Working with Standard Data Formats 1657.13.1 JSON – JavaScript Object Notation 1657.13.2 json Python Module 1667.13.3 XML – Extensible Markup Language 1687.13.4 Python XML modules 1707.13.5 Other Standard Data Formats 1767.14 Key Takeaways 1768 Web Resources 1798.1 TCP/IP Networks – What You Need to Know 1798.1.1 Internet Protocol 1808.1.2 Transmission Control Protocol 1808.1.3 Connections and Ports 1808.1.4 Application Layer Protocols 1818.1.5 IPv4 vs. IPv6 Addresses 1818.1.6 Proxy Servers 1818.2 Introduction to Hypertext Transfer Protocol 1828.2.1 The Uniform Resource Locator 1838.2.2 Anatomy of an HTTP Request 1848.2.3 Anatomy of an HTTP Response 1868.3 Web Services and the Python Requests Module 1878.3.1 HTTP GET Requests and the Response Object 1888.3.2 HTTP POST Requests 1898.3.3 Binary Responses 1908.3.4 Customizing the Request Object 1938.3.5 Verifying Certificates and Encryption 1938.3.6 Other requests Module Options 1948.4 Project – Print Weather Forecast for a Location 1958.4.1 National Weather Service API Web Service 1958.4.2 Getting Forecast URL from Geolocation 1978.4.3 Loading and Processing Forecast Data 1978.4.4 Completed Program to Generate Temperature Forecast 1988.5 Project – Scraping HTML Page Content 2018.6 Key Takeaways 2069 Data Analysis and Visualization 2099.1 JupyterLab 2099.2 Scientific Plotting with Matplotlib 2119.2.1 The pyplot Submodule 2129.2.2 The pyplot.plot() function 2129.2.3 Customizing a Plot 2139.2.4 Multiple Curves on a Single Plot 2149.2.5 Additional Plot Types 2149.2.6 Multiple Axes on a Single Figure 2149.2.7 Other Useful Functions 2169.2.8 Project – Plotting Weather Forecast 2169.2.9 Project – A Custom Microplate Heat Map 2199.2.10 Other Scientific Plotting Libraries 2229.3 NumPy – Numerical Python 2239.3.1 Creating ndarray Objects 2239.3.2 Working with ndarray Objects 2239.3.3 Accessing and Updating ndarray Elements 2249.3.4 Broadcasting 2269.4 pandas DataFrame 2269.4.1 Creating and Inspecting DataFrames 2279.4.2 Filtering DataFrames 2289.4.3 Project – A Screening Experiment 2309.5 SciPy – A Library for Mathematics, Science, and Engineering 2399.5.1 Descriptive Statistics with SciPy 2399.5.2 Hypothesis Testing 2399.5.3 Project – Running Hypothesis Tests on Two Samples 2409.5.4 Project – Comparing Liquid Handler Syringe Performance 2439.5.5 Linear Regression 2459.5.6 Fitting Nonlinear Models to Data 2469.5.7 Project – Four-Parameter Logistic Regression 2489.6 Key Takeaways 25310 Report Generation 25510.1 BytesIO Object 25510.2 Generating Reports in Microsoft Word 25710.2.1 Document Object 25710.2.2 Paragraph Object 25810.2.3 Run Object 25910.2.4 Picture and InlineShape Objects 26010.2.5 Table Object 26110.2.6 Project – Generate a Complete Word Report 26310.3 Generating Microsoft PowerPoint Presentations 26610.3.1 Presentation Object 26610.3.2 Slide Objects 26710.3.3 SlideShapes Object 26810.3.4 Length Objects 26910.3.5 Table Object 26910.3.6 Project – Generate a PowerPoint Document with Figures and Tables 27210.4 Generating PDF File Reports 27510.4.1 ReportLab PDF Generation Process 27510.4.2 Creating a Canvas Object 27610.4.3 Setting Canvas Styles 27610.4.4 Managing Text Blocks with PDFTextObjects 27810.4.5 Canvas State Stack 28110.4.6 Drawing Images 28110.4.7 PLATYPUS for Page Layout 28310.4.8 Project – Generate a Complete PDF Report 28310.5 Sending Email Programmatically 28710.5.1 Simple Mail Transfer Protocol 28810.5.2 SMTP Mail Server 28810.5.3 Send a Simple Email Message 28810.5.4 Sending Email Messages over a Secure Connection 29110.5.5 Building an Email Message with Attachments 29210.6 Serving Results with an HTTP Server 29410.7 Key Takeaways 29611 Control and Automation 29711.1 Concurrency in Python 29711.2 Asynchronous Execution 29911.3 Concurrent Programs with AsyncIO 30011.4 Asynchronous Instrument Control and Coordination 30411.4.1 Project – Integrated Laboratory System Control and Coordination 30411.5 Communicating over a Serial Port 31111.5.1 Reading Barcodes from a Serial Port 31211.5.2 Project – Scanning Sample Tasks into a Running Controller 31811.6 Execute Remote Commands over HTTP 31911.6.1 A Basic HTTP Server with aiohttp 32011.6.2 Routing an HTTP Request to a Custom Python Function 32111.7 Persistent Network Connections using a WebSocket 32511.7.1 A User Interface for Asynchronous Networked Programs 32611.7.2 WebSocketResponse and FileResponse Objects 32611.7.3 Project – A Browser-Based WebSocket Message Broadcaster 32711.7.4 Project – A Browser User Interface to Schedule Samples for Analysis 33511.8 Responding to File System Changes 33811.8.1 Watching a Directory for Changes with watchfiles 33811.8.2 File System Monitoring Options 34011.9 Executing Tasks on a Schedule 34111.9.1 sched Module 34211.9.2 Project – Taking and Sending Images on a Schedule 34411.10 Key Takeaways 348Postface 351References 353Appendix A: ASCII American Standard Code for Information Interchange 357Index 359