Update app.py
Browse files
app.py
CHANGED
|
@@ -44,7 +44,31 @@ def parse_genbank(uploaded_file):
|
|
| 44 |
|
| 45 |
return organism, gene_info, cds_info, gc_content, len(record.seq), feature_types, str(record.seq)
|
| 46 |
|
| 47 |
-
# Additional functions (calculate_gc_content, calculate_kmers, add_protein_features)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
# Function to generate genome diagram
|
| 50 |
def create_genome_diagram(genbank_content, output_file_path):
|
|
|
|
| 44 |
|
| 45 |
return organism, gene_info, cds_info, gc_content, len(record.seq), feature_types, str(record.seq)
|
| 46 |
|
| 47 |
+
# Additional functions (calculate_gc_content, calculate_kmers, add_protein_features)
|
| 48 |
+
# Function to calculate GC content over genome
|
| 49 |
+
def calculate_gc_content(sequence, window_size=1000):
|
| 50 |
+
gc_content = [
|
| 51 |
+
(sequence[i:i+window_size].count('G') + sequence[i:i+window_size].count('C')) / window_size * 100
|
| 52 |
+
for i in range(0, len(sequence) - window_size + 1, window_size)
|
| 53 |
+
]
|
| 54 |
+
return gc_content
|
| 55 |
+
|
| 56 |
+
# Function to calculate k-mers
|
| 57 |
+
def calculate_kmers(sequence, k):
|
| 58 |
+
kmers = Counter([sequence[i:i+k] for i in range(len(sequence) - k + 1)])
|
| 59 |
+
return kmers
|
| 60 |
+
|
| 61 |
+
# Function to add molecular weight and isoelectric point to CDS information
|
| 62 |
+
def add_protein_features(cds_info):
|
| 63 |
+
for cds in cds_info:
|
| 64 |
+
if cds['Protein'] != 'N/A':
|
| 65 |
+
prot_analysis = ProteinAnalysis(cds['Protein'])
|
| 66 |
+
cds['Molecular Weight'] = prot_analysis.molecular_weight()
|
| 67 |
+
cds['Isoelectric Point'] = prot_analysis.isoelectric_point()
|
| 68 |
+
else:
|
| 69 |
+
cds['Molecular Weight'] = 'N/A'
|
| 70 |
+
cds['Isoelectric Point'] = 'N/A'
|
| 71 |
+
return cds_info
|
| 72 |
|
| 73 |
# Function to generate genome diagram
|
| 74 |
def create_genome_diagram(genbank_content, output_file_path):
|