Search code examples
pythonbioinformaticsbiopython

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

  • 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)