thanks kim..

On Sat, Feb 6, 2010 at 2:36 AM, Namshin Kim <deepr...@gmail.com> wrote:

> I think you need to give arguments.
>
> [deepr...@s50 ~]$ python tt.py 2 4 20
> 0 1
> TCCAAGG
> sequence identity to next sequence : 0.285714285714
> 2 As  2 Cs  2 Gs  1 Ts
> None
> ACCCGTTCTACTAGT
> 3 As  5 Cs  2 Gs  5 Ts
> None
>
>
>
>
>   On Sat, Feb 6, 2010 at 6:22 PM, chintan pathak <
> chintanpatha...@gmail.com> wrote:
>
>>   Hi guys,
>>
>> When I run the below code it gives me an index error: *List Index out of
>> range* at setsize = int(sys.argv[1]) in the code
>>
>> Can you help me fix the problem.
>>
>>
>> import random
>> import sys
>>
>> #function that simulates the DNA sequence
>> def simulate_sequence(length):
>>     dna = ['A', 'C', 'G', 'T']
>>     sequence = ''
>>     for i in range(length):
>>         sequence += random.choice(dna)
>>     return sequence
>>
>> #function that determines the nucleotide frequencies
>> def nucleotide_percentage(sequence):
>>     print str(sequence.count('A')) + ' As ',
>>     print str(sequence.count('C')) + ' Cs ',
>>     print str(sequence.count('G')) + ' Gs ',
>>     print str(sequence.count('T')) + ' Ts'
>>
>> #function that determines the sequence identities
>> def sequence_identity(set):
>>     iden = []
>>     count = 0.0
>>     for x in range(len(set)-1):
>>         print str(x), str(x+1)
>>         for n in range(len(set[x])):
>>             if set[x][n] == set[x+1][n]:
>>                 count += 1
>>         iden.append(count/len(set[x]))
>>         count = 0.0
>>     return iden
>>
>>
>> #get three values from the parameters
>>
>> *setsize = int(sys.argv[1])*      #number of sequences to simulate
>> minlength = int(sys.argv[2])    #minimum sequence length
>> maxlength = int(sys.argv[3])    #maximum sequence length
>>
>> sequenceset = []
>> for i in range(setsize):
>>     rlength = random.randint(minlength, maxlength)
>>     sequenceset.append(simulate_sequence(rlength))
>>
>> identity = sequence_identity(sequenceset)
>>
>> #print the results
>> for i in range(len(sequenceset)):
>>     print sequenceset[i]
>>     if i < len(sequenceset)-1:
>>         print 'sequence identity to next sequence : ' + str(identity[i])
>>     print nucleotide_percentage(sequenceset[i])
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "pygr-dev" group.
>> To post to this group, send email to pygr-...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> pygr-dev+unsubscr...@googlegroups.com<pygr-dev%2bunsubscr...@googlegroups.com>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/pygr-dev?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "pygr-dev" group.
> To post to this group, send email to pygr-...@googlegroups.com.
> To unsubscribe from this group, send email to
> pygr-dev+unsubscr...@googlegroups.com<pygr-dev%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/pygr-dev?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"pygr-dev" group.
To post to this group, send email to pygr-...@googlegroups.com.
To unsubscribe from this group, send email to 
pygr-dev+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/pygr-dev?hl=en.

Reply via email to