Created
September 23, 2022 20:07
-
-
Save Spebby/feeb3a519429267687dfce6c8cb52da0 to your computer and use it in GitHub Desktop.
GC analyzer
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
#!/usr/bin/env python3 | |
"""takes in a DNA string and outputs GC content.""" | |
class RosalindAnalyzer: | |
# takes in a string, returns a decimal representing the GC content of the string to 3 decimal places. | |
@staticmethod | |
def Analyzer(inStr: str): | |
GCString = ""; | |
for char in inStr: | |
if char in ("G", "C"): | |
# in the future I can simply use str.count("G") and str.count("C") to get the number of Gs and Cs in the string. | |
GCString += char; | |
# formats to 3rd decimal place. | |
return f"{(len(GCString) / len(inStr)) * 100:.3f}"; | |
print("Input a DNA string, and this program will return the GC content of it."); | |
string = input(); | |
string = string.upper(); | |
print(f'recieved: "{string[0:10]}..."'); | |
print(f'The GC content of the string is, "{RosalindAnalyzer.Analyzer(string)}%"'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment