Assignment

Write a function pattern2number that takes a DNA string $$s$$. The function must return the lexicographic index of $$s$$ among all DNA strings of length $$|s|$$.

Example

In the following interactive session, we assume the FASTA file data.fna1 to be located in the current directory.

>>> pattern2number('AGT')
11
>>> pattern2number('CTTCTCACGTACAACAAAATC')
2161555804173

>>> from Bio import SeqIO
>>> pattern2number(*SeqIO.parse('data.fna', 'fasta'))
401677730568729587