<?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 Minhazul Hasan Sohan on Medium]]></title>
        <description><![CDATA[Stories by Minhazul Hasan Sohan on Medium]]></description>
        <link>https://medium.com/@minhazulhasansohan?source=rss-e6d90bce461b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*FsgnE4dVraKw3Kxkjk1nuA.jpeg</url>
            <title>Stories by Minhazul Hasan Sohan on Medium</title>
            <link>https://medium.com/@minhazulhasansohan?source=rss-e6d90bce461b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 16:46:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@minhazulhasansohan/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[Biopython: Protein shapes and Phylogenetic trees — Part 3]]></title>
            <link>https://medium.com/analytics-vidhya/biopython-protein-shapes-and-phylogenetic-trees-part-3-0dceb7892ac6?source=rss-e6d90bce461b------2</link>
            <guid isPermaLink="false">https://medium.com/p/0dceb7892ac6</guid>
            <category><![CDATA[biopython]]></category>
            <category><![CDATA[python-for-bioinformatics]]></category>
            <category><![CDATA[bioinformatics]]></category>
            <category><![CDATA[phylogenetics]]></category>
            <category><![CDATA[computational-biology]]></category>
            <dc:creator><![CDATA[Minhazul Hasan Sohan]]></dc:creator>
            <pubDate>Mon, 27 Jul 2026 06:28:13 GMT</pubDate>
            <atom:updated>2026-07-27T06:28:13.953Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G6tv_CR19hGVBlD_Fyvd5g.png" /></figure><p>So far everything in this series has been flat. Sequences are just letters in a row, and even alignment and BLAST are really about comparing rows of letters. That’s most of the day-to-day work, but it leaves out two things that, honestly, are the reason a lot of us got into this in the first place: the actual three-dimensional shape of a protein, and the tree of how living things are related.</p><p>This part is about both. It’s the part that feels least like spreadsheets and most like biology.</p><p>Still on Biopython 1.87.</p><h3>Bio.PDB: proteins in three dimensions</h3><p>A protein is a chain of amino acids, but it doesn’t stay a straight chain. It folds into a specific 3D shape, and that shape is the whole point. The shape makes the pockets and surfaces that let a protein grab other molecules and do its job. If you want to understand how an enzyme works, or why a mutation causes disease, or whether a drug will fit, you’re really asking about shape.</p><p>Structures get measured in labs and deposited in the Protein Data Bank. A PDB file is a plain text file that lists every atom and where it sits in space, as x, y, z coordinates. There’s an older .pdb format and a newer .cif one; Biopython reads both, with PDBParser and MMCIFParser respectively.</p><p>Normally you’d grab a real structure by its four-letter ID:</p><pre>from Bio.PDB import PDBList<br><br>pdbl = PDBList()<br>pdbl.retrieve_pdb_file(&quot;1CRN&quot;, pdir=&quot;.&quot;, file_format=&quot;pdb&quot;)</pre><p>That needs internet, and I want the parsing to be the star here, so I’ll use a tiny hand-made protein instead. Three amino acids, that’s it. Everything you learn on it works identically on a real 30,000-atom structure.</p><p>And a reminder that has burned me more than once across this series: <strong>you have to create the file before you read it.</strong> So we write it first.</p><pre>pdb_text = &quot;&quot;&quot;ATOM      1  N   GLY A   1       0.000   0.000   0.000  1.00  0.00           N<br>ATOM      2  CA  GLY A   1       1.500   0.000   0.000  1.00  0.00           C<br>ATOM      3  C   GLY A   1       2.000   1.400   0.000  1.00  0.00           C<br>ATOM      4  O   GLY A   1       1.300   2.400   0.000  1.00  0.00           O<br>ATOM      5  N   ALA A   2       3.300   1.500   0.000  1.00  0.00           N<br>ATOM      6  CA  ALA A   2       4.000   2.800   0.000  1.00  0.00           C<br>ATOM      7  C   ALA A   2       5.500   2.700   0.000  1.00  0.00           C<br>ATOM      8  O   ALA A   2       6.100   1.600   0.000  1.00  0.00           O<br>ATOM      9  CB  ALA A   2       3.600   3.600   1.200  1.00  0.00           C<br>ATOM     10  N   SER A   3       6.200   3.800   0.000  1.00  0.00           N<br>ATOM     11  CA  SER A   3       7.600   3.900   0.000  1.00  0.00           C<br>ATOM     12  C   SER A   3       8.100   5.300   0.000  1.00  0.00           C<br>ATOM     13  O   SER A   3       7.400   6.300   0.000  1.00  0.00           O<br>ATOM     14  CB  SER A   3       8.200   3.100   1.200  1.00  0.00           C<br>ATOM     15  OG  SER A   3       9.600   3.200   1.200  1.00  0.00           O<br>END<br>&quot;&quot;&quot;<br><br>with open(&quot;prot.pdb&quot;, &quot;w&quot;) as f:<br>    f.write(pdb_text)</pre><p>Quick note on those columns, since they look like noise at first. Each ATOM line is one atom: a serial number, the atom name (N, CA, C, O are the backbone atoms every residue has; CB and beyond are the side chain), the amino acid it belongs to (GLY, ALA, SER), the chain (A), the residue number, and then the important part, the x, y, z position. That&#39;s why glycine has only 4 atoms here and serine has 6: glycine has no side chain, serine has a bigger one.</p><p>Now parse it:</p><pre>from Bio.PDB import PDBParser<br><br>parser = PDBParser(QUIET=True)   # QUIET hides harmless warnings<br>structure = parser.get_structure(&quot;myprotein&quot;, &quot;prot.pdb&quot;)</pre><h3>The hierarchy is the whole thing</h3><p>A parsed structure is organised in five nested levels, and once this clicks the rest is easy:</p><p><strong>Structure → Model → Chain → Residue → Atom</strong></p><p>I think of it like a postal address, big to small. The structure is the whole thing. A model is one complete 3D snapshot (usually just one, called Model 0; some lab methods capture the protein wobbling and store several). A chain is one protein strand, labelled A, B, C. A residue is one amino acid. An atom is one atom. To find a single atom, you walk down the levels.</p><p>You can walk the whole thing with nested loops:</p><pre>for model in structure:<br>    for chain in model:<br>        print(&quot;chain&quot;, chain.id)<br>        for residue in chain:<br>            print(&quot;  &quot;, residue.get_resname(), residue.id[1])</pre><pre>chain A<br>   GLY 1<br>   ALA 2<br>   SER 3</pre><h3>Pulling out one atom, and measuring distances</h3><p>You don’t always want to loop. You can jump straight to an atom by its address:</p><pre>ca1 = structure[0][&quot;A&quot;][1][&quot;CA&quot;]<br>ca3 = structure[0][&quot;A&quot;][3][&quot;CA&quot;]<br><br>print(&quot;CA of residue 1:&quot;, ca1.coord)<br>print(&quot;CA of residue 3:&quot;, ca3.coord)</pre><pre>CA of residue 1: [1.5 0.  0. ]<br>CA of residue 3: [7.6 3.9 0. ]</pre><p>Read the brackets left to right: model 0, chain A, residue 1, atom CA. (CA is the alpha carbon, the central backbone atom of each amino acid, and it&#39;s what people usually use to stand in for the overall shape.)</p><p>And here’s the payoff of having real coordinates. To get the distance between two atoms, you subtract them. That’s it. Biopython does the 3D maths.</p><pre>print(&quot;distance:&quot;, round(ca1 - ca3, 3), &quot;Angstroms&quot;)</pre><pre>distance: 7.24 Angstroms</pre><p>Angstroms are the tiny unit atoms are measured in. Neighbouring backbone atoms sit about 3.8 apart, so two residues apart landing near 7 feels about right. This sounds like a toy, but measuring distances is genuinely how you find which parts of a protein are close together in space even when they’re far apart in the sequence, which is how active sites and binding pockets get spotted.</p><h3>The honest bit about pictures</h3><p>Here’s something that confused me, so I’ll save you the confusion. When you picture a “protein structure,” you probably picture one of those gorgeous ribbon diagrams. Biopython does <strong>not</strong> make those. It reads the coordinates and does the maths, and that’s its job. It is not a rendering program.</p><p>If you want the pretty picture, that’s a different tool. The easiest one inside a notebook is py3Dmol (pip install py3Dmol), which shows a rotatable 3D view right there:</p><pre>import py3Dmol<br><br>view = py3Dmol.view(query=&quot;pdb:1CRN&quot;)<br>view.setStyle({&quot;cartoon&quot;: {&quot;color&quot;: &quot;spectrum&quot;}})<br>view.zoomTo()<br>view.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/911/1*JR9YQnhmgm0y3ZcEP0c8aQ.png" /></figure><p>For publication-quality figures people reach for PyMOL, ChimeraX, or the Mol* website. The mental split that helped me: Biopython is for reading and measuring, the other tools are for drawing. Don’t wait around for Biopython to hand you a ribbon diagram, because it never will.</p><h3>Bio.Phylo: the tree of who’s related to whom</h3><p>The other big idea is the phylogenetic tree. It’s a family tree, but for species (or genes). It shows who shares a common ancestor with whom, and roughly how far back. You and a cousin share grandparents; you and a stranger share some very distant ancestor. Species work the same way, and the tree draws it.</p><p>Trees get stored in a format called Newick, which looks cryptic until someone explains the four symbols, so here they are. Names are the tips (the species). Parentheses group things that share an ancestor. Commas separate members of a group. A colon and a number give a branch length, meaning how much change happened along that branch. A semicolon ends the tree.</p><p>The rule to remember: the more deeply nested together two things are, the more closely related they are.</p><p>Here’s a small tree of four primates. Create the file first (you know the drill by now):</p><pre>with open(&quot;primates.nwk&quot;, &quot;w&quot;) as f:<br>    f.write(&quot;(((Human:0.1,Chimp:0.1):0.05,Gorilla:0.15):0.1,Orangutan:0.3);&quot;)</pre><p>Phylo.read for one tree, Phylo.parse for a file with many. Same &quot;one vs many&quot; split as SeqIO from Part 1.</p><h3>Drawing it in the terminal</h3><p>My favourite thing here is draw_ascii, which draws the tree with plain text characters. No graphics library, no image file, works over SSH, works anywhere:</p><pre>from Bio import Phylo<br><br>tree = Phylo.read(&quot;primates.nwk&quot;, &quot;newick&quot;)<br><br>Phylo.draw_ascii(tree)</pre><pre>                                     _____________________ Human<br>                         ___________|<br>   _____________________|           |_____________________ Chimp<br>  |                     |<br>__|                     |_________________________________ Gorilla<br>  |<br>  |____________________________________________________________ Orangutan</pre><p>Read it and it tells the right story. Human and Chimp join first, so they’re closest. Then Gorilla joins that group. Orangutan sits off on its own long branch, the most distant of the four. Which is exactly what the biology says, and it fell straight out of that one line of Newick.</p><p>For a proper picture (like the one above), use Phylo.draw with matplotlib.</p><pre>import matplotlib.pyplot as plt<br>from Bio import Phylo<br><br>tree = Phylo.read(&quot;primates.nwk&quot;, &quot;newick&quot;)<br><br>fig = plt.figure(figsize=(8, 5))<br>ax = fig.add_subplot(111)<br>Phylo.draw(tree, axes=ax)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*yJ3-XVad4kj49bJxGU4IfA.png" /></figure><h3>Asking the tree questions</h3><p>You can poke at it too:</p><pre>print(&quot;species:&quot;, tree.count_terminals())<br><br>for tip in tree.get_terminals():<br>    print(&quot;  &quot;, tip.name)<br><br>print(&quot;internal nodes:&quot;, len(tree.get_nonterminals()))<br>print(&quot;total branch length:&quot;, tree.total_branch_length())</pre><pre>species: 4<br>   Human<br>   Chimp<br>   Gorilla<br>   Orangutan<br>internal nodes: 3<br>total branch length: 0.8</pre><p>Two kinds of points on a tree: the tips you can see (the terminals, today’s species) and the internal nodes where branches split (the non-terminals, the ancestors). Four species, three ancestor split-points.</p><p>When you want an actual figure instead of text art, Phylo.draw(tree) renders a proper graphical tree with matplotlib, with branch lengths drawn to scale. Nice for a paper or a slide.</p><h3>Almost done</h3><p>That’s structures and trees. Between the three parts so far, you can handle sequences, compare them, identify them, poke around inside 3D structures, and map out evolutionary relationships.</p><p>If you catch a mistake or know a slicker way, tell me. Still learning, always.</p><p>Link to part 1 and 2 is as follows:</p><ul><li><a href="https://minhazulhasansohan.medium.com/the-biopython-basics-i-use-in-almost-every-script-part-01-9ffaab12e2bf">The Biopython basics I use in almost every script — Part 01</a></li><li><a href="https://minhazulhasansohan.medium.com/biopython-comparing-sequences-and-finding-out-what-they-are-part-02-a84fa8c7cce3">Biopython: Comparing sequences and finding out what they are — Part 02</a></li></ul><p>Stay Safe! ❤️🖤</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0dceb7892ac6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/biopython-protein-shapes-and-phylogenetic-trees-part-3-0dceb7892ac6">Biopython: Protein shapes and Phylogenetic trees — Part 3</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Biopython: Comparing sequences and finding out what they are — Part 02]]></title>
            <link>https://medium.com/analytics-vidhya/biopython-comparing-sequences-and-finding-out-what-they-are-part-02-a84fa8c7cce3?source=rss-e6d90bce461b------2</link>
            <guid isPermaLink="false">https://medium.com/p/a84fa8c7cce3</guid>
            <category><![CDATA[bioinformatics-tools]]></category>
            <category><![CDATA[bioinformatics]]></category>
            <category><![CDATA[computational-biology]]></category>
            <category><![CDATA[python-for-bioinformatics]]></category>
            <category><![CDATA[biopython]]></category>
            <dc:creator><![CDATA[Minhazul Hasan Sohan]]></dc:creator>
            <pubDate>Fri, 24 Jul 2026 09:16:33 GMT</pubDate>
            <atom:updated>2026-07-27T06:29:54.197Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AZFrfGGsELGZ9MoIpUzNNw.png" /></figure><p><a href="https://medium.com/@minhazulhasansohan/the-biopython-basics-i-use-in-almost-every-script-part-01-9ffaab12e2bf?sharedUserId=minhazulhasansohan"><strong>Part 1</strong> </a>was all about handling one sequence at a time: read it, translate it, save it, download it. Useful, but a bit lonely. One sequence sitting by itself doesn’t tell you much.</p><p>The interesting questions start when you have two. How similar are these two genes? Did they come from a common ancestor? And the big one: I’ve got this sequence and I have no idea what it is, so what does it match?</p><p>That’s alignment and BLAST. This is where it starts to feel like actual biology instead of file wrangling.</p><p>Same setup as before, I’m on Biopython 1.87.</p><h3>Alignment: lining two sequences up</h3><p>Aligning two sequences means sliding them against each other so the matching letters stack up, and sticking in gaps where you need to so the rest lines up. It sounds simple, and for two nearly identical sequences it is. The clever part is that Biopython figures out the <em>best</em> way to line them up for you.</p><p>The tool is PairwiseAligner. &quot;Pairwise&quot; just means two at a time.</p><pre>from Bio import Align<br><br>aligner = Align.PairwiseAligner()<br>alignments = aligner.align(&quot;GATTACA&quot;, &quot;GATTGCA&quot;)<br>print(&quot;score:&quot;, alignments.score)<br>print(alignments[0])</pre><p>Output:</p><pre>score: 6.0<br>target            0 GATTACA 7<br>                  0 ||||.|| 7<br>query             0 GATTGCA 7</pre><p>Take a second with that little diagram, because you’ll be reading a lot of them. The top line is your first sequence, the bottom is your second, and the middle line tells you what happened at each spot. A | is a match, a . is a mismatch, and a - (you&#39;ll see it soon) is a gap. So here, six letters match and one doesn&#39;t, right where the A and the G disagree.</p><h3>The score is just points</h3><p>How does it decide what “best” means? Points. Matches earn points, mismatches and gaps cost points, and the aligner hunts for the arrangement with the highest total. You set the values yourself:</p><pre>from Bio import Align<br><br>aligner = Align.PairwiseAligner()<br>aligner.match_score = 2       # reward a match<br>aligner.mismatch_score = -1   # penalise a mismatch<br>aligner.open_gap_score = -2   # cost to start a gap<br>aligner.extend_gap_score = -1 # cost to make a gap longer<br><br>alignments = aligner.align(&quot;ACGTACGT&quot;, &quot;ACGTCGT&quot;)<br><br>print(&quot;score:&quot;, alignments.score)<br>print(alignments[0])</pre><pre>score: 12.0<br>target            0 ACGTACGT 8<br>                  0 ||||-||| 8<br>query             0 ACGT-CGT 7</pre><p>There’s the gap. The second sequence is missing a letter, so the aligner drops in a - to keep everything else lined up. The score of 12 is nothing mysterious: seven matches at 2 points each is 14, minus one gap penalty of 2, gives 12. That&#39;s the whole idea. Add up the good, subtract the bad.</p><p>One detail worth knowing: opening a gap and extending a gap are priced separately, and opening usually costs more. That’s on purpose. In real biology, one clean gap of five letters is more believable than five random single-letter gaps scattered around, so you make the scattered version expensive.</p><h3>Global vs local, and why it matters</h3><p>There are two ways to align, and picking the wrong one will give you nonsense.</p><p>Global alignment lines up the whole length of both sequences, end to end. Local alignment ignores the ends and finds only the best-matching stretch in the middle. Watch what happens with two sequences that share a core but have totally different ends:</p><pre>from Bio import Align<br><br>aligner = Align.PairwiseAligner()<br>aligner.match_score = 2<br>aligner.mismatch_score = -1<br>aligner.open_gap_score = -2<br>aligner.extend_gap_score = -1<br><br>s1 = &quot;GGGGGACGTACGTCCCCC&quot;<br>s2 = &quot;TTACGTACGTAA&quot;<br><br>aligner.mode = &quot;global&quot;<br>print(aligner.align(s1, s2)[0])<br><br>aligner.mode = &quot;local&quot;<br>print(aligner.align(s1, s2)[0])</pre><pre>target            0 GGGGGACGTACGTCCCCC 18<br>                  0 ---..||||||||---.. 18<br>query             0 ---TTACGTACGT---AA 12</pre><pre>target            5 ACGTACGT 13<br>                  0 ||||||||  8<br>query             2 ACGTACGT 10</pre><p>Global forced the whole thing to line up and made a mess of the ends, all gaps and mismatches. Local just quietly pulled out the shared ACGTACGT in the middle and ignored the rest. Notice the numbers on the side of the local one: it tells you it found the match starting at position 5 in the first sequence and position 2 in the second.</p><p>Rule of thumb I use: global when the two things are basically the same kind of object (the same gene from two species), local when I’m fishing for a small shared region hidden inside larger, different sequences.</p><h3>BLOSUM: not all mismatches are equal</h3><p>For DNA, a mismatch is a mismatch. Proteins are pickier. Some amino acid swaps barely change anything because the two amino acids are chemically similar, and some swaps are a big deal. Scoring every protein mismatch the same is throwing away information.</p><p>So for proteins you hand the aligner a substitution matrix. BLOSUM62 is the usual one. It has a score for every possible pair of amino acids, based on how often that swap actually happens in related proteins.</p><pre>from Bio import Align<br>from Bio.Align import substitution_matrices<br><br>aligner = Align.PairwiseAligner()<br>aligner.substitution_matrix = substitution_matrices.load(&quot;BLOSUM62&quot;)<br>aligner.open_gap_score = -10<br>aligner.extend_gap_score = -0.5<br><br>alignments = aligner.align(&quot;KEVLA&quot;, &quot;KEVLQ&quot;)<br><br>print(&quot;score:&quot;, alignments.score)<br>print(alignments[0])</pre><pre>score: 17.0<br>target            0 KEVLA 5<br>                  0 ||||. 5<br>query             0 KEVLQ 5</pre><p>Look at a few of the individual scores to see the idea:</p><pre>bl = substitution_matrices.load(&quot;BLOSUM62&quot;)<br>print(bl[&quot;A&quot;, &quot;A&quot;], bl[&quot;A&quot;, &quot;Q&quot;], bl[&quot;L&quot;, &quot;I&quot;])</pre><pre>4.0 -1.0 2.0</pre><p>A against itself scores +4, no surprise. A against Q gets a small penalty. But L against I, two different amino acids, still scores a positive +2, because swapping leucine for isoleucine is a common, harmless change in nature. A plain match-or-mismatch score would completely miss that. When you use a matrix, don&#39;t also set match_score and mismatch_score. The matrix is doing that job now.</p><h3>BLAST: what is this thing I’m holding?</h3><p>Alignment compares two sequences you already have. But a lot of the time you have one sequence and a question: what is it? You want to compare it against everything known, not just one other thing.</p><p>That’s BLAST. Honestly it’s the tool I’d point a total beginner to first, because the payoff is immediate. You give it a sequence, it searches a giant database, and it hands back the closest known matches, ranked. It’s basically a search engine for DNA and protein. And underneath, it’s doing the local alignment from a minute ago, just very fast and against millions of sequences at once. So you already understand the engine.</p><p>You can run BLAST two ways. There’s the website (blast.ncbi.nlm.nih.gov), which is great for a one-off, you paste your sequence and click. But if you’ve got a script that needs to BLAST twenty sequences, clicking isn’t going to cut it, and that’s where doing it from Python earns its keep.</p><p>Two things to get out of the way first. It needs an internet connection, and it can take a minute or two per search because you’re waiting on NCBI’s servers. That’s normal, don’t kill it. Also, set your email, same as with the downloads in Part 1.</p><pre>from Bio import Blast<br><br>Blast.email = &quot;your_real_email@example.com&quot;<br>my_sequence = &quot;ATTAAAGGTTTATACCTTCCCAGGTAACAAACCAACCAACTTTCGATCTCTTGTAGATCTG&quot;<br><br>result_stream = Blast.qblast(&quot;blastn&quot;, &quot;nt&quot;, my_sequence)</pre><p>blastn is for DNA against a DNA database (nt). For proteins you&#39;d use blastp against nr. The search goes off to NCBI and comes back as a stream of results.</p><p>Save that stream before you do anything else. BLAST is slow, so run it once, write the result to a file, and read the file as many times as you want afterwards.</p><pre>with open(&quot;results.xml&quot;, &quot;wb&quot;) as out:   # note: binary mode, &quot;wb&quot;<br>    out.write(result_stream.read())<br><br>result_stream.close()</pre><h3>Reading the results</h3><p>Now read the saved file. Blast.read gives you back a record, and the structure is worth picturing before you poke at it. A record is a list of hits. Each hit is one matching database sequence. And each hit contains one or more HSPs, which are the actual aligned chunks. Record, then hits, then HSPs.</p><pre>from Bio import Blast<br><br>record = Blast.read(&quot;results.xml&quot;)<br><br>print(&quot;query:&quot;, record.query.description)<br>print(&quot;hits found:&quot;, len(record))<br><br>for hit in record:<br>    print(hit.target.description)<br>    print(&quot;  accession:&quot;, hit.target.name)<br>    for hsp in hit:<br>        print(&quot;  e-value:&quot;, hsp.annotations[&quot;evalue&quot;])<br>        print(&quot;  identity:&quot;, hsp.annotations[&quot;identity&quot;])<br>        print(&quot;  bit score:&quot;, hsp.annotations[&quot;bit score&quot;])</pre><p>The sequence up there is a slice of the SARS-CoV-2 genome, so when I ran it, every single hit came back as some SARS-CoV-2 genome from somewhere in the world. Which is exactly what you’d hope. The output looked like this, over and over:</p><pre>Severe acute respiratory syndrome coronavirus 2 ...<br>  accession: OY942076<br>  e-value: 2.9e-28<br>  identity: 75<br>  bit score: 136.5</pre><h3>The two numbers you actually read</h3><p>Every hit gives you a pile of numbers, but two of them do most of the work.</p><p>Identity is the easy one. It’s how many letters in the aligned stretch are exactly the same. Bigger is better, and it usually gets shown as a percentage.</p><p>The e-value is the one people misread, so slow down here. It answers a single question: could this match just be luck? Specifically, it’s how many matches this good you’d expect to stumble on by pure chance in a database this size. And the direction is backwards from what you’d guess. Smaller is better. An e-value like 2.9e-28 means the odds of this being a coincidence are basically zero, so trust it. An e-value of 8 means you&#39;d trip over a match that good by accident anyway, so ignore it. The way I remember it: identity, bigger is better; e-value, smaller is better.</p><p>There’s also the bit score. Think of it as the alignment score from the first half of this post, but rescaled onto a standard scale so you can compare scores across different searches and different databases. Bigger is a stronger match. Bit score and e-value move in opposite directions, because a stronger match is less likely to be an accident.</p><h3>A thing that will confuse you the first time</h3><p>When I ran that COVID search, every hit had the <em>same</em> e-value, the same identity, the same bit score. Fifty results, identical numbers. My first thought was that something had broken.</p><p>Nothing had broken. All those SARS-CoV-2 genomes are nearly identical copies of each other, and the little slice I searched happens to fall in a region that doesn’t vary between them. So my sequence matched every one of them in exactly the same way, and identical matches produce identical numbers. It’s not a bug, it’s biology. Search for something that has genuinely different relatives and the numbers spread out like you’d expect.</p><p>Which is the same lesson from Part 1, really: always look at what you got back and ask whether it makes sense, instead of trusting the first row.</p><h3>Next time</h3><p>That’s alignment and BLAST. You can now compare two sequences properly, and take a mystery sequence and find out what it is. Between this and <a href="https://medium.com/@minhazulhasansohan/the-biopython-basics-i-use-in-almost-every-script-part-01-9ffaab12e2bf?sharedUserId=minhazulhasansohan"><strong>Part 1</strong></a>, that’s most of the day-to-day work.</p><p>Part 3 is the fun stuff to end on: cracking open 3D protein structures and measuring distances inside them, drawing evolutionary trees, and a couple of smaller tools I keep coming back to.</p><p>As always, if I’ve botched something or you’ve got a better way, say so. Still learning.</p><p>Link to part 3 is as follows:</p><p><a href="https://minhazulhasansohan.medium.com/biopython-protein-shapes-and-phylogenetic-trees-part-3-0dceb7892ac6">Biopython: Protein shapes and Phylogenetic trees — Part 3</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a84fa8c7cce3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/biopython-comparing-sequences-and-finding-out-what-they-are-part-02-a84fa8c7cce3">Biopython: Comparing sequences and finding out what they are — Part 02</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Biopython basics I use in almost every script — Part 01]]></title>
            <link>https://medium.com/analytics-vidhya/the-biopython-basics-i-use-in-almost-every-script-part-01-9ffaab12e2bf?source=rss-e6d90bce461b------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ffaab12e2bf</guid>
            <category><![CDATA[bioinformatics]]></category>
            <category><![CDATA[bioinformatics-analysis]]></category>
            <category><![CDATA[computational-biology]]></category>
            <category><![CDATA[bioinformatics-tools]]></category>
            <category><![CDATA[biopython]]></category>
            <dc:creator><![CDATA[Minhazul Hasan Sohan]]></dc:creator>
            <pubDate>Fri, 24 Jul 2026 09:00:28 GMT</pubDate>
            <atom:updated>2026-07-24T09:17:10.515Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3EV1jZCIjw0arXDTpkybNQ.png" /></figure><p>Most of my early bioinformatics code did things that Biopython already does in one line. I just didn’t know it yet. I was splitting strings by hand, writing my own reverse-complement function (and getting it subtly wrong), counting nucleotides with loops. It worked, mostly. It was also a waste of an afternoon.</p><p>So this is the stuff I wish someone had put in front of me on day one. Nothing fancy. Just the handful of tools I end up reaching for in almost every script, with the small traps that cost me time so they don’t cost you any.</p><p>I’m on Biopython 1.87 as I write this. If you’re on something older, most of this still holds, but a few things have changed over the years, so check your version if a line misbehaves.</p><h3>Install it first</h3><pre>pip install biopython</pre><p>Then confirm it worked:</p><pre>import Bio<br>print(Bio.__version__)</pre><p>One thing that threw me at the start: the import is Bio, not biopython. If import Bio runs without complaining, you&#39;re set.</p><h3>1. Seq — the thing everything else is built on</h3><p>A Seq holds a single sequence. That&#39;s it. But almost every other tool hands you one of these, so it&#39;s worth getting comfortable with.</p><pre>&gt;&gt;&gt; from Bio.Seq import Seq<br>&gt;&gt;&gt; my_dna = Seq(&quot;ATGCGTACGTTAG&quot;)<br>&gt;&gt;&gt; print(my_dna)<br>ATGCGTACGTTAG<br>&gt;&gt;&gt; len(my_dna)<br>13</pre><p>It behaves a lot like a normal string, which is the point. You can measure it, slice it, search it. The difference is that it knows it’s biology, so it can do things a plain string can’t.</p><h3>2. Reverse complement, and other things you’ll do constantly</h3><p>The reverse complement is probably the function I call most. If you’ve ever written this yourself, you know there are two easy ways to mess it up: forgetting to reverse, or fumbling the base pairing. Biopython just does it.</p><pre>&gt;&gt;&gt; my_dna.reverse_complement()<br>Seq(&#39;CTAACGTACGCAT&#39;)</pre><p>There’s a plain complement() too, but in real work you almost always want the reverse complement, because genes on the opposite strand are read the other direction.</p><p>Counting a base:</p><pre>&gt;&gt;&gt; my_dna.count(&quot;A&quot;)<br>3</pre><p>Small trap here: count does not count overlaps. In AAAA, counting AA gives you 2, not 3. I&#39;ve been bitten by that.</p><p>Finding where something starts:</p><pre>&gt;&gt;&gt; my_dna.find(&quot;TAC&quot;)<br>3<br>&gt;&gt;&gt; my_dna.find(&quot;GGG&quot;)<br>-1</pre><p>That -1 is the &quot;not found&quot; signal. Get used to checking for it, because it&#39;s easy to treat -1 as a real position and end up slicing from the wrong end of your sequence.</p><p>And slicing works how you’d expect, with the usual Python rule that the start is included and the end is not:</p><pre>&gt;&gt;&gt; my_dna[0:3]<br>Seq(&#39;ATG&#39;)</pre><h3>3. From DNA to protein in three lines</h3><p>This is the part that made me actually like the library. The whole central-dogma path, DNA to RNA to protein, is three method calls.</p><pre>dna = Seq(&quot;ATGGCCATTGTAATGGGCCGCTGA&quot;)</pre><pre>print(dna.transcribe())         # DNA -&gt; RNA, T becomes U<br>print(dna.translate())          # -&gt; protein<br>print(dna.translate(to_stop=True))</pre><p>Output:</p><pre>AUGGCCAUUGUAAUGGGCCGCUGA<br>MAIVMGR*<br>MAIVMGR</pre><p>A quick read of that protein: each letter is one amino acid, and the * at the end is a stop codon, not an amino acid. Pass to_stop=True and it cuts the protein at the first stop and drops the star, which is usually what you want.</p><p>One thing worth knowing before it burns you: the genetic code isn’t universal. Mitochondria and some organisms read certain codons differently. By default translate uses the standard code, but you can pass a different table:</p><pre>&gt;&gt;&gt; dna.translate(table=&quot;Vertebrate Mitochondrial&quot;)<br>Seq(&#39;MAIVMGRW&#39;)</pre><p>Same DNA, different last letter, because TGA means &quot;stop&quot; in the standard code but codes for tryptophan in the vertebrate mitochondrial one. If you&#39;re working on mitochondrial genes and forget this, your protein will be quietly wrong.</p><p>GC content comes from a separate module:</p><pre>&gt;&gt;&gt; from Bio.SeqUtils import gc_fraction<br>&gt;&gt;&gt; round(gc_fraction(Seq(&quot;ATGCGTACGGGGCCCC&quot;)) * 100, 1)<br>75.0</pre><p>It returns a fraction from 0 to 1, so multiply by 100 if you want a percentage.</p><h3>4. SeqRecord — because a sequence without a name is useless</h3><p>Here’s the thing nobody explained to me clearly, so I’ll try to.</p><p>A Seq is just letters. If you load a thousand sequences and they&#39;re all bare Seq objects, you have a thousand strings and no idea which is which. Which one is the human gene? Which is the mouse one? You can&#39;t tell. The letters don&#39;t carry a name.</p><p>A SeqRecord fixes that. It&#39;s the sequence <em>plus</em> its identity: an id, a name, a description, and room for extra notes. When you read a real file, this is what you get back. Not a bare Seq, a SeqRecord.</p><pre>from Bio.Seq import Seq<br>from Bio.SeqRecord import SeqRecord<br><br>record = SeqRecord(<br>    Seq(&quot;ATGCGTACGTTAG&quot;),<br>    id=&quot;GENE001&quot;,<br>    name=&quot;MyGene&quot;,<br>    description=&quot;An example gene&quot;,<br>)<br><br>print(record.id, &quot;|&quot;, record.description)<br>print(len(record))</pre><pre>GENE001 | An example gene<br>13</pre><p>The id is the unique identifier (in real data, an accession number). The description is the human-readable line. And you can stash extra facts in annotations, which is just a dictionary:</p><pre>record.annotations[&quot;organism&quot;] = &quot;Homo sapiens&quot;</pre><p>The sequence itself is still right there in record.seq, so anything from earlier still works: record.seq.translate(), record.seq.reverse_complement(), all of it.</p><h3>5. SeqIO — reading and writing files</h3><p>Real sequences live in files, and SeqIO is how you read and write them. There are two functions to keep straight:</p><ul><li>parse for a file with <strong>many</strong> records. It gives you an iterator, so you loop.</li><li>read for a file with exactly <strong>one</strong> record. It hands you that record directly.</li></ul><p>Reading a FASTA:</p><pre>from Bio import SeqIO</pre><pre>for record in SeqIO.parse(&quot;example.fasta&quot;, &quot;fasta&quot;):<br>    print(record.id, len(record))</pre><p>Note that parse needs two things: the filename and the format string. read will throw an error if the file has more than one record, so don&#39;t reach for it unless you&#39;re sure there&#39;s only one.</p><p>Now the mistake I made more than once, and watched other people make too. <strong>You can’t read a file that doesn’t exist yet.</strong> Obvious when you say it out loud, but in a notebook it’s easy to write the reading code, run it, and get a FileNotFoundError because you never actually created or downloaded the file. So, create it first:</p><pre>from Bio.Seq import Seq<br>from Bio.SeqRecord import SeqRecord<br>from Bio import SeqIO</pre><pre>records = [<br>    SeqRecord(Seq(&quot;ATGAAATAG&quot;), id=&quot;g1&quot;, description=&quot;gene one&quot;),<br>    SeqRecord(Seq(&quot;ATGGGGTAA&quot;), id=&quot;g2&quot;, description=&quot;gene two&quot;),<br>]</pre><pre>SeqIO.write(records, &quot;out.fasta&quot;, &quot;fasta&quot;)</pre><p>That writes a proper FASTA:</p><pre>&gt;g1 gene one<br>ATGAAATAG<br>&gt;g2 gene two<br>ATGGGGTAA</pre><p>FASTQ files are similar, except each read also carries a quality score for every single base (how sure the sequencer was). Biopython decodes those funny quality symbols into real numbers for you:</p><pre>for record in SeqIO.parse(&quot;reads.fastq&quot;, &quot;fastq&quot;):<br>    print(record.id, record.letter_annotations[&quot;phred_quality&quot;])</pre><p>You’ll get a list like [40, 40, 40, ...], where higher means more reliable.</p><p>And converting between formats is a one-liner, which is genuinely one of my favorite small conveniences:</p><pre>count = SeqIO.convert(&quot;demo.gb&quot;, &quot;genbank&quot;, &quot;demo.fasta&quot;, &quot;fasta&quot;)<br>print(&quot;Converted&quot;, count, &quot;record(s)&quot;)</pre><p>Four arguments: input file, input format, output file, output format. Done.</p><h3>6. Entrez — getting real data off NCBI</h3><p>Everything above works on files you already have. But a lot of the time you want data from NCBI, the huge public database, and you don’t want to click through a website to get it. That’s Entrez.</p><p>Two rules before anything else. First, this needs an internet connection. Second, you have to give NCBI your email, every time. It’s not optional, it’s how they contact you if your script accidentally hammers their servers. So set it first:</p><pre>from Bio import Entrez, SeqIO</pre><pre>Entrez.email = &quot;your_real_email@example.com&quot;</pre><p>If you already know the accession, efetch pulls it straight down. Here&#39;s the original SARS-CoV-2 genome:</p><pre>handle = Entrez.efetch(db=&quot;nucleotide&quot;, id=&quot;MN908947&quot;, rettype=&quot;fasta&quot;, retmode=&quot;text&quot;)<br>record = SeqIO.read(handle, &quot;fasta&quot;)<br>handle.close()</pre><pre>print(record.id, len(record))</pre><p>You’ll get back MN908947.3 and a length of 29903. A whole viral genome, in four lines. efetch gives you a handle, which you can think of as an open pipe to NCBI, and you read from it just like a file. Close it when you&#39;re done.</p><p>Save what you download, by the way. Don’t re-fetch the same thing over and over. Pull it once, write it to disk, read the local copy next time.</p><p>If you don’t know the accession and just have keywords, esearch finds matching ids:</p><pre>handle = Entrez.esearch(db=&quot;nucleotide&quot;, term=&quot;human insulin&quot;, retmax=5)<br>results = Entrez.read(handle)<br>handle.close()</pre><pre>print(results[&quot;Count&quot;], results[&quot;IdList&quot;])</pre><p>results[&quot;Count&quot;] is how many total matches exist, and IdList is the actual ids (up to retmax). Notice you read search results with Entrez.read, not SeqIO.read. They&#39;re different things.</p><p>Now the lesson that actually cost me time. A plain keyword search like &quot;human insulin&quot; matches a lot of garbage, because NCBI matches words, not meaning. I once searched for human insulin and the top hit was a giant fish genome, twenty-four million bases long, that happened to mention &quot;insulin&quot; and &quot;human&quot; somewhere in its notes. So be specific, and use field tags:</p><pre>term = &quot;INS[Gene] AND Homo sapiens[Organism] AND refseq[filter] AND biomol_mrna[PROP]&quot;</pre><p>That says: the INS gene, in humans, from the clean RefSeq set, mRNA only. Way better. And whatever you get, always sanity-check the description and the length before you trust it. If you asked for a gene and got back something twenty million bases long, that’s a chromosome, not a gene.</p><h3>That’s part one</h3><p>If you take one thing from this, let it be the boring one: create or download your file before you try to read it. That single mistake accounts for a surprising number of the errors I see, my own included.</p><p>Next time I’ll get into the more interesting stuff: aligning sequences to see how similar they are, running BLAST to identify a mystery sequence.</p><p>Link to part 2 is as follows:</p><p><a href="https://minhazulhasansohan.medium.com/biopython-comparing-sequences-and-finding-out-what-they-are-part-02-a84fa8c7cce3">Biopython: Comparing sequences and finding out what they are — Part 02</a></p><p>If you spot something I got wrong, or you have a Biopython trick you swear by, tell me. I’m still learning this too.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ffaab12e2bf" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/the-biopython-basics-i-use-in-almost-every-script-part-01-9ffaab12e2bf">The Biopython basics I use in almost every script — Part 01</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploying Flask API on Microsoft IIS in Windows]]></title>
            <link>https://minhazulhasansohan.medium.com/deploying-flask-application-on-microsoft-iis-in-windows-2fb7b25eeb1d?source=rss-e6d90bce461b------2</link>
            <guid isPermaLink="false">https://medium.com/p/2fb7b25eeb1d</guid>
            <category><![CDATA[flask]]></category>
            <category><![CDATA[wsgi]]></category>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[isis]]></category>
            <dc:creator><![CDATA[Minhazul Hasan Sohan]]></dc:creator>
            <pubDate>Wed, 21 Aug 2024 12:37:09 GMT</pubDate>
            <atom:updated>2024-08-21T13:00:56.855Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/543/1*WNPLtIZgDymuT1bAxy6Y_Q.png" /></figure><p>In a typical deployment, IIS serves as the web server, and WSGI handles the communication between IIS and your Flask application. This is usually achieved through a WSGI-compatible server like <strong>wfastcgi</strong> or <strong>mod_wsgi</strong>. These servers translate incoming HTTP requests from IIS into a format that Flask can process, and then return the response back to IIS, which delivers it to the client.</p><p>Deploying a <strong>Flask API</strong> on a Windows machine can be a bit tricky, but with the right steps, you can have your application up and running on the Microsoft Internet Information Services (IIS) server. This guide will walk you through the process of deploying a Flask application on an IIS server, ensuring a smooth and efficient deployment.</p><h4><strong>Prerequisites:</strong></h4><ul><li>Windows machine with IIS server installed and configured.</li><li>A Flask web application (make sure it’s running correctly on the local development environment).</li></ul><h4><strong>Step 1: Ensure IIS is Enabled on Your Windows Machine</strong></h4><p>First, you need to verify that IIS is active on your Windows machine. To do this, type <strong>IIS</strong> into the Windows search box.</p><p>If IIS is not found, you’ll need to enable it:</p><ol><li>Open the <strong>Control Panel</strong>.</li><li>Go to <strong>Programs</strong> &gt; <strong>Uninstall a program</strong>.</li><li>On the left side, click <strong>Turn Windows features On or Off</strong>.</li><li>Locate and check the <strong>Internet Information Services (IIS)</strong> option, then click <strong>OK</strong> to enable it.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/835/1*5HMi-sWOtkrf2iQpsrK5qA.png" /><figcaption>Enable IIS from Turn Windows Feature On or Off</figcaption></figure><h4><strong>Step 2: Create a Flask API Project</strong></h4><ol><li>Create a new Flask API project in your preferred development environment.</li><li>Set up a virtual environment using the command: python -m venv env.</li><li>Activate the virtual environment using the command: .\env\Scripts\activate.</li><li>Install the required dependencies using pip install flask.</li><li>Create a simple Flask application in a file named main.py (or any other name you prefer).</li><li>Run the Flask application using the command: python main.py.</li><li>Verify that the application is working correctly by accessing http://127.0.0.1:5000/ in your web browser.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BtUWbJ_JImGkxOHPsi4jKQ.png" /><figcaption>A simple Flask API on VS Code</figcaption></figure><h4><strong>Step 3: Configure File &amp; Folder Permission</strong></h4><p>Before deploying the app, ensure that the IIS user has the necessary permissions to access your Flask project:</p><ol><li>Right-click your Flask project folder and select <strong>Properties</strong>.</li><li>Go to the <strong>Security</strong> tab and click <strong>Edit</strong>.</li><li>Click <strong>Add</strong>, and in the dialog, type IUSR and IIS_IUSRS.</li><li>If the users are not found:<br>4.1. Click <strong>Advanced </strong>&gt; <strong>Find Now</strong>.<br>4.2. Select IUSR and IIS_IUSRS from the list, then click OK.</li><li>Assign the necessary permissions (usually <strong>Read &amp; execute</strong>, <strong>List folder contents</strong>, and <strong>Read</strong>).</li><li>Click <strong>Apply</strong> and <strong>OK</strong>.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ys37lJUz4Rgwg-ZX_MAvLQ.png" /><figcaption>Configure Permission for IUSER and IIS_USER</figcaption></figure><h4><strong>Step 4: Configure IIS for Your Flask App</strong></h4><p>Now that your project is ready and permissions are set, configure IIS to serve your Flask app:</p><ol><li>Open IIS by typing <strong>IIS</strong> in the Windows search box.</li><li>In IIS Manager, right-click on <strong>Sites</strong> and select <strong>Add Website</strong>.</li></ol><ul><li><strong>Site name:</strong> Enter a name for your site (e.g., <strong><em>Flask API on IIS</em></strong> or any name you prefer).</li><li><strong>Physical path:</strong> Set this to the path of your Flask project (e.g., for me it’s C:\\Users\\BS1017\\Desktop\\MyFlaskApp).</li><li><strong>Port:</strong> Assign a port (e.g., 7070).</li><li>Click <strong>OK</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HoxHqyTVw4zRQAOIAj34gw.png" /><figcaption>Create a Site on IIS</figcaption></figure><h4><strong>Step 4.1: Configure Handler Mappings</strong></h4><ol><li>Double-click on your site in IIS Manager.</li><li>Click <strong>Handler Mappings</strong> and select <strong>Add Module Mapping</strong>.</li></ol><ul><li><strong>Request Path:</strong> *</li><li><strong>Module:</strong> FastCgiModule</li><li><strong>Executable Path: </strong>For get the executable path<br>1. Open <strong>Command Prompt</strong> as Administrator.<br>2. Navigate to your virtual environment’s <strong>Scripts</strong> directory.<br>3. Run: `<strong>python.exe -m pip install wfastcgi</strong>`<br>4. Then, enable FastCGI: `wfastcgi-enable.exe`<br>5. Copy the executable path shown in the console and paste it in the <strong>Executable Path</strong> field.</li><li><strong>Name:</strong> FlaskAPIHandler</li><li><strong>Request Restrictions:</strong> In the <strong>Mapping</strong> tab, uncheck <strong>Invoke handler.</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KmZdvj_9yP52C-03P8Vo-A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jxi-BdRBO9d81EnANL2HPA.png" /><figcaption>Handler Mapping</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*j13mEVULV71ulRJU3KwTCg.png" /><figcaption>Get the Executable Path</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6fbSt6eH8xNk5xdGlD6thQ.png" /><figcaption>Configure Handler Mapping</figcaption></figure><h4><strong>Step 4.1: Configure FastCGI Settings</strong></h4><ol><li>Go back to IIS Manager and click <strong>FastCGI Settings</strong>.</li><li>Select your site and double-click on it.</li><li>Under the <strong>General</strong> section, click on the <strong>Environment Variables</strong> button (three dots).</li></ol><ul><li><strong>Add:<br>1. Name:</strong> PYTHONPATH <br><strong>2. Value:</strong> The path of your application (For me its: C:\User\BS1017\Desktop\MyFlaskApp )</li><li><strong>Add:<br>1. Name:</strong> WSGI_HANDLER <br><strong>2. Value:</strong> main.app (replace main.app with the entry point of your Flask app).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kr5x23f03VAOvR_Y80Jxiw.png" /><figcaption>FastCGI Settings</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XL-0jkQqMtqaoeAgBlZkHQ.png" /><figcaption>Find your created site</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/983/1*tU0RS08DfOH527OAOp1ufg.png" /><figcaption>Add PYTHON path and WSGI_HANDLER</figcaption></figure><p><strong>Final Step: Test Your Deployment</strong></p><p>That’s it! Your Flask application should now be deployed and accessible through the IIS server. You can test it by navigating to http://localhost:7070/ (or the port number you specified) in your web browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ctl9PXp89qH50gCk0BWEYQ.png" /><figcaption>Test Your API on Deployed Port</figcaption></figure><p>Remember to replace the paths and file names with the ones specific to your Flask application and development environment.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2fb7b25eeb1d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python — List]]></title>
            <link>https://minhazulhasansohan.medium.com/python-list-a739022efa5b?source=rss-e6d90bce461b------2</link>
            <guid isPermaLink="false">https://medium.com/p/a739022efa5b</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[python-list-comprehension]]></category>
            <category><![CDATA[python-list]]></category>
            <category><![CDATA[python-fundamentals]]></category>
            <category><![CDATA[python-list-methods]]></category>
            <dc:creator><![CDATA[Minhazul Hasan Sohan]]></dc:creator>
            <pubDate>Tue, 06 Apr 2021 15:52:59 GMT</pubDate>
            <atom:updated>2021-04-06T15:52:59.137Z</atom:updated>
            <content:encoded><![CDATA[<h3>Python — List</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YJpdbAyoieZgw4uDVAfsTQ.png" /></figure><p>List in Python is more likely an array in other programming languages. It is used to store multiple items in a single variable. So we can say that a list in python is a data structure that is an ordered sequence of elements and each element inside of a list is called an Item. Python list is mutable which means it’s changeable.</p><h4>Declare a List:</h4><p>In python programming, a list is declared by placing all the items (elements) inside square brackets <strong>[]</strong>, separated by commas. We can put different types of datatype inside a list.</p><pre>my_list = [] # empty list<br>my_list = [1, 2, 3] # list of integers<br>my_list = [&#39;apple&#39;, &#39;banana&#39;, &#39;orange&#39;]  # list of strings<br>my_list = [3.4, &quot;Bangladesh&quot;, [4, 5, 6]] # list with mixed datatypes</pre><h4>List Indexing:</h4><p>List indexing is very much flexible in Python. We can use both positive and negative indexing in python.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fsheetsu.com%2Ftables%2Ff877a00f52&amp;dntp=1&amp;display_name=Sheetsu&amp;url=https%3A%2F%2Fsheetsu.com%2Ftables%2Ff877a00f52&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=sheetsu" width="700" height="200" frameborder="0" scrolling="no"><a href="https://medium.com/media/154557ab9b699cb6f620a8b936b1dfb1/href">https://medium.com/media/154557ab9b699cb6f620a8b936b1dfb1/href</a></iframe><pre>&gt;&gt;&gt; days = [&#39;Saturday&#39;, &#39;Sunday&#39;, &#39;Monday&#39;, &#39;Tuesday&#39;, &#39;Wednesday&#39;, &#39;Thursday&#39;, &#39;Friday&#39;]<br>&gt;&gt;&gt; days[0]<br>&#39;Saturday&#39;<br>&gt;&gt;&gt; days[2]<br>&#39;Monday&#39;<br>&gt;&gt;&gt; days[6]<br>&#39;Friday&#39;<br>&gt;&gt;&gt; days[-1]<br>&#39;Friday&#39;<br>&gt;&gt;&gt; days[-2]<br>&#39;Thursday&#39;<br>&gt;&gt;&gt; days[-7]<br>&#39;Saturday&#39;</pre><h4>List Slicing in Python:</h4><p>In Python, list slicing is a common practice and it is the most used technique for programmers to solve efficient problems. With the colon(:) operator, we can specify where to start the slicing, where to end, and also specify the step. List slicing returns a new list from the existing list.</p><p><strong>Syntax —</strong> List[Initial_Index, Ending_Index, Index_Jump]</p><pre>&gt;&gt;&gt; num = [10, 20, 30, 40, 50, 60, 70, 80, 90]<br>&gt;&gt;&gt; num[:] # Returns all the elements<br>[10, 20, 30, 40, 50, 60, 70, 80, 90]</pre><pre># Return the elements from index 2 to index (5-1)<br>&gt;&gt;&gt; num[2:5]<br>[30, 40, 50]</pre><pre># Return the elements from beginning to index (6-1)<br>&gt;&gt;&gt; num[:6]<br>[10, 20, 30, 40, 50, 60]</pre><pre># Return the elements from index 3 to end<br>&gt;&gt;&gt; num[3:]<br>[40, 50, 60, 70, 80, 90]</pre><pre># Return the elements from index -7 to index (-2-1)<br>&gt;&gt;&gt; num[-7:-2]<br>[30, 40, 50, 60, 70]</pre><pre># Return the elements from index -5 to end<br>&gt;&gt;&gt; num[-5:]<br>[50, 60, 70, 80, 90]</pre><pre># Return the elements from beginning to index (-2-1)<br>&gt;&gt;&gt; num[:-2]<br>[10, 20, 30, 40, 50, 60, 70]</pre><pre># Return every 2nd element of the list<br>&gt;&gt;&gt; nums[::2]<br>[10, 30, 50, 70, 90]</pre><pre>&gt;&gt;&gt; num[::-1]<br>[90, 80, 70, 60, 50, 40, 30, 20, 10]<br>&gt;&gt;&gt; num[::-2]<br>[90, 70, 50, 30, 10]</pre><h3>Python List Methods:</h3><h4>append()</h4><p>The append() method appends an element to the end of the list.</p><pre>&gt;&gt;&gt; fruits = [&#39;apple&#39;, &#39;banana&#39;, &#39;cherry&#39;]<br>&gt;&gt;&gt; fruits.append(&quot;orange&quot;)<br>&gt;&gt;&gt; fruits<br>[&#39;apple&#39;, &#39;banana&#39;, &#39;cherry&#39;, &#39;orange&#39;]<br>&gt;&gt;&gt; fruit2 = [&#39;mango&#39;, &#39;goava&#39;]<br>&gt;&gt;&gt; fruits.append(fruit2)<br>&gt;&gt;&gt; fruits<br>[&#39;apple&#39;, &#39;banana&#39;, &#39;cherry&#39;, &#39;orange&#39;, [&#39;mango&#39;, &#39;goava&#39;]]</pre><h4><strong>insert()</strong></h4><p>The insert()method inserts an element at the specific index of a list.</p><pre>&gt;&gt;&gt; saarc = [&#39;Afghanistan&#39;, &#39;Bhutan&#39;, &#39;India&#39;, &#39;Maldives&#39;, &#39;Pakistan&#39;, &#39;Sri-Lanka&#39;]</pre><pre>&gt;&gt;&gt; saarc.insert(1, &#39;Bangladesh&#39;)<br>&gt;&gt;&gt; saarc<br>[&#39;Afghanistan&#39;, &#39;Bangladesh&#39;, &#39;Bhutan&#39;, &#39;India&#39;, &#39;Maldives&#39;, &#39;Pakistan&#39;, &#39;Sri-Lanka&#39;]</pre><pre>&gt;&gt;&gt; saarc.insert(5, &#39;Nepal&#39;)<br>&gt;&gt;&gt; saarc<br>[&#39;Afghanistan&#39;, &#39;Bangladesh&#39;, &#39;Bhutan&#39;, &#39;India&#39;, &#39;Maldives&#39;, &#39;Nepal&#39;, &#39;Pakistan&#39;, &#39;Sri-Lanka&#39;]</pre><h4>extend()</h4><p>extend() method is used to append elements from <em>another list / </em>tuple to the current list. It is kind of list concatination.</p><pre>&gt;&gt;&gt; fruit1 = [&quot;apple&quot;, &quot;banana&quot;, &quot;cherry&quot;]<br>&gt;&gt;&gt; fruit2 = [&quot;mango&quot;, &quot;pineapple&quot;, &quot;papaya&quot;]<br>&gt;&gt;&gt; fruit1.extend(fruit2)<br>&gt;&gt;&gt; fruit1<br>[&#39;apple&#39;, &#39;banana&#39;, &#39;cherry&#39;, &#39;mango&#39;, &#39;pineapple&#39;, &#39;papaya&#39;]</pre><pre>&gt;&gt;&gt; numList = [1, 2, 3]<br>&gt;&gt;&gt; numTuple = [4, 5, 6]<br>&gt;&gt;&gt; numList.extend(numTuple)<br>&gt;&gt;&gt; numList<br>[1, 2, 3, 4, 5, 6]</pre><h4>remove()</h4><p>remove() method removes the specified item from a list. It takes the item as a parameter that we want to remove.</p><pre>&gt;&gt;&gt; fruit = [&quot;mango&quot;, &quot;pineapple&quot;, &quot;papaya&quot;]<br>&gt;&gt;&gt; fruit.remove(&quot;pineapple&quot;)<br>&gt;&gt;&gt; fruit<br>[&#39;mango&#39;, &#39;papaya&#39;]</pre><h4>pop()</h4><p>pop() method also use to delete element. But instead of removing the specified item, it removes the specified index from a list. It takes the index number as a parameter that we want to remove. If we do not specify the index, then the pop() method removes the last item.</p><pre>&gt;&gt;&gt; fruit = [&#39;apple&#39;, &#39;banana&#39;, &#39;mango&#39;, &#39;pineapple&#39;, &#39;papaya&#39;]</pre><pre>&gt;&gt;&gt; fruit.pop()<br>&gt;&gt;&gt; fruit<br>[&#39;apple&#39;, &#39;banana&#39;, &#39;mango&#39;, &#39;pineapple&#39;]</pre><pre>&gt;&gt;&gt; fruit.pop(2)<br>&gt;&gt;&gt; fruit<br>[&#39;apple&#39;, &#39;banana&#39;, &#39;pineapple&#39;]</pre><h4>del</h4><p>The del keyword also removes the specified index by taking index value. If we do not specify the index, then the del keyword delete the list completely. It means the variable does not exist the memory at all.</p><pre>&gt;&gt;&gt; fruit = [&#39;apple&#39;, &#39;banana&#39;, &#39;mango&#39;, &#39;pineapple&#39;, &#39;papaya&#39;]</pre><pre>&gt;&gt;&gt; del fruit[3]<br>&gt;&gt;&gt; fruit<br>[&#39;apple&#39;, &#39;banana&#39;, &#39;mango&#39;, &#39;papaya&#39;]</pre><pre>&gt;&gt;&gt; del fruit<br>&gt;&gt;&gt; fruit<br>Traceback (most recent call last):<br>  File &quot;&lt;pyshell#6&gt;&quot;, line 1, in &lt;module&gt;<br>    fruit<br>NameError: name &#39;fruit&#39; is not defined</pre><h4>clear()</h4><p>clear() method empties the list. The list still exist but it has no contents.</p><pre>&gt;&gt;&gt; fruit = [&#39;apple&#39;, &#39;banana&#39;, &#39;mango&#39;, &#39;pineapple&#39;, &#39;papaya&#39;]<br>&gt;&gt;&gt; fruit.clear()<br>&gt;&gt;&gt; fruit<br>[]</pre><h4>copy()</h4><p>The copy() method copy all the list elements into a new list variable. Here both lists are independent and they contain different references. If we changes anythig to a list, that doesn’t effect the another list.</p><pre>&gt;&gt;&gt; a = [10, 20, 30, 40, 50, 60, 70]<br>&gt;&gt;&gt; b = a.copy()<br>&gt;&gt;&gt; b<br>[10, 20, 30, 40, 50, 60, 70]<br>&gt;&gt;&gt; a<br>[10, 20, 30, 40, 50, 60, 70]</pre><pre>&gt;&gt;&gt; b[2] = 25<br>&gt;&gt;&gt; b<br>[10, 20, 25, 40, 50, 60, 70]<br>&gt;&gt;&gt; a<br>[10, 20, 30, 40, 50, 60, 70]</pre><p>So we can see that, changing of b does’t effect a anymore. But if we assign entire a list into the b list, then both variables will contain the same referance. So that, changing of any list will effects the another.</p><pre>&gt;&gt;&gt; a = [10, 20, 30, 40, 50, 60, 70]<br>&gt;&gt;&gt; b = a<br>&gt;&gt;&gt; a<br>[10, 20, 30, 40, 50, 60, 70]<br>&gt;&gt;&gt; b<br>[10, 20, 30, 40, 50, 60, 70]</pre><pre>&gt;&gt;&gt; b[2] = 25<br>&gt;&gt;&gt; b<br>[10, 20, 25, 40, 50, 60, 70]<br>&gt;&gt;&gt; a<br>[10, 20, 25, 40, 50, 60, 70]</pre><h4>count()</h4><p>count() returns the number of elements with the specified value</p><pre>&gt;&gt;&gt; a = [10, 20, 30, 20, 50, 20, 70]<br>&gt;&gt;&gt; x = a.count(20)<br>&gt;&gt;&gt; x<br>3</pre><h4>index()</h4><p>index() returns the index of the first element with the specified value.</p><pre>&gt;&gt;&gt; num = [4, 55, 64, 32, 16, 32]<br>&gt;&gt;&gt; x = num.index(32)<br>&gt;&gt;&gt; x<br>3</pre><h4>reverse()</h4><p>reverse() method reverses the order of the list.</p><pre>&gt;&gt;&gt; digit = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]<br>&gt;&gt;&gt; digit.reverse()<br>&gt;&gt;&gt; digit<br>[9, 8, 7, 6, 5, 4, 3, 2, 1, 0]</pre><h4>sort()</h4><p>The sort() method sort the list alphanumerically, ascending, by default.</p><pre># Sort Alphabetically<br>&gt;&gt;&gt; fruit = [&quot;mango&quot;, &quot;pineapple&quot;, &#39;apple&#39;, &#39;banana&#39;, &quot;papaya&quot;]<br>&gt;&gt;&gt; fruit.sort()<br>&gt;&gt;&gt; fruit<br>[&#39;apple&#39;, &#39;banana&#39;, &#39;mango&#39;, &#39;papaya&#39;, &#39;pineapple&#39;]</pre><pre># Sort Numerically<br>&gt;&gt;&gt; num = [15, 12, 18, 5, 1, 7]<br>&gt;&gt;&gt; num.sort()<br>&gt;&gt;&gt; num<br>[1, 5, 7, 12, 15, 18]</pre><p>To sort descending, we can use the keyword argument reverse = True .</p><pre>&gt;&gt;&gt; fruit = [&quot;mango&quot;, &quot;pineapple&quot;, &#39;apple&#39;, &#39;banana&#39;, &quot;papaya&quot;]<br>&gt;&gt;&gt; fruit.sort(reverse=True)<br>&gt;&gt;&gt; fruit<br>[&#39;pineapple&#39;, &#39;papaya&#39;, &#39;mango&#39;, &#39;banana&#39;, &#39;apple&#39;]</pre><p>We can also customize our own function by using the keyword argument key =<em> function</em>.</p><pre>def myFunc(n):<br>    return abs(n - 50)</pre><pre>num = [100, 50, 65, 82, 23]<br>num.sort(key=myFunc)<br>print(num)</pre><pre>Output: [50, 65, 23, 82, 100]</pre><h3>Loop Through a List</h3><p>We can loop through a list items by using a for loop:</p><pre>fruit = [&quot;mango&quot;, &quot;pineapple&quot;, &#39;apple&#39;, &#39;banana&#39;, &quot;papaya&quot;]<br>for x in fruit:<br>    print(x)</pre><pre>Output:</pre><pre>mango<br>pineapple<br>apple<br>banana<br>papaya</pre><h3>List Comprehension</h3><p>List comprehension is an elegant way when we want to define and create lists based on existing lists. We can also does the same thing with a for statement with a conditional test inside but list comprehension makes that work more easier.</p><p><strong>Without List Comprehension</strong></p><pre>fruits = [&quot;apple&quot;, &quot;banana&quot;, &quot;cherry&quot;, &quot;kiwi&quot;, &quot;mango&quot;]<br>newlist = []</pre><pre>for item in fruits:<br>    if &quot;a&quot; in item:<br>        newlist.append(item)<br>print(newlist)</pre><pre>Output:<br>[&#39;apple&#39;, &#39;banana&#39;, &#39;mango&#39;]</pre><p><strong>With List Comprehension</strong></p><pre>fruits = [&quot;apple&quot;, &quot;banana&quot;, &quot;cherry&quot;, &quot;kiwi&quot;, &quot;mango&quot;]<br>newlist = [x for x in fruits if &quot;a&quot; in x]<br>print(newlist)</pre><pre>Output:<br>[&#39;apple&#39;, &#39;banana&#39;, &#39;mango&#39;]</pre><p><strong>Another Example</strong></p><pre>matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]<br>first_col = [row[0] for row in matrix]<br>print(first_col)</pre><pre>Output:<br>[1, 4, 7]</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a739022efa5b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is Node JS??? Building Blocks & Architecture???]]></title>
            <link>https://minhazulhasansohan.medium.com/what-is-node-js-building-blocks-architecture-6dba434d974e?source=rss-e6d90bce461b------2</link>
            <guid isPermaLink="false">https://medium.com/p/6dba434d974e</guid>
            <category><![CDATA[what-is-node-js]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[node-js-architecture]]></category>
            <category><![CDATA[node-js-building-block]]></category>
            <category><![CDATA[how-node-js-works]]></category>
            <dc:creator><![CDATA[Minhazul Hasan Sohan]]></dc:creator>
            <pubDate>Tue, 22 Dec 2020 14:25:59 GMT</pubDate>
            <atom:updated>2020-12-22T14:25:59.143Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*lBKp4ReuLIhwPVhkp9hktQ.jpeg" /></figure><h4>Node.JS</h4><p>Node JS is an open-source, cross-platform JavaScript runtime powered by a Chrome V8 engine that executes JavaScript code outside a web browser.</p><p>What is the runtime environment really??? Well, before node we use JavaScript only to build applications that run inside the browser. Every browser has a JavaScript engine that takes our JavaScript code and converts it to code that a computer can understand. For example, Microsoft Edge uses Chakra, Firefox uses Spider Monkey, Google Chrome uses V8. Because of these varieties of engines that sometimes JavaScript code can behave differently in one browser or another. The browser provides a runtime environment for JavaScript code. For example, the window or the document object allows us to work with the environment in which our code is running.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cv8fgiUCExch7WgBe6OSxw.jpeg" /></figure><p>Up to 2009 the only way to execute JavaScript code was inside of a browser. In 2009 a creative programmer Ryan Dahl came up with a brilliant idea. He thought it would be great to execute JavaScript outside of a browser. He took Google’s V8 engine which is the fastest JavaScript engine and embedded it inside a C++ program and called that program Node.JS. So, similar to a browser Node is a runtime environment for JavaScript code that contains a JavaScript engine that can execute JavaScript code. Also, it has certain objects that provide an environment for our JavaScript code but these objects are different from the environment objects we have in browsers. For example, we don’t have the document object instead we have other objects that give us more interesting capabilities, for example, we can work with the file system, listen for requests and a given port, and so on.</p><p>So in essence Node is a program that includes the V8 JavaScript engine plus some additional modules that give us capabilities not available inside the browser. Both Node and CHrome share the same JavaScript engine but they provide different runtime environments for JavaScript.</p><h4>How Node works???</h4><p>Well at first we have to know how the webserver works? Web server contains backend web application which can access by a client. That client could be a browser or a mobile application, etc. When a client is a web browser, it will expect HTML or data from the server but if the client is a mobile app, it will expect data from the server.</p><p>Now there have two kinds of request:</p><ul><li>CPU intensive task (done by server CPU)</li><li>I/O intensive task (request to another server, fetch data from the database, read data from a file system by the main server)</li></ul><p>We know that JavaScript is a single-threaded language. So Node JS works with a single thread. Here comes the main two concepts of Node JS.</p><ol><li>Non-Blocking I/O</li><li>Asynchronous (Call-Back)</li></ol><p><strong>Non-Blocking I/O </strong>means the single thread sends the request to other workers by accepting the request and not to block for the request. These workers are implemented by another concept known as<strong> libuv</strong>, which is a special type of library specially made for Node JS by C Language. <strong>Libuv</strong> gives us the Non-Blocking I/O concepts. So the thread can accept multiple requests without being blocked. But this mechanism works only for I/O intensive tasks. It’s not suitable for <strong>CPU intensive task</strong> because of the single thread. We work with Node JS for <strong>I/O intensive tasks</strong> when we want to interact with external systems like databases, file-system, or network.</p><p>Now, what will happen when the response is back after accepting the request. Therefore we have another concept for <strong>Asynchronous or Call-Back</strong>. After finishing the task it returns an event. That’s why Node JS has also known as <strong>event-based architecture</strong>.</p><p>There has another concept to talks about Node JS called Event Loop. It can assume a simple infinite while loop that waits continuously for a new task and delivers the task to the exact location one by one.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6dba434d974e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Most Common HTTP Request Methods — POST, GET, PUT, PATCH, and DELETE.]]></title>
            <link>https://minhazulhasansohan.medium.com/most-common-http-request-methods-post-get-put-patch-and-delete-b563acc22931?source=rss-e6d90bce461b------2</link>
            <guid isPermaLink="false">https://medium.com/p/b563acc22931</guid>
            <category><![CDATA[common-http-methods]]></category>
            <category><![CDATA[javascript-fetch-api]]></category>
            <category><![CDATA[http-methods]]></category>
            <category><![CDATA[http-request]]></category>
            <dc:creator><![CDATA[Minhazul Hasan Sohan]]></dc:creator>
            <pubDate>Mon, 21 Dec 2020 15:22:14 GMT</pubDate>
            <atom:updated>2020-12-21T15:22:14.745Z</atom:updated>
            <content:encoded><![CDATA[<h3>Most Common HTTP Request Methods — POST, GET, PUT, PATCH, and DELETE. A walkthrough with JavaScript’s Fetch API.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j3uC9VrzUK4SwTRxTh9YrA.png" /></figure><p>POST, GET, PUT, PATCH, and DELETE are the most-commonly-used HTTP verbs. These correspond to the <strong>CRUD</strong> (create, read, update, and delete) operations respectively. There are a number of other verbs too, but these are utilized less frequently.</p><ul><li>POST — <strong>CREATE</strong> a new record</li><li>GET — <strong>READ</strong></li><li>PUT —<strong>UPDATE</strong> If the record exists else <strong>CREATE</strong> a new record</li><li>PATCH — <strong>UPDATE </strong>(modify)</li><li>DELETE — <strong>DELETE</strong></li></ul><p>I will be using this fake API for a demonstration. with credits to <a href="https://jsonplaceholder.typicode.com/albums"><em>https://jsonplaceholder.typicode.com/albums</em></a></p><h3>The POST method</h3><p><strong>POST </strong>method used to submit an entity to the server and creates a new resource. In particular, it’s used to create subordinate resources. When a new resource is posted successfully, the API service will automatically associate the new resource by assigning it an ID (new resource URI). In sort, the <strong>POST</strong> method is used to insert new items in the backend server and it performs the create operation of the <strong>CRUD</strong> operation. It returns an HTTP status code <strong>201</strong> on successful creation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MkgbXx3Fr5ojBEvDmgYdvw.png" /><figcaption>post.html</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SmN9PmRE7FKqDUGwrVPd7Q.png" /><figcaption>POST Result</figcaption></figure><h3>The GET Method</h3><p>The <strong>GET </strong>method is used to retrieve data from the server. The <strong>GET </strong>is a read-only method, so there has no risk of corrupting the data. In the success case, <strong>GET </strong>returns a representation in <strong>XML </strong>or <strong>JSON </strong>and an HTTP response code of <strong>200 </strong>(OK). In an error case, it most often returns a <strong>404 </strong>(NOT FOUND) or <strong>400 </strong>(BAD REQUEST).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SH_noJKgYcRpw0bxDTBNtA.png" /><figcaption>get.html</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JZEMWnQmgkALgRYp1IB_gA.png" /><figcaption>GET Result</figcaption></figure><h3>The PUT Method</h3><p>The <strong>PUT </strong>method is used to update an existing resource. Firstly, The resource is identified by the URL and if it exists, then it is updated, otherwise, a new resource is created. The <strong>PUT </strong>is idempotent: means, calling the <strong>PUT </strong>method one or several time successively has the same effect (no side effect), whereas calling a <strong>POST</strong>(non-idempotent) request repeatedly have side effects of creating the same resource multiple times. <strong>PUT </strong>return HTTP status <strong>200 </strong>on successful update and HTTP status <strong>201 </strong>on successful creation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HIR1zUQSHhJ9_YsuWrhsJg.png" /><figcaption>put.html</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rXJbZIpsyiAZFrdNQ24c1g.png" /><figcaption>PUT Result</figcaption></figure><h3>The PATCH method</h3><p><strong>PATCH </strong>is very similar to the <strong>PUT </strong>method. It is used to apply partial modifications to an existing resource. The difference is that, in the <strong>PUT</strong> method the request-body contains the completely new version, whereas in the <strong>PATCH </strong>method the request-body contains the specific changes to the resource. A <strong>PATCH </strong>is not necessarily idempotent, although it can be. Contrast this with <strong>PUT</strong>; which is always idempotent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/623/1*RrKnI82U5MQFMbPIkPH6Kg.png" /><figcaption>Before Patch Request</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y34mtZCMR8xSNWu7nCXK2A.png" /><figcaption>patch.html</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ffu_0H4NjmUMoMzvl1UIZQ.png" /><figcaption>PATCH Result</figcaption></figure><h3>The DELETE Method</h3><p>The <strong>DELETE </strong>method deletes the specified resource by its URI. It returns an HTTP status code <strong>202 </strong>(Accepted) if the action will probably succeed but has not been implemented yet. On successful deletion, it returns an HTTP status code <strong>200 </strong>(OK). If the action has been implemented and no further information is to be supplied then it returns status code <strong>204 </strong>(No Content).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U0AzLFyLnn-wETGVSXgddg.png" /><figcaption>delete.html</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KAU25lkwTrvEFM5GpIcKyA.png" /><figcaption>DELETE Result</figcaption></figure><blockquote><strong>References:</strong></blockquote><blockquote><a href="https://www.restapitutorial.com/lessons/httpmethods.html">https://www.restapitutorial.com/lessons/httpmethods.html</a></blockquote><blockquote><a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods">https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods</a></blockquote><blockquote><a href="https://medium.com/@9cv9official/what-are-get-post-put-patch-delete-a-walkthrough-with-javascripts-fetch-api-17be31755d28">https://medium.com/@9cv9official/what-are-get-post-put-patch-delete-a-walkthrough-with-javascripts-fetch-api-17be31755d28</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b563acc22931" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Web Server — Functionality & Types]]></title>
            <link>https://minhazulhasansohan.medium.com/web-server-functionality-types-29cb2d2ad03d?source=rss-e6d90bce461b------2</link>
            <guid isPermaLink="false">https://medium.com/p/29cb2d2ad03d</guid>
            <category><![CDATA[servers]]></category>
            <category><![CDATA[types-of-web-server]]></category>
            <category><![CDATA[objective-of-servers]]></category>
            <category><![CDATA[web-server]]></category>
            <dc:creator><![CDATA[Minhazul Hasan Sohan]]></dc:creator>
            <pubDate>Sun, 20 Dec 2020 11:40:38 GMT</pubDate>
            <atom:updated>2020-12-20T11:40:38.599Z</atom:updated>
            <content:encoded><![CDATA[<h3>Web Server — Functionality &amp; Types</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*NKFV21r3zhWFgaLYuBz_9g.png" /><figcaption>The basic structure of a web server</figcaption></figure><h3><strong>What is a Web Server??? What does it do???</strong></h3><p>The basic objective of the web-server is to store, process, and deliver web pages to the users. The term web server can refer to hardware or software, or both of them working together.</p><p>On the hardware side, a web server is a computer that stores web server software and web pages, and their supporting files (HTML documents, images, style sheets, test, etc) are available on that computer.</p><p>On the software side, a web server includes several parts that control how web users access hosted files. At a minimum, this is an HTTP server. An HTTP server can be accessed through the domain names of the websites it stores, and it delivers the content of these hosted websites to the end user’s device. Besides HTTP, web servers also support SMTP (Simple Mail Transfer Protocol) and FTP (File Transfer Protocol), used for email, file transfer, and storage.</p><p>If we hear someone say, “My website is not responding”, it actually means that the web-server is not responding and therefore the website is not available.</p><h3>Types of Web Servers???</h3><p>There are mainly four types of web servers:</p><ul><li>Apache,</li><li>IIS (Internet Information Services),</li><li>Nginx and</li><li>LiteSpeed.</li></ul><h4>Apache web-server:</h4><p>Apache web server is one of the most popular open-source web servers developed by the Apache Software Foundation. It supports almost all the operating system such as Linux, Windows, Mac OS X, Unix FreeBSD, etc. It can be customized due to its modular structure. It is highly suitable as compared to other web servers. The administrative issue on it can be resolved easily. About 60% of the web server machines run the Apache Web Server.</p><h4>IIS(Internet Information Services) web-server:</h4><p>IIS is a Microsoft product and it offers all the features such as apache. But it’s not open-source so adding personal modules as well as modifying becomes a bit difficult. It supports all the platform that runs windows OS also we can get good customers to support if there is an issue.</p><h4>Nginx web-server:</h4><p>After Apache, Nginx is the next open source web server. It provides high performance, stability, simple configuration, and low resource uses. No threads are used to handle the requests by Nginx. Approximately 7.5% of all the domains are hosted by Nginx globally. Many web hosting companies have started this server.</p><h4>LiteSpeed web-server:</h4><p>Light speed is a commercial web server and it is the 4th popular web server on the internet. This service is compatible with most common Apache features such as mod_rewrite, .htaccess, and mod_security. It has the ability to load apache configuration files directly and work as a drop-in replacement Apache with almost all the hosting control panels. It can replace the Apache within 15 minutes without any downtime.</p><p><strong><em>Some more web servers are:-</em></strong></p><h4>lighttpd (pronounced ‘Lightly’):</h4><p>Lighttpd is also a free web server that is distributed with the FreeBSD operating system. This open-source web server is fast, secure, and consumes much less CPU power. Lighttpd can also run on Windows, Mac OS X, Linux, and Solaris operating systems. It currently runs approximately 0.1% of websites.</p><h4>Node JS:</h4><p>Node JS was originally written by Ryan Dahl in 2009. It is basically a server-side JavaScript environment that is used for network applications such as web servers. Having a small market position Node JS runs 0.2% of all websites. Node JS differs from other popular web servers because it is mainly a cross-platform runtime environment for building network applications. An event-driven architecture is applied by Node JS which is capable of asynchronous Input/Output.</p><h4>Jigsaw Server:</h4><p>Jigsaw (W3C’s Server) comes from the World Wide Web Consortium. It is open-source and free and can run on various platforms like Linux, Unix, Windows, Mac OS X Free BSD, etc. Jigsaw has been written in Java and can run CGI scripts and PHP programs.</p><h4>Sun Java System Web Server:</h4><p>This web-server from Sun Microsystems is suited for medium and large websites. It is a multi-threaded and multi-process web server that provides high performance, scalability, and reliability to enterprises. It also provides data security and command-line interface CLI support.</p><blockquote>References:</blockquote><blockquote>https://www.tutorialspoint.com/web_developers_guide/web_server_types.html</blockquote><blockquote>https://www.milesweb.in/blog/hosting/web-server-types-web-servers/</blockquote><blockquote>https://developer.mozilla.org/en-US/docs/Learn/Common_questions/What_is_a_web_server</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=29cb2d2ad03d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React JS — Some Fundamental Topics]]></title>
            <link>https://minhazulhasansohan.medium.com/react-js-some-fundamental-topics-b637f5acc2d7?source=rss-e6d90bce461b------2</link>
            <guid isPermaLink="false">https://medium.com/p/b637f5acc2d7</guid>
            <category><![CDATA[framework-vs-library]]></category>
            <category><![CDATA[react-fundamental]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[react-components]]></category>
            <dc:creator><![CDATA[Minhazul Hasan Sohan]]></dc:creator>
            <pubDate>Thu, 05 Nov 2020 10:29:59 GMT</pubDate>
            <atom:updated>2020-11-05T11:05:45.418Z</atom:updated>
            <content:encoded><![CDATA[<h3>React JS — Some Fundamental Topics</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9NTP0xAVDVXEqwCrRWEAuQ.png" /></figure><p>In this article, I am going to discuss some fundamental concepts about React JS.</p><h4>What is React JS?</h4><p>React JS is an open-source, front end, efficient, and flexible JavaScript library for building user interfaces. It is used to build single-page applications. It allows us to create reusable UI components. There have two buzzwords — Library &amp; FrameWork. React is a JavaScript <strong>library, </strong>not a <strong>framework</strong>.</p><h4>Difference between Library &amp; FrameWork:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/345/1*y_zUCSYVxjvZ13VisCixuw.png" /></figure><p>The library is a small package that made for some specific tasks. On the other hand, a framework is a gigantic thing that is made for the complete solution. When we call a method from a library, we are in control. But with a framework, the control is inverted: the framework calls us.</p><p>Assume you need to buy some shoes. You can go to either a particular shoe shop (Library) or a shopping mall (Framework). In the particular shoe shop, you can only buy your shoes but in a shopping mall, there have many other shops except the shoe shop.</p><p>The framework gives you a structure to complete a project. Working with a framework, many smart design decisions are already made for you. It gives us a clear path to focus on making good application-level logic. But it is not flexible. A framework usually wants us to code everything a certain way. We tied in a boundary when we use a framework.</p><p>But in the Library, it’s not a complete solution. We will often need to use an external library for another solution. But there has the freedom to writing code and decorate our application. eg: Redux library is often used with React for building complex web applications.</p><h4>JSX:</h4><p><strong>JSX</strong> stands for JavaScript XML. <strong>JSX</strong> allows us to write HTML in React. That means we can write HTML code into JavaScript code. It gives React to a superpower. Assume we need to show 20 cards about different products in our UI. And the number also might be increased. It’s obviously very irritating to write the same code continuously 20 times. There the solution gives by JSX. It allows us to make a component. Then we can write the same code only one time and recall them with different data by using a loop or any height order array method.</p><pre>import React from &#39;react&#39;</pre><pre>const products = [<br>  {img: &quot;.....&quot;, name: &quot;.....&quot;},<br>  {img: &quot;.....&quot;, name: &quot;.....&quot;},<br>  {img: &quot;.....&quot;, name: &quot;.....&quot;},<br>  ... ... ... ... ...,<br>  {img: &quot;.....&quot;, name: &quot;.....&quot;}<br>]</pre><pre>const Component = () =&gt; {<br>  return (<br>    &lt;div&gt;<br>      {<br>         products.map(product =&gt; {<br>           &lt;card&gt;<br>             &lt;img src={product.img} /&gt;<br>             &lt;h2&gt;{product.name}&lt;/h2&gt;<br>           &lt;/card&gt;<br>         }<br>       }<br>    &lt;/div&gt;<br>  )<br>}</pre><h3>Creating Components in React:</h3><p>Everything that shows on our UI is a component. React JS is built with components. There are two ways to build components.</p><ul><li><strong>Class Component </strong>&amp;</li><li><strong>Functional Component.</strong></li></ul><h4>Class Component:</h4><p>As we all know that JavaScript is also an Object-Oriented Programming Language (OOP) so it can allow us to write code in React through the functional component. And which is a very traditional way. People who previously worked on another framework can easily relate to this way.</p><pre>class Greetings ectends React.Component {<br>    render() {<br>        return &lt;h1&gt;Hello Everyone!!!&lt;/h1&gt;<br>    }<br>}</pre><h4>Functional Component:</h4><p>This is the simplest and also the modern way to build a react component. JavaScript is a multi-paradigm language. So we can freely mix and match object-oriented, procedural, and functional paradigms. Using functional components in React also allow some advantage. Like we can be using React Hook by building our React application through functional components.</p><pre>const Greetings = () =&gt; {<br>    return &lt;h1&gt;Hello Everyone!!!&lt;/h1&gt;<br>}</pre><h3>Component Lifecycle</h3><p>Each component has several <strong>lifecycle methods</strong> that you can override to run code at particular times in the process. We can control react components by these lifecycles.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/1*KatNYKo6JOe7GPBlzvcgbw.jpeg" /></figure><ul><li><strong>Mounting:<br></strong>1. constructor()<br>2. static getDerivedStateFromProps()<br>3. render()<br>4. componentDidMount()</li><li><strong>Updating:<br></strong>1.static getDerivedStateFromProps()<br>2. shouldComponentUpdate()<br>3. render()<br>4. getSnapshotBeforeUpdate()<br>5. componentDidUpdate()</li><li><strong>Unmounting:<br></strong>1. componentWillUnmount()</li><li><strong>Error Handling:<br></strong>1. static getDerivedStateFromError()<br>2. componentDidCatch()</li></ul><h3>React Props</h3><p>Props and PropTypes are an important mechanism for passing information between React components. It is immutable. React props looks like function arguments and attributes in HTML. Sending a prop into a component is just like an HTML attribute.</p><p><em>Parent Component:</em></p><pre>const Person = () =&gt; {<br>    return (<br>        &lt;PersonInfo name=&quot;Mr. Bulbul&quot; age=&quot;25&quot; /&gt;<br>    )<br>}</pre><p><em>Child Component:</em></p><pre>const PersonInfo = (props) =&gt; {<br>    return (<br>        &lt;h1&gt;I am {props.name}&lt;/h1&gt;<br>        &lt;h3&gt;I am {props.age} years old!&lt;/h3&gt;<br>    )<br>}</pre><p><strong>Let’s see some different types of props to React.</strong></p><pre>MyComponent.propTypes = {<br>    optionalArray: PropTypes.array,<br>    optionalBool: PropTypes.bool,<br>    optionalFunc: PropTypes.func,<br>    optionalNumber: PropTypes.number,<br>    optionalObject: PropTypes.object,<br>    optionalString: PropTypes.string,<br>    optionalSymbol: PropTypes.symbol,<br>    optionalNode: PropTypes.node,<br>    optionalElement: PropTypes.element,<br>    optionalElementType: PropTypes.elementType,<br>    optionalMessage: PropTypes.instanceOf(Message),<br>}</pre><h4>Default Props:</h4><p>React components take inputs in the argument called props. It passed down from the parent component. But what happens if our parent component doesn’t pass any attributes to the child component? What will be the props value??? — Here the default props idea comes from.</p><p>We can use the logical OR operator to set a default value. If our prop is missing then it displays the default value in place of the missing prop. This default value is known as default props.</p><p><em>Parent Component:</em></p><pre>const Person = () =&gt; {<br>    return (<br>        &lt;PersonInfo /&gt;<br>    )<br>}</pre><p><em>Child Component:</em></p><pre>const PersonInfo = (props) =&gt; {<br>    return (<br>        &lt;h1&gt;I am {props.name || &#39;Mr. X&#39;}&lt;/h1&gt;<br>        &lt;h3&gt;I am {props.age || 20} years old!&lt;/h3&gt;<br>    )<br>}</pre><blockquote>Reference:</blockquote><blockquote><a href="https://reactjs.org/">https://reactjs.org/</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b637f5acc2d7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JavaScript Function (ES6)]]></title>
            <link>https://minhazulhasansohan.medium.com/javascript-function-es6-9e8a98442ae5?source=rss-e6d90bce461b------2</link>
            <guid isPermaLink="false">https://medium.com/p/9e8a98442ae5</guid>
            <category><![CDATA[arrow-functions]]></category>
            <category><![CDATA[javascript-arrow-function]]></category>
            <category><![CDATA[function-javascript]]></category>
            <category><![CDATA[iife]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Minhazul Hasan Sohan]]></dc:creator>
            <pubDate>Wed, 04 Nov 2020 21:12:54 GMT</pubDate>
            <atom:updated>2020-12-20T11:35:01.133Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-9WHpDDQIqajuuDu05cgww.png" /></figure><p>In the programming world, a function is a block of organized, reusable code that is used to perform a single, related action. We can simply think of it as a machine where we give some input and it gives us some output, that’s it. In JavaScript, a function is also an object that means it is a non-primitive data type. JavaScript function starts with the keyword called function .There have two basic ways to declare a function in JavaScript. One is function expression another is function statement. Let’s start with a sum() function that takes 2 parameters (input) and return their addition as output.</p><pre>/// FUNCTION STATEMENT<br>function addTwoValue (a, b) {<br>    return a + b;<br>}<br>addTwoValue(3, 2); // 5</pre><pre>// FUNCTION EXPRESSION<br>var addTwoValue = function (a, b) {<br>    return a + b;<br>}<br>addTwoValue(3, 2); // 5</pre><p>But there has a limitation. We don&#39;t pass more than two parameters in the function. If we want the addition of more than two values then we also need to modify the function. There comes the <strong>arguments </strong>keyword.</p><h4>arguments :</h4><p>This is a special keyword for the JavaScript function. It can receive all the parameters inside of it and we can read those by giving the index value. But it can&#39;t read outside the function. Noted that it’s not a proper array it is an array-like object. The push(), pop(), shift(), unshift() etc method can’t perform by it.</p><pre>function addNumbers() {<br>    var sum = 0;<br>    for(var i = 0; i &lt; arguments.length; i++){<br>        sum += arguments[i];<br>    }<br>    return sum;<br>}<br>addNumbers(1, 2, 3, 4, 5); // 15</pre><h4>Anonymous Function:</h4><p>An anonymous function is a function without a name. An anonymous function is often not accessible after its initial creation. A function expression is similar to and has the same syntax as the anonymous function.</p><pre>let greetings = function() {<br>    console.log(&#39;Hello There!&#39;);<br>};<br>greetings(); // &#39;Hello There!&#39;</pre><p>But most of the time the anonymous function is used as a call back function.</p><pre>setTimeout(function() {<br>    console.log(&#39;Execute later after 5 second&#39;)<br>}, 5000);</pre><h4>Immediately Invoked Function Expression (IIFE):</h4><p>If we want to create a function and execute it immediately after the declaration then we can use IIFE, which is also an anonymous function.</p><pre>(function () {<br>    console.log(&#39;Immediately invoked function expression&#39;);<br>})();<br>// &#39;Immediately invoked function expression&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yZYRCYJnIaSF6CjFvXpuHQ.jpeg" /></figure><h3>Arrow Function:</h3><p>An arrow function is a new addition to JavaScript ES6. It is also known as Fat Arrow. This is one kind of Syntactic Sugar of our classical function. Arrow functions provide a more concise syntax for writing function expressions. They allow us to have implicit returns with a shorter syntax by removing curly brackets {} and return keyword. Let’s implement the addTwoValue() function with the arrow function.</p><pre>const addTwoValue = (a, b) =&gt; a + b;<br>addTwoValue(2, 3); // 5</pre><p>So it clearly shows the difference, how concise it is!</p><h3>Call-Back Function:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*JIegUx1x2VKuBYitL2zrxw.jpeg" /></figure><p>If we passed a function as an argument into <strong>another function </strong>or return a function from <strong>another function </strong>then <strong>another</strong> function is known as a Call-Back function. That&#39;s why the JavaScript function is also known as Call-Back Function.</p><pre>function explain_callBack(name, task) {<br>    console.log(&quot;Hello &quot; + name);<br>    task();<br>}<br>function washHand(){<br>    console.log(&quot;Wash your Hands&quot;);<br>}<br>function takeShower(){<br>    console.log(&quot;Take a Shower&quot;);<br>}</pre><pre>explain_callBack(&quot;Abul&quot;, washHand);<br>// Hello Abul<br>// Wash your Hands</pre><pre>explain_callBack(&quot;Kabul&quot;, takeShower);<br>// Hello Kabul<br>// Take a Shower</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9e8a98442ae5" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>