This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Script To Calculate Word Frequency For Many Sequences

Hello!

Who can help me with a writing a script?

1. For each file in the set (archive, probably):

Open input nucleotide sequence (.embl format is desirable, but fasta format is possible);

Calculate the observable frequency for all possible words based on input word size (e.g. number of all possible words for word size = 3 (triplet) is 64). Obs. Frequency = Obs Count/Total count [Сompseq is work in a similar way, but not support a batch processing].

Shift the reading frame by 1 nucleotide and repeat the previous step (number of shifts = word size - 1). The file with frequencies for each file in the set save as name_of_the_file(id of a contig).dic(+word size). It looks something like this (word size = 2):

# Word    Obs Count    Obs Frequency    
AA    194        0.0757221    
AC    129        0.0503513    
AG    203        0.0792350   
AT    185        0.0722092  
CA    212        0.0827479 
CC    174        0.0679157
CG    49          0.0191257 
CT    174        0.0679157   
GA    175        0.0683060
GC    142        0.0554254   
GG    131        0.0511319  
GT    118        0.0460578 
TA    130        0.0507416  
TC    163        0.0636222  
TG    184        0.0718189   
TT    199        0.0776737

2. Make a summary file, something like this (example for word size = 2)

                                AA         AC         AG         AT         CA         CC         CG         CT         GA         GC         GG         GT         TA         TC         TG         TT
comp730_c0_seq1   description   0,019133   0,015228   0,019914   0,021476   0,019914   0,011324   0,003124   0,016009   0,025381   0,019524   0,017571   0,01679    0,015228   0,0164     0,016009   0,0246
comp741_c0_seq1   description   0,016957   0,012832   0,010541   0,016957   0,008708   0,012832   0,009166   0,01604    0,015124   0,010541   0,0055     0,010082   0,01604    0,028414   0,010999   0,021998
comp752_c0_seq1   description   0,025503   0,012081   0,02953    0,022371   0,010738   0,009843   0,009396   0,008054   0,026846   0,024161   0,021477   0,012528   0,012081   0,021029   0,019687   0,018792
comp767_c0_seq1   description   0,030486   0,016032   0,028384   0,016557   0,021288   0,010775   0,007096   0,009461   0,028121   0,016557   0,021025   0,017608   0,011301   0,01866    0,02339    0,020237
comp773_c0_seq1   description   0,044055   0,017054   0,023685   0,026528   0,014685   0,020369   0,010422   0,008053   0,026528   0,01658    0,016106   0,014211   0,024633   0,01658    0,016106   0,020369
..
..
..
..
..
..
compseq frequency homework script

If a word (say, AAAAACCCCCTTTTTGGGGG) doesn't exist, but you're looking at 10bp words, do you want the count to be 0, or do you just not want it to show up in the final list?

I think, it's necessary to show the words that have a frequency of zero.

This is not a bioinformatics question.This is a niche string manipulation question that uses sequence data. I'm not sure if this belongs here.

Hello thom_otis!

We believe that this post does not fit the main topic of this site.

Looks like homework to me.

For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.

If you disagree please tell us why in a reply below, we'll be happy to talk about it.

Cheers!

0 answers

No answers yet.

Log in to answer this question.