Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Extremely Long String Help
#1
Hi,
I'm working with DNA and am trying to run a simple program to clean up the sequences I get from online databases. I need to convert all lower case letters to uppercase ones and ignore anything that isn't an A, T, C, or G. I want this new string in a new global variable. Unfortunately the code I currently have (below), which does work, is EXTREMELY slow. Does anyone know a better/faster/more efficient means of doing this? I currently have it running over the human genome which is 6.6 billion characters long and it has been going for 7 days and counting.

def CleanText(Text):
Gen = ""
global Genome
Genome = Gen
for i in Text:
if i == "a":
Gen += "A"
elif i == "t":
Gen += "T"
elif i == "c":
Gen += "C"
elif i == "g":
Gen += "G"
Genome = Gen

Sorry, I forgot to format it correctly.

def CleanText(Text):
Gen = ""
global Genome
Genome = Gen
for i in Text:
if i == "a":
Gen += "A"
elif i == "t":
Gen += "T"
elif i == "c":
Gen += "C"
elif i == "g":
Gen += "G"
Genome = Gen 
Reply


Messages In This Thread
Extremely Long String Help - by Destry23000 - Aug-29-2018, 10:46 AM
RE: Extremely Long String Help - by Gribouillis - Aug-29-2018, 12:21 PM
RE: Extremely Long String Help - by buran - Aug-29-2018, 12:55 PM
RE: Extremely Long String Help - by buran - Aug-29-2018, 02:06 PM
RE: Extremely Long String Help - by Gribouillis - Aug-29-2018, 02:21 PM
RE: Extremely Long String Help - by Destry23000 - Aug-29-2018, 02:46 PM
RE: Extremely Long String Help - by Gribouillis - Aug-29-2018, 02:47 PM
RE: Extremely Long String Help - by Gribouillis - Aug-29-2018, 04:17 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Isolate a word from a long string nicocorico 2 1,571 Feb-25-2022, 01:12 PM
Last Post: nicocorico
  Split a long string into other strings with no delimiters/characters krewlaz 4 2,829 Nov-15-2019, 02:48 PM
Last Post: ichabod801
  How to create a long string by concatenating two lists nikhilkumar 11 7,593 Jul-12-2017, 05:36 PM
Last Post: wavic

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020