-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #64 from SauravMishraaa/main
DNA Count App
- Loading branch information
Showing
1 changed file
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
from turtle import width | ||
import pandas as pd | ||
import streamlit as st | ||
import altair as alt #for graph | ||
from PIL import Image | ||
|
||
image=Image.open('dna.jpg') | ||
st.image(image,use_column_width=True) #displaying the image and allowing to expand till the column width | ||
|
||
st.write(""" | ||
# DNA Nucleotide Count Web App | ||
This app counts the nucleotide composition of query DNA. :) | ||
*** | ||
""") | ||
|
||
# Input Text Box | ||
|
||
#st.sidebar.header('Enter DNA sequence') | ||
|
||
st.header('Enter DNA sequence') | ||
sequence_input=">DNA Query 2\nGAACACGTGGAGGCAAACAGGAAGGTGAAGAAGAACTTATCCTATCAGGACGGAAGGTCCTGTGCTCGGG\nATCTTCCAGACGTCGCGACTCTAAATTGCCCCCTCTGAGGTCAAGGAACACAAGATGGTTTTGGAAATGC\nTGAACCCGATACATTATAACATCACCAGCATCGTGCCTGAAGCCATGCCTGCTGCCACCATGCCAGTCCT" | ||
|
||
#sequence=st.sidebar.text_area("Sequence input", sequence_input , height=250) | ||
sequence=st.text_area("Sequence input",sequence_input,height=250) | ||
sequence=sequence.splitlines() | ||
sequence=sequence[1:] #skips the sequence name(first line) | ||
sequence=''.join(sequence) #Concatenates list to string | ||
|
||
st.write(""" | ||
*** | ||
""") | ||
|
||
## Prints the input DNA sequence | ||
st.header('INPUT (DNA Query)') | ||
sequence | ||
|
||
## DNA nucleotide count | ||
st.header('OUTPUT (DNA Nucleotide Count)') | ||
|
||
##1.Print dictionary | ||
st.subheader('1.Print dictionary') | ||
def DNA_nucleotide_count(seq): | ||
d=dict([ | ||
('A',seq.count('A')), | ||
('T',seq.count('T')), | ||
('G', seq.count('G')), | ||
('C', seq.count('C')) | ||
]) | ||
return d | ||
X=DNA_nucleotide_count(sequence) | ||
X_label=list(X) | ||
X_values=list(X.values()) | ||
X | ||
|
||
## 2.Print text | ||
st.subheader('2.Print text') | ||
st.write('There are '+str(X['A'])+' adenine(A).') | ||
st.write('There are '+str(X['T'])+' thymine(T).') | ||
st.write('There are '+str(X['G'])+' guanine(G).') | ||
st.write('There are '+str(X['C'])+' cytosine(C).') | ||
|
||
### 3.Display DataFrame | ||
st.subheader('3.Display DataFrame') | ||
df=pd.DataFrame.from_dict(X,orient='index') | ||
df=df.rename({0:'count'},axis='columns') | ||
df.reset_index(inplace=True) | ||
df=df.rename(columns={'index':'nucleotide'}) | ||
st.write(df) | ||
|
||
### 4.Display Bar Chart using Altair | ||
st.subheader('4.Display Bar chart') | ||
p=alt.Chart(df).mark_bar().encode( | ||
x='nucleotide', | ||
y='count' | ||
) | ||
p=p.properties( | ||
width=alt.Step(80) #controls width of bar. | ||
) | ||
st.write(p) |