2
$\begingroup$

I am interested in performing nucleotide sequence pattern-mining (regular expressions) which is 12 characters (sequences) in length from a dataset. Is that possible to script using MATLAB?

$\endgroup$
  • $\begingroup$ Dont use MATLAB for this.. it is too damn slow for these stuff.. Add more details on what do you want to search exactly and what is your input file like. $\endgroup$ – WYSIWYG Aug 19 '14 at 7:47
  • $\begingroup$ You can use Perl, Python or Awk for this kind of stuff (all of them have regex searches). Awk is my favourite; it is fast and doesn't require too much of code writing. $\endgroup$ – WYSIWYG Aug 19 '14 at 7:51
  • $\begingroup$ Alternately you can use R (search for regular expressions in R language), which allows you to construct your mining results in a format of a table, which each column containing the data you are interested! there are many packages in R that allows you to process many data types. I would say R is worth the investment to learn for any future data analysis. I use the RStudio to interact with the R language software. $\endgroup$ – Bez Aug 19 '14 at 9:53
  • $\begingroup$ For python, the Bio.motifs package from BioPython could be useful: biopython.org/DIST/docs/tutorial/Tutorial.html#sec244 $\endgroup$ – bli Aug 19 '14 at 15:14
1
$\begingroup$

I'm no expert in MATLAB but I know that it is possible to do regular expressions in MATLAB with the general rules explained here. However there are alternative approaches and softwares you could use to achieve this with softwares that are freely available and quite powerful in performing such functions. Although I'm aware that perl and python are the programs of choice for regular expression analysis; however I would urge you to consider the R language. R allows you to construct your mining results in a format of a table, which each column containing the data you are interested! there are many packages in R that allows you to process many data types. I would say R is worth the investment to learn for any future data analysis. I use the RStudio to interact with the R language software.

The best place to get help for MATLAB or R is the http://stackoverflow.com which you can sign on with you current account. In fact I have asked a few questions there on regular expressions and the community is very helpful however ensure that you show your attempt at the problem and where you are stuck in order to get a constructive responses!

$\endgroup$
1
$\begingroup$

With awk it is as simple as this (Assuming that the sequences are in fasta format and the sequences are not interrupted by line breaks):

awk -v p=<some_patttern> '/>/{name=$0} !/>/{
    s=$0
while (match(s,p)){
       print name,substr(s, RSTART, RLENGTH)
       s=substr(s, RSTART+RLENGTH)
    }

}' fastafile.fa

This script will print all matches for a pattern in a given set of sequences.I cannot explain how this script works in this forum; Stackoverflow would be more suitable for that.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.