<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Python Project for Chemistry on Medium]]></title>
        <description><![CDATA[Stories by Python Project for Chemistry on Medium]]></description>
        <link>https://medium.com/@jaylanchunjaturtle?source=rss-20d88a49aa26------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*B3Jcp1e9yKQltbN6</url>
            <title>Stories by Python Project for Chemistry on Medium</title>
            <link>https://medium.com/@jaylanchunjaturtle?source=rss-20d88a49aa26------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 20:24:51 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jaylanchunjaturtle/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Made a Calculator to Solve the Problem of Peptide Fragments Caused by Missing Amino Acids]]></title>
            <link>https://medium.com/@jaylanchunjaturtle/made-a-calculator-to-solve-the-problem-of-peptide-fragments-caused-by-missing-amino-acids-5615c0630ba4?source=rss-20d88a49aa26------2</link>
            <guid isPermaLink="false">https://medium.com/p/5615c0630ba4</guid>
            <category><![CDATA[calculator]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[mass-spectrometry]]></category>
            <category><![CDATA[amino-acid]]></category>
            <category><![CDATA[peptides]]></category>
            <dc:creator><![CDATA[Python Project for Chemistry]]></dc:creator>
            <pubDate>Sat, 02 Nov 2024 04:26:31 GMT</pubDate>
            <atom:updated>2024-11-02T04:36:59.310Z</atom:updated>
            <content:encoded><![CDATA[<h4>When chemists synthesize peptides, how do they identify unknown substances in mass spectra caused by the absence of one or more amino acids?</h4><p>I made a simple calculator to solve the peptide fragment problem. Before explaining what I did, Let’s explain what a peptide is.</p><p>A peptide is composed of amino acids, the building blocks of proteins. These amino acids are linked in a specific sequence, forming a chain that defines the peptide’s structure and function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*alWrvsPQILRDS70DJlMd6g.png" /><figcaption>A peptide is a string of amino acids. <a href="https://www.cellgs.com/blog">https://www.cellgs.com/blog</a></figcaption></figure><p>Chemists can synthesize peptides and use mass spectrometry to analyze whether the peptide fragments are what we want. However, many times we can find from mass spectrometry that some unknown substances are composed of one or more amino acids missing.</p><p>To quickly identify these peptides missing certain amino acids, I created a tool that can list all possible amino acid combinations of a peptide. Arrange and combine acids and calculate their molecular weights, so that chemists can immediately know that the peptide they synthesize may be missing certain amino acids.</p><p>For example, if a chemist synthesizes a sequence “SGDEPA” and a peak appears in the mass spectrum, its sequence is missing two amino acids, G and D. To quickly identify this peak, automatically calculate all possible combinations of amino acid molecular weights will save time in identifying unknown peaks in mass spectra caused by fragment loss.</p><p>Let’s start understanding how this program works.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/496/1*OY3f3VLBGuOMkIYpxiqhjw.png" /><figcaption>Starting screen</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/496/1*tRkkxRrfMdDM1TzfwqnGbg.png" /><figcaption>Input the amino acid sequence</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/496/1*P2_HX8r7MahBjeRqAkniiA.png" /><figcaption>Show the combination results</figcaption></figure><p>Here is part of the code:</p><p>Make an Amino acid dehydration molecular weights dictionary</p><pre>amino_acid_weights = {<br>    &#39;A&#39;: 89.09 - 18.015, &#39;R&#39;: 174.20 - 18.015, &#39;N&#39;: 132.12 - 18.015, &#39;D&#39;: 133.10 - 18.015, &#39;C&#39;: 121.16 - 18.015,<br>    &#39;E&#39;: 147.13 - 18.015, &#39;Q&#39;: 146.15 - 18.015, &#39;G&#39;: 75.07 - 18.015, &#39;H&#39;: 155.16 - 18.015, &#39;I&#39;: 131.18 - 18.015,<br>    &#39;L&#39;: 131.18 - 18.015, &#39;K&#39;: 146.19 - 18.015, &#39;M&#39;: 149.21 - 18.015, &#39;F&#39;: 165.19 - 18.015, &#39;P&#39;: 115.13 - 18.015,<br>    &#39;S&#39;: 105.09 - 18.015, &#39;T&#39;: 119.12 - 18.015, &#39;W&#39;: 204.23 - 18.015, &#39;Y&#39;: 181.19 - 18.015, &#39;V&#39;: 117.15 - 18.015<br>}</pre><p>Let the user input the amino acid sequence</p><pre>def add_entry():<br>    entry_var = tk.StringVar()<br>    entry = tk.Entry(frame, textvariable=entry_var)<br>    entry.grid(row=len(entry_widgets) + 1, column=0, pady=5)<br>    entry_widgets.append(entry_var)</pre><p>Define combination function, calculate all combinations of amino acids’ molecular weights</p><pre>def generate_combinations():</pre><p>This function contains the following code</p><pre>def generate_combinations():<br>input_list = [entry_var.get().strip().upper() for entry_var in entry_widgets if entry_var.get().strip().upper() in amino_acid_weights]<br><br>all_combinations = []<br>all_sums = []<br><br># Generate all possible combinations of the input list<br>for r in range(1, len(input_list) + 1):<br>combinations = itertools.combinations(input_list, r)<br>all_combinations.extend(combinations)<br><br># Calculate the sum of each combination<br>for combination in all_combinations:<br>combination_sum = sum(amino_acid_weights[aa] for aa in combination)+18.015 #the final calculated result should plus one H2O molecular weight<br>all_sums.append(combination_sum)</pre><h4>Notes and possible changes:</h4><p>This program only includes 20 amino acids found in nature. In the future, users will be able to enter the codes and molecular weights of non-natural amino acids.</p><p>The complete code is in my GitHub:</p><p><a href="https://github.com/turtle002/Combination/blob/main/Amino%20acid%20Combination%20Calculator">https://github.com/turtle002/Combination/blob/main/Amino acid Combination Calculator</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5615c0630ba4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Extract HPLC Data into Excel using python]]></title>
            <link>https://medium.com/@jaylanchunjaturtle/extract-hplc-data-into-excel-using-python-5d233b410582?source=rss-20d88a49aa26------2</link>
            <guid isPermaLink="false">https://medium.com/p/5d233b410582</guid>
            <category><![CDATA[excel]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[hplc]]></category>
            <category><![CDATA[txt]]></category>
            <dc:creator><![CDATA[Python Project for Chemistry]]></dc:creator>
            <pubDate>Wed, 25 Sep 2024 03:12:35 GMT</pubDate>
            <atom:updated>2024-09-25T03:16:03.730Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="https://microbenotes.com/" src="https://cdn-images-1.medium.com/max/766/1*3Wo7CepIxuRD9i5PthOwxA.jpeg" /><figcaption>Photo From: <a href="https://microbenotes.com/">https://microbenotes.com/</a></figcaption></figure><p>As a chemist, I often use HPLC (high-performance liquid chromatography) to monitor synthesis processes. In my daily job, I have to take HPLC data to analyze and record all the peaks. Traditionally, I printed HPLC spectra manually and entered the file data manually. This process took me too much time, and I often made mistakes because I should have recorded too many peaks.</p><p>I realized that if I could automate this process it would save a lot of time and record the data correctly. Therefore, I exported the selected data from the HPLC instrument in txt file format and then built a small program using chatgpt to extract the context (text and numbers). These extracted contexts will be imported into Excel. This feature allows me to log data correctly and save time.</p><p>Let’s look what I did.</p><p>The txt file can be generated from HPLC. The program can import multiple txt files into an excel, the data in the txt files will be extracted and arrange neatly.</p><p>The result is right here:</p><p>Multiple txt files containing information such as sample name, retention time (RT) and % area.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/271/1*e_twVqIxRsWtims5bNIpJg.png" /></figure><p>Extract data into Excel</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ett8GUJkh3bfshyC9vNcOw.png" /></figure><p>Here is the code:</p><pre>import pandas as pd<br>from tkinter import Tk, filedialog<br>import os<br><br>def import_and_export_text_files():<br>    # Hide the root window<br>    root = Tk()<br>    root.withdraw()<br><br>    # Ask the user to select multiple text files<br>    file_paths = filedialog.askopenfilenames(title=&quot;Select Text Files&quot;, filetypes=[(&quot;Text files&quot;, &quot;*.txt&quot;)])<br><br>    if not file_paths:<br>        print(&quot;No files selected.&quot;)<br>        return<br><br>    # Ask the user to select the export directory<br>    export_dir = filedialog.askdirectory(title=&quot;Select Export Directory&quot;)<br><br>    if not export_dir:<br>        print(&quot;No export directory selected.&quot;)<br>        return<br><br>    # Define the output file path with a default name<br>    export_path = os.path.join(export_dir, &quot;combined_output_transposed.xlsx&quot;)<br><br>    # List to store all data for concatenation<br>    all_data = []<br><br>    for file_path in file_paths:<br>        try:<br>            # Read the full text file into a list to capture header and data<br>            with open(file_path, &#39;r&#39;) as file:<br>                lines = file.readlines()<br><br>            # Extract header information (first 2 lines: Sample Name and Peak Results)<br>            sample_name = lines[0].strip()<br>            peak_results = lines[1].strip()<br><br>            # Create a DataFrame for the numerical data starting from line 4<br>            data = pd.read_csv(<br>                file_path,<br>                delimiter=&quot;\t&quot;,  # Assuming tab-delimited data<br>                header=2,  # Skip first two lines<br>                skipinitialspace=True,  # Remove leading/trailing spaces<br>                names=[&quot;RT&quot;, &quot;% Area&quot;]  # Define column names<br>            )<br><br>            # Transpose the data (switch rows and columns)<br>            transposed_data = data.T.reset_index()<br><br>            # Rename the columns after transposition<br>            transposed_data.columns = [&quot;Metric&quot;] + [f&quot;Row {i+1}&quot; for i in range(transposed_data.shape[1] - 1)]<br><br>            # Create a DataFrame for the header (Sample Name and Peak Results)<br>            header_df = pd.DataFrame({<br>                &quot;Header&quot;: [&quot;Sample Name&quot;, &quot;Peak Results&quot;],<br>                &quot;Value&quot;: [sample_name, peak_results]<br>            })<br><br>            # Add a blank row between different file imports<br>            blank_row = pd.DataFrame([[&quot;&quot;, &quot;&quot;]], columns=[&quot;Header&quot;, &quot;Value&quot;])<br><br>            # Combine the header and the transposed data<br>            combined_df = pd.concat([header_df, blank_row, transposed_data])<br><br>            # Append to the list<br>            all_data.append(combined_df)<br><br>        except Exception as e:<br>            print(f&quot;Error reading {file_path}: {e}&quot;)<br><br>    if all_data:<br>        # Concatenate all data into one DataFrame<br>        final_df = pd.concat(all_data, ignore_index=True)<br><br>        # Save the final DataFrame to a single Excel file<br>        try:<br>            final_df.to_excel(export_path, index=False, engine=&#39;openpyxl&#39;)<br>            print(f&quot;All data successfully exported to {export_path}&quot;)<br>        except Exception as e:<br>            print(f&quot;Error saving file: {e}&quot;)<br>    else:<br>        print(&quot;No data was imported.&quot;)<br><br>if __name__ == &quot;__main__&quot;:<br>    import_and_export_text_files()</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5d233b410582" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Extract PDF Tables to Excel using pdfplumber]]></title>
            <link>https://medium.com/@jaylanchunjaturtle/extract-pdf-tables-to-excel-using-pdfplumber-step-by-step-1e46051e8593?source=rss-20d88a49aa26------2</link>
            <guid isPermaLink="false">https://medium.com/p/1e46051e8593</guid>
            <category><![CDATA[exccel]]></category>
            <category><![CDATA[pdf]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[data-analysis]]></category>
            <dc:creator><![CDATA[Python Project for Chemistry]]></dc:creator>
            <pubDate>Sat, 21 Sep 2024 06:54:40 GMT</pubDate>
            <atom:updated>2024-09-21T06:57:52.010Z</atom:updated>
            <content:encoded><![CDATA[<p>In my daily work, I often need to collect information from PDF files. If I want to use the data in the table to perform calculations, a convenient way is to extract the PDF data to Excel. Today, I want to show you how to extract the PDF data o Excel using <strong>pdfplumber</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DWEcVc8_IInhoxkI1fe18g.png" /></figure><p>The complete code with the annotation is right here:</p><pre>import pdfplumber<br>import pandas as pd<br>import os<br>from tkinter import Tk<br>from tkinter.filedialog import askdirectory<br><br># Hide the root Tkinter window<br>Tk().withdraw()<br><br># Prompt the user to select a directory for saving Excel files<br>save_directory = askdirectory(title=&quot;Select Directory to Save Excel Files&quot;)<br><br># Replace with the path to your PDF file<br>pdf_path = &quot;C:/Users/Desktop/Test.pdf&quot;<br><br># Open the PDF file<br>with pdfplumber.open(pdf_path) as pdf:<br>    for i, page in enumerate(pdf.pages):<br>        # Extract tables from each page<br>        tables = page.extract_tables()<br><br>        # Loop through each table found on the page<br>        for j, table in enumerate(tables):<br>            # Convert the table to a DataFrame<br>            df = pd.DataFrame(table)<br><br>            # Construct the file path to save the Excel file<br>            save_path = os.path.join(save_directory, f&quot;table_page_{i+1}_table_{j+1}.xlsx&quot;)<br><br>            # Save the DataFrame to an Excel file<br>            df.to_excel(save_path, index=False)<br><br>print(&quot;Tables have been extracted and saved to Excel files in the selected directory.&quot;)</pre><p>Let’s explain this code step by step</p><h4>1. Importing Libraries</h4><pre>import pdfplumber<br>import pandas as pd<br>import os<br>from tkinter import Tk<br>from tkinter.filedialog import askdirectory</pre><ul><li><strong>pdfplumber</strong>: This library is used to open and extract data (like tables) from PDF files.</li><li><strong>pandas</strong>: This is a popular library for data manipulation, and we use it to convert tables into a DataFrame and save them as Excel files.</li><li><strong>os</strong>: The os module provides functions for interacting with the operating system, particularly for managing file paths.</li><li><strong>Tk and </strong><strong>askdirectory from </strong><strong>tkinter</strong>: Tkinter is a Python library for creating graphical user interfaces (GUIs). Here, it&#39;s used to create a dialog box for selecting a folder to save the Excel files.</li></ul><h4>2. Hiding the Tkinter Root Window</h4><pre>Tk().withdraw()</pre><p>Purpose: The Tk() creates a basic window for Tkinter, but since we don’t want to display any window except the file dialog, withdraw() hides it.</p><h4>3. Selecting the Save Directory</h4><pre>save_directory = askdirectory(title=&quot;Select Directory to Save Excel Files&quot;)</pre><ul><li><strong>askdirectory()</strong>: This opens a dialog box where the user can choose a folder to save the Excel files.</li><li><strong>Result</strong>: Once the user selects a folder, the chosen directory’s path (a string) is stored in the save_directory variable.</li></ul><h4>4. PDF File Path</h4><pre>pdf_path = &quot;C:\\Users\\python projects\\example.pdf&quot;</pre><p>This is the path to the PDF file you want to process. Replace it with the path to your own PDF file.</p><h4>5. Open the PDF File</h4><pre>with pdfplumber.open(pdf_path) as pdf:</pre><ul><li><strong>pdfplumber.open(pdf_path)</strong>: This opens the PDF file specified by pdf_path.</li><li><strong>with statement</strong>: This ensures that the PDF file is properly closed after processing. The opened PDF file object is stored in the pdf variable.</li></ul><h4>6. Loop Through Each Page in the PDF</h4><pre>for i, page in enumerate(pdf.pages):</pre><ul><li><strong>pdf.pages</strong>: This retrieves all the pages in the PDF.</li><li><strong>enumerate()</strong>: This function provides both the index (i) and the page object (page) as we loop through each page. i is the page number starting from 0, and page represents each page in the PDF.</li></ul><h4>7. Extract Tables from the Page</h4><pre>tables = page.extract_tables()</pre><p><strong>page.extract_tables():</strong> This method extracts any tables found on the current page. The result is a list of tables. Each table is itself a list of rows, where each row is a list of cells (usually strings or numbers).</p><h4>8. Loop Through the Extracted Tables</h4><pre>for i, page in enumerate(pdf.pages):</pre><ul><li><strong>enumerate(tables)</strong>: Loops through each table on the current page, providing both the index (j) and the table object (table).</li><li><strong>Result</strong>: This allows us to process each table found on the page.</li></ul><h4>9. Convert Table to DataFrame</h4><pre>df = pd.DataFrame(table)</pre><p><strong>pd.DataFrame(table):</strong> Converts the extracted table into a pandas DataFrame. A DataFrame is a two-dimensional, tabular data structure that’s well-suited for saving to an Excel file.</p><h4>10. Construct the File Path for Saving the Excel File</h4><pre>save_path = os.path.join(save_directory, f&quot;table_page_{i+1}_table_{j+1}.xlsx&quot;)</pre><ul><li><strong>os.path.join()</strong>: This function combines the directory path stored in save_directory with the Excel file name.</li><li><strong>f&quot;table_page_{i+1}_table_{j+1}.xlsx&quot;</strong>: This is a formatted string that creates a unique file name for each table.</li><li><em>i+1 is the page number (starting from 1).</em></li><li><em>j+1 is the table number on that page (starting from 1).</em></li><li><em>The file name will be something like </em><em>table_page_1_table_1.xlsx, </em><em>table_page_1_table_2.xlsx, etc.</em></li><li><strong>save_path</strong>: This is the full path (directory + file name) where the Excel file will be saved.</li></ul><h4>11. Save the DataFrame as an Excel File</h4><pre>df.to_excel(save_path, index=False)</pre><ul><li><strong>df.to_excel(save_path, index=False)</strong>: This saves the DataFrame df to an Excel file at the location specified by save_path.</li><li><strong>index=False</strong>: This ensures that the row numbers are not included in the saved Excel file.</li></ul><h4>12. Final Message</h4><pre>print(&quot;Tables have been extracted and saved to Excel files.&quot;)</pre><p>This prints a confirmation message once the extraction and saving process is completed.</p><h3>Summary</h3><ol><li>It opens the PDF file specified by pdf_path.</li><li>For each page in the PDF, it attempts to extract tables. Each table is converted into a pandas DataFrame.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1e46051e8593" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Operate AiZynthFinder to perform retrosynthesis with Colab]]></title>
            <link>https://medium.com/@jaylanchunjaturtle/operate-aizynthfinder-to-perform-retrosynthesis-with-colab-5b2938ef59ef?source=rss-20d88a49aa26------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b2938ef59ef</guid>
            <category><![CDATA[aizynthfinder]]></category>
            <category><![CDATA[retrosynthesis]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Python Project for Chemistry]]></dc:creator>
            <pubDate>Sat, 20 Apr 2024 04:59:32 GMT</pubDate>
            <atom:updated>2024-04-20T04:59:32.908Z</atom:updated>
            <content:encoded><![CDATA[<p>Today, I want to show you how to use AiZynthFinder, which is a powerful retrosynthesis solftware, with Colab step-by-step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-hxbeAB5IKH-MSm9rjLXvg.png" /><figcaption>This image is from: <a href="https://github.com/MolecularAI/aizynthfinder">https://github.com/MolecularAI/aizynthfinder</a></figcaption></figure><p>Let me simply introduce first</p><p>In the realm of chemistry, synthesis planning is the crucial process of figuring out how to create a specific compound. Traditionally, chemists would break down the target compound into smaller, purchasable building blocks through retrosynthetic analysis. However, with the advancement of technology, particularly in deep learning, retrosynthetic software tools have undergone significant evolution. This has led to the development of sophisticated algorithms capable of providing more accurate and broader retrosynthetic analysis.</p><p>These tools can be categorized into two main approaches: template-based and template-free. Template-based methods rely on predefined reaction templates or rules, while template-free methods approach chemical reactions more flexibly, often treating them as linguistic transformations or utilizing graph-based methods.</p><p>Despite the availability of several tools for retrosynthesis planning, only a few are fully open source. Many are hindered by reliance on commercial reaction databases and limited access to purchasable precursors. To address these challenges, the AiZynthFinder tool is introduced as an open-source solution. This tool, an improved version of previous work, offers a trained neural network policy and supports the creation of precursor databases. The goal is to provide a transparent and accessible platform for collaborative development and synthetic route suggestions within the scientific community.</p><p>Let’s start to operate:</p><p>Step 1: Click the GitHub link: <a href="https://github.com/MolecularAI/aizynthfinder">https://github.com/MolecularAI/aizynthfinder</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UraS3SyEiHE8ul4f9zvlFg.png" /></figure><p>Step 2: Click ‘Open in Colab’</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cIkWzmA5iFeCSEqCb81mqQ.png" /></figure><p>You will see this page</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7xFxcSO6sXrRT8ebsMz8EQ.png" /></figure><p>Step 3: Click ‘Installation’ to install <strong>AiZynthFinder</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BwtM5DegL5xY_KC-BNDHpA.png" /></figure><p>It will take some time, and you will see the uploaded information:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ydV-OMI7bxtW0XYRHQvi-Q.png" /></figure><p>Sometimes you could get an incompatible error, in this case, you can click ‘RESTART SESSION’ to install new versions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FpQRKMI30it008rShFnkDQ.png" /></figure><p>Step 4: When the installation has been done, Click ‘Start application’, it will take some time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xjNgnx84pDSfliGs7oObaw.png" /></figure><p>If you are available to run, you can see the page:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g7m7uUPb83OSArErLjp9-g.png" /></figure><p>and now you can start to generate the retrosynthesis plan!</p><p>Step 5: Type the SMILES format of a compound you desired</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2d9cMnJhJACkQyJhCIYWAw.png" /></figure><p>If you type the correct SMILES format, you will see the chemistry structure</p><p>Step 6: Click ‘Run Search’, and it will take some time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fOLxR3MJUFr-9fBohQZZSg.png" /></figure><p>Step 7: Click ‘Show Reaction’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u3uIh8vAKVuvGmGzlpuKnw.png" /></figure><p>Finally, you can see the result.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x5JRMYMUuqNFV_O0gLe-wQ.png" /></figure><p>You can choose the different synthetic routes</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HvbQjVXuW-jFx-t_npuCgg.png" /></figure><p>The plan also gives you stock information of the precursors:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*By8lOCj8LOAAji1s0QLHvQ.png" /></figure><p>If you want to look details, you can visit the GitHub: <a href="https://github.com/MolecularAI/aizynthfinder">https://github.com/MolecularAI/aizynthfinder</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b2938ef59ef" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[As a chemist, I believe that learning coding helps to expand the field of chemistry]]></title>
            <link>https://medium.com/@jaylanchunjaturtle/as-a-chemist-i-believe-that-learning-coding-helps-to-expand-the-field-of-chemistry-a608d9910da5?source=rss-20d88a49aa26------2</link>
            <guid isPermaLink="false">https://medium.com/p/a608d9910da5</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[chemistry]]></category>
            <category><![CDATA[code]]></category>
            <dc:creator><![CDATA[Python Project for Chemistry]]></dc:creator>
            <pubDate>Fri, 19 Apr 2024 02:56:42 GMT</pubDate>
            <atom:updated>2024-04-19T02:56:42.494Z</atom:updated>
            <content:encoded><![CDATA[<p>I am a chemical researcher, always delving into the intricacies of organic synthesis. My days are filled with experiments, data analysis, and a continuous quest for innovation in my field. One day, I stumble upon Python, a powerful programming language, during my quest for new tools to enhance my research.</p><p>Curiosity sparks, and I delve into learning Python, intrigued by its potential to streamline data analysis and automate repetitive tasks in chemistry. I soon discover the synergy between Python and chemistry, where complex chemical structures can be represented and manipulated with ease using Python libraries.</p><p>As I delve deeper into Python, I begin to envision a future where this programming language will revolutionize the way chemical research is conducted. From predicting molecular structures to simulating chemical reactions, Python opens doors to new possibilities that were once constrained by manual calculations and traditional methods.</p><blockquote><strong>With Python by my side, I embark on a journey to bridge the gap between programming and chemistry.</strong></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a608d9910da5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python Foundation (2): Conditionals]]></title>
            <link>https://medium.com/@jaylanchunjaturtle/python-foundation-2-conditionals-a88c17a2e04e?source=rss-20d88a49aa26------2</link>
            <guid isPermaLink="false">https://medium.com/p/a88c17a2e04e</guid>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Python Project for Chemistry]]></dc:creator>
            <pubDate>Sun, 14 Apr 2024 03:47:06 GMT</pubDate>
            <atom:updated>2024-04-14T03:47:06.706Z</atom:updated>
            <content:encoded><![CDATA[<p>Conditions in Python are used to control the flow of a program based on certain conditions. They allow you to make decisions and execute different blocks of code depending on whether a condition is true or false. In Python, conditions are typically implemented using if statements, elif (else if) statements, and else statements. Here’s a detailed explanation along with an example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n2HqDKKX-7Z_00xc_l26Wg.jpeg" /></figure><h3>If Statement:</h3><p>The if statement is used to execute a block of code only if a specified condition is true.</p><h3>Syntax:</h3><pre>if condition:<br>    # Code block to be executed if condition is true</pre><h3>Example:</h3><pre># Check if a number is positive<br>num = 5<br>if num &gt; 0:<br>    print(&quot;The number is positive&quot;)</pre><h3>Elif Statement:</h3><p>The elif (else if) statement allows you to check multiple conditions. It is used when you want to check for more than one condition.</p><h3>Syntax:</h3><pre>if condition1:<br>    # Code block to be executed if condition1 is true<br>elif condition2:<br>    # Code block to be executed if condition2 is true<br>elif condition3:<br>    # Code block to be executed if condition3 is true<br># You can have multiple elif statements</pre><h3>Example:</h3><pre># Check if a number is positive, negative, or zero<br>num = -3<br>if num &gt; 0:<br>    print(&quot;The number is positive&quot;)<br>elif num &lt; 0:<br>    print(&quot;The number is negative&quot;)<br>else:<br>    print(&quot;The number is zero&quot;)</pre><h3>Else Statement:</h3><p>The else statement is used to execute a block of code if the preceding conditions in an if statement or elif statement are not true.</p><h3>Syntax:</h3><pre>if condition:<br>    # Code block to be executed if condition is true<br>else:<br>    # Code block to be executed if condition is false</pre><h3>Example:</h3><pre># Check if a number is positive or negative<br>num = -3<br>if num &gt; 0:<br>    print(&quot;The number is positive&quot;)<br>else:<br>    print(&quot;The number is negative&quot;)</pre><h3>Nested If Statements:</h3><p>You can also nest if statements inside other if statements to create more complex conditions.</p><h3>Example:</h3><pre># Check if a number is positive, negative, or zero using nested if statements<br>num = -3<br>if num &gt;= 0:<br>    if num == 0:<br>        print(&quot;The number is zero&quot;)<br>    else:<br>        print(&quot;The number is positive&quot;)<br>else:<br>    print(&quot;The number is negative&quot;)</pre><h3>Logical Operators:</h3><p>Python provides logical operators (and, or, not) that allow you to combine multiple conditions.</p><h3>Example:</h3><pre># Check if a number is between 10 and 20<br>num = 15<br>if num &gt; 10 and num &lt; 20:<br>    print(&quot;The number is between 10 and 20&quot;)</pre><h3>Comparison Operators:</h3><p>Comparison operators (==, !=, &lt;, &gt;, &lt;=, &gt;=) are used to compare values and evaluate conditions.</p><h3>Example:</h3><pre># Check if two numbers are equal<br>a = 5<br>b = 10<br>if a == b:<br>    print(&quot;The numbers are equal&quot;)<br>else:<br>    print(&quot;The numbers are not equal&quot;)</pre><h3>Let’s practice with a small project: a simple calculator</h3><p>Here’s a simple calculator program using if statements in Python. This calculator will perform addition, subtraction, multiplication, and division based on user input.</p><pre>def add(x, y):<br>    return x + y<br><br>def subtract(x, y):<br>    return x - y<br><br>def multiply(x, y):<br>    return x * y<br><br>def divide(x, y):<br>    if y != 0:<br>        return x / y<br>    else:<br>        return &quot;Cannot divide by zero!&quot;<br><br>def calculator():<br>    print(&quot;Welcome to Simple Calculator&quot;)<br>    print(&quot;Operations:&quot;)<br>    print(&quot;1. Addition&quot;)<br>    print(&quot;2. Subtraction&quot;)<br>    print(&quot;3. Multiplication&quot;)<br>    print(&quot;4. Division&quot;)<br><br>    choice = input(&quot;Enter choice (1/2/3/4): &quot;)<br><br>    num1 = float(input(&quot;Enter first number: &quot;))<br>    num2 = float(input(&quot;Enter second number: &quot;))<br><br>    if choice == &#39;1&#39;:<br>        print(&quot;Result:&quot;, add(num1, num2))<br>    elif choice == &#39;2&#39;:<br>        print(&quot;Result:&quot;, subtract(num1, num2))<br>    elif choice == &#39;3&#39;:<br>        print(&quot;Result:&quot;, multiply(num1, num2))<br>    elif choice == &#39;4&#39;:<br>        print(&quot;Result:&quot;, divide(num1, num2))<br>    else:<br>        print(&quot;Invalid choice&quot;)<br><br># Run the calculator<br>calculator()</pre><p>In this program:</p><ul><li>We define four functions add(), subtract(), multiply(), and divide() to perform addition, subtraction, multiplication, and division respectively.</li><li>We define the calculator() function where the program starts executing. It displays a menu of operations, prompts the user to enter their choice, and then asks for two numbers. Based on the user&#39;s choice, it calls the appropriate function to perform the calculation and displays the result.</li><li>We use if statements to check the user&#39;s choice and perform the corresponding operation.</li></ul><h3>Switch Statement</h3><p>In Python, there is no built-in switch statement like in some other programming languages such as C or Java. However, you can achieve similar functionality using various alternatives, such as using dictionaries, if-elif-else chains, or the match statement available in Python 3.10 and later versions.</p><h3>Using If-Elif-Else Chains:</h3><p>You can use if-elif-else chains to achieve similar functionality to a switch statement. This approach is straightforward and commonly used in Python.</p><h3>Example:</h3><pre>def switch_case(argument):<br>    if argument == 1:<br>        return &quot;One&quot;<br>    elif argument == 2:<br>        return &quot;Two&quot;<br>    elif argument == 3:<br>        return &quot;Three&quot;<br>    else:<br>        return &quot;Invalid argument&quot;<br><br># Example usage<br>result = switch_case(2)<br>print(result)  # Output: &quot;Two&quot;</pre><h3>Using Dictionaries:</h3><p>You can use dictionaries to map keys to corresponding values, similar to the cases in a switch statement.</p><h3>Example:</h3><pre>def switch_case(argument):<br>    switch_dict = {<br>        1: &quot;One&quot;,<br>        2: &quot;Two&quot;,<br>        3: &quot;Three&quot;,<br>    }<br>    return switch_dict.get(argument, &quot;Invalid argument&quot;)<br><br># Example usage<br>result = switch_case(3)<br>print(result)  # Output: &quot;Three&quot;</pre><h3>Using the Match Statement (Python 3.10+):</h3><p>Starting from Python 3.10, you can use the match statement to achieve pattern matching, which can be thought of as a more versatile replacement for the traditional switch statement.</p><h3>Example:</h3><pre>def switch_case(argument):<br>    match argument:<br>        case 1:<br>            return &quot;One&quot;<br>        case 2:<br>            return &quot;Two&quot;<br>        case 3:<br>            return &quot;Three&quot;<br>        case _:<br>            return &quot;Invalid argument&quot;<br><br># Example usage<br>result = switch_case(1)<br>print(result)  # Output: &quot;One&quot;</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a88c17a2e04e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python Foundation (1): Variables and Functions]]></title>
            <link>https://medium.com/@jaylanchunjaturtle/python-foundation-1-variables-and-functions-11fb85d4320b?source=rss-20d88a49aa26------2</link>
            <guid isPermaLink="false">https://medium.com/p/11fb85d4320b</guid>
            <dc:creator><![CDATA[Python Project for Chemistry]]></dc:creator>
            <pubDate>Fri, 12 Apr 2024 15:34:07 GMT</pubDate>
            <atom:updated>2024-04-12T15:34:07.320Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n2HqDKKX-7Z_00xc_l26Wg.jpeg" /></figure><h3>Variable</h3><p>Variables in Python are used to store data values. They act as placeholders that represent various types of data, such as numbers, strings, lists, dictionaries, etc. Here’s a more detailed explanation along with examples:</p><p><strong>Variable Naming Rules:</strong></p><ol><li>Variable names must start with a letter (a-z, A-Z) or an underscore (_).</li><li>The remainder of the variable name can contain letters, numbers, and underscores.</li><li>Variable names are case-sensitive.</li><li>Variable names cannot be Python keywords (reserved words).</li></ol><p><strong>Variable Assignment:</strong> In Python, you can assign values to variables using the assignment operator =. You don&#39;t need to declare the type of a variable explicitly; Python infers the type based on the value assigned to it.</p><p><strong>Example:</strong></p><pre>#Integer variable<br>age = 25<br><br>#String variable<br>name = &quot;John&quot;<br><br>#Float variable<br>height = 5.9</pre><p><strong>Data Types:</strong></p><p>Python supports several data types for variables. Some common ones include:</p><ol><li><strong>Integer (int)</strong>: Represents whole numbers.</li><li><strong>Float (float)</strong>: Represents decimal numbers.</li><li><strong>String (str)</strong>: Represents sequences of characters, enclosed within single (‘ ‘) or double (“ “) quotes.</li><li><strong>Boolean (bool)</strong>: Represents True or False values.</li><li><strong>List (list)</strong>: Represents ordered collections of items.</li><li><strong>Tuple (tuple)</strong>: Represents ordered, immutable collections of items.</li><li><strong>Dictionary (dict)</strong>: Represents key-value pairs.</li></ol><p><strong>Example:</strong></p><pre># Integer variable<br>age = 25<br><br># Float variable<br>height = 5.9<br><br># String variable<br>name = &quot;John&quot;<br><br># Boolean variable<br>is_student = True<br><br># List variable<br>fruits = [&quot;apple&quot;, &quot;banana&quot;, &quot;orange&quot;]<br><br># Tuple variable<br>coordinates = (3, 7)<br><br># Dictionary variable<br>person = {&quot;name&quot;: &quot;Alice&quot;, &quot;age&quot;: 30}</pre><p><strong>Variable Reassignment:</strong></p><p>You can change the value of a variable by simply assigning a new value to it.</p><pre>x = 5<br>print(x)  # Output: 5<br><br>x = 10  # Reassigning variable x<br>print(x)  # Output: 10</pre><p><strong>Variable Scope:</strong></p><p>The scope of a variable refers to the region of the program where the variable is accessible. In Python, variables can have either global or local scope.</p><ul><li><strong>Global Variables</strong>: Defined outside of any function. Accessible throughout the entire program.</li><li><strong>Local Variables</strong>: Defined within a function. Accessible only within that function.</li></ul><p><strong>Example:</strong></p><pre># Global variable<br>global_var = 10<br><br>def my_function():<br>    # Local variable<br>    local_var = 20<br>    print(&quot;Inside function:&quot;, global_var)  # Accessing global variable<br>    print(&quot;Inside function:&quot;, local_var)   # Accessing local variable<br><br>my_function()<br>print(&quot;Outside function:&quot;, global_var)     # Accessing global variable outside function<br>#print(&quot;Outside function:&quot;, local_var)    # This will raise an error as local_var is not accessible outside the function</pre><h3>Functions</h3><p>Functions in Python are blocks of reusable code that perform a specific task. They allow you to break down your code into smaller, manageable pieces, making it easier to read, understand, and maintain. Here’s a detailed explanation of functions along with an example:</p><p><strong>Defining a Function:</strong></p><p>In Python, you can define a function using the def keyword followed by the function name and parentheses (). If the function takes parameters, you can specify them within the parentheses.</p><p><strong>Example (Syntax):</strong></p><pre>def function_name(parameter1, parameter2, ...):<br>    # Code block<br>    # Perform specific tasks<br>    # Optionally, return a value</pre><p><strong>Calling a Function:</strong></p><p>To execute the code inside a function, you need to call it by using its name followed by</p><p>parentheses ().</p><p><strong>Example (Syntax):</strong></p><pre>function_name(argument1, argument2, ...)</pre><h3>Example:</h3><p>Let’s create a simple function that takes two numbers as parameters and returns their sum.</p><pre># Define a function to add two numbers<br>def add_numbers(a, b):<br>    sum_result = a + b<br>    return sum_result<br><br># Call the function and store the returned value<br>result = add_numbers(3, 5)<br><br># Print the result<br>print(&quot;The sum is:&quot;, result)</pre><h3>Explanation:</h3><ol><li>We define a function named add_numbers that takes two parameters a and b.</li><li>Inside the function, we calculate the sum of a and b and store it in a variable sum_result.</li><li>We use the return statement to return the value of sum_result back to the caller.</li><li>We call the add_numbers function with arguments 3 and 5, and the returned result is stored in the variable result.</li><li>Finally, we print the result.</li></ol><h3>Function Parameters:</h3><p>Functions can take zero or more parameters. Parameters are placeholders for the values that are passed to the function when it is called. These values are called arguments.</p><h3>Example with Default Parameter:</h3><p>You can also provide default values for function parameters. If a value is not provided when the function is called, the default value will be used.</p><pre># Define a function with default parameter<br>def greet(name=&quot;Guest&quot;):<br>    print(&quot;Hello,&quot;, name)<br><br># Call the function without providing an argument<br>greet()  # Output: Hello, Guest<br><br># Call the function with an argument<br>greet(&quot;Alice&quot;)  # Output: Hello, Alice</pre><h3>Return Statement:</h3><p>Functions can return values using the return statement. A function can have multiple return statements, but as soon as a return statement is executed, the function exits, and no further code is executed.</p><h3>Example with Multiple Return Statements:</h3><pre># Define a function to check if a number is positive, negative, or zero<br>def check_number(num):<br>    if num &gt; 0:<br>        return &quot;Positive&quot;<br>    elif num &lt; 0:<br>        return &quot;Negative&quot;<br>    else:<br>        return &quot;Zero&quot;<br><br># Call the function and print the result<br>print(check_number(5))   # Output: Positive<br>print(check_number(-3))  # Output: Negative<br>print(check_number(0))   # Output: Zero</pre><h3>Scope of Variables:</h3><p>Variables defined inside a function are local to that function and cannot be accessed from outside. Similarly, variables defined outside of any function are global and can be accessed from anywhere within the program.</p><h3>Example:</h3><pre># Global variable<br>global_var = 10<br><br># Define a function<br>def my_function():<br>    # Local variable<br>    local_var = 20<br>    print(&quot;Inside function:&quot;, global_var)  # Accessing global variable<br>    print(&quot;Inside function:&quot;, local_var)   # Accessing local variable<br><br># Call the function<br>my_function()<br>print(&quot;Outside function:&quot;, global_var)  # Accessing global variable outside function<br>#print(&quot;Outside function:&quot;, local_var)   # This will raise an error as local_var is not accessible outside the function</pre><h3>Nested Functions:</h3><p>Python allows defining functions inside other functions. These are called nested functions. The inner functions have access to the variables of the outer function.</p><h3>Example:</h3><pre># Define an outer function<br>def outer_function():<br>    x = 10<br><br>    # Define an inner function<br>    def inner_function():<br>        print(&quot;Inside inner function:&quot;, x)  # Accessing variable from outer function<br>    <br>    # Call the inner function<br>    inner_function()<br><br># Call the outer function<br>outer_function()</pre><h3>Lambda Functions (Anonymous Functions):</h3><p>Lambda functions are small, anonymous functions defined using the lambda keyword. They can have any number of parameters but can only have one expression.</p><h3>Example:</h3><pre># Define a lambda function to square a number<br>square = lambda x: x**2<br><br># Call the lambda function<br>result = square(5)<br>print(&quot;Square of 5:&quot;, result)  # Output: 25</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=11fb85d4320b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>