Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

editing python script file again and again

Hi I want to check the score value of the Amino acid sequence, for which I wrote the following code which works absolutely fine. But the problem is every time I have to edit the file. is there any way I can give the the amino acid sequence from the command interface.

AA_seq='AVTLSPQRS' # this is the input variable
sum=0

value={"V": 3.1,"Y":3.5,"W":4.7,"T" :5.3,"S":5.1,"P":3.7,
"F":4.7,"M":1.5,"K":8.9,"L":6,"I":4.3,"H":3.3,"G":7.1,
"E":7,"Q":5.4,"C":0.6,"D":7.6,"N":6,"R":8.7,"A":3.4}

print("Total length of sequence is:", len(AA_seq))
for i in AA_seq:
    
    sum+=value[i]


print("Total Score is :", sum)

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

If I understood your problem well, you can get it done by using ‘input’ function of python.
This will enable you to give input from the CLI. Below is the modifies code.

Hope this helps you.
Also if you want to avoid small/caps hedache for the input, you can use .upper().

Though its not required for this question.

AA_seq=input("write Amino Acid Sequence:" )
AA_seq=AA_seq.upper()

sum=0

value={"V": 3.1,"Y":3.5,"W":4.7,"T" :5.3,"S":5.1,"P":3.7,
"F":4.7,"M":1.5,"K":8.9,"L":6,"I":4.3,"H":3.3,"G":7.1,
"E":7,"Q":5.4,"C":0.6,"D":7.6,"N":6,"R":8.7,"A":3.4}

print("Total length of sequence is:", len(AA_seq))
for i in AA_seq:
    
    sum+=value[i]


print("Total Score is :", sum)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading