Hello, I need some specific string related functionality and I find string functions in Python to be bit lacking. I am not sure if their are other functions that I can use. I did manage to write some code that seems to work but I am afraid it might not work as expected in all cases.
Lets say, I have following variables,
myString="RLFEG DNALIR" #some string
myFrag="NALIR" #known substring of above string
From these information, I would like to:
1) Get the
otherFrag= "RLFEGD" #complimentary fragment/substring of myFrag
2) Check if their is a specific letter within two spaces of the "fragmentat ion site" in otherFrag
I could not find any string functions that returned substrings except for split which I was able to make it work for me but it is not satisfactory at all and I am afraid their are bugs from exceptional cases that I might be overlooking. This i what I do right now:
1)
otherFrag=st.rs plit(myString,m yFrag,1)[0]
2)
proxCheck=(len( otherFrag)-1)-st.rfind(otherF rag,'specific_l etter') #proximity check
if (proxCheck==1) or (proxCheck==2):
multipleFlag=0
I guess I am just wondering if their are more powerful substring methods in python that I can use besides "split" functionality in string. For instance, something that returns substring of a string if I supply the starting and ending position. I suppose I can write a module myself.. hmm
Lets say, I have following variables,
myString="RLFEG DNALIR" #some string
myFrag="NALIR" #known substring of above string
From these information, I would like to:
1) Get the
otherFrag= "RLFEGD" #complimentary fragment/substring of myFrag
2) Check if their is a specific letter within two spaces of the "fragmentat ion site" in otherFrag
I could not find any string functions that returned substrings except for split which I was able to make it work for me but it is not satisfactory at all and I am afraid their are bugs from exceptional cases that I might be overlooking. This i what I do right now:
1)
otherFrag=st.rs plit(myString,m yFrag,1)[0]
2)
proxCheck=(len( otherFrag)-1)-st.rfind(otherF rag,'specific_l etter') #proximity check
if (proxCheck==1) or (proxCheck==2):
multipleFlag=0
I guess I am just wondering if their are more powerful substring methods in python that I can use besides "split" functionality in string. For instance, something that returns substring of a string if I supply the starting and ending position. I suppose I can write a module myself.. hmm
Comment