in reply to Find a sequence in a multifasta files and motifs

First things first. Generate a separate file for each amino acid sequence. Put these flat files into a separate folder. Label each file by the FASTA code. You may then be in a position to put each line of each sequence into the elements of an array. I'm assuming that the sequences correspond to particular proteins.


Looking at your code. I have never seen the following before:

if(!open(MY_HANDLE, "file.txt")){
Try to keep to what you might find in a text book.

Your taking a single argument as an id and then worked with an array @id. That needs to be fixed.

I am assuming that you know that your regular expression does not match what you have said in the text.The standard input is the protein code ID but the regular expression that is search for is a protein motif. You are jumping ahead of yourself in the code. I expect that you will modify the program to then allow for alternative protein motifs to be inputed by the user.

Replies are listed 'Best First'.
Re^2: Find a sequence in a multifasta files and motifs
by haukex (Archbishop) on Jun 30, 2019 at 10:53 UTC
    I have never seen the following before: if(!open(MY_HANDLE, "file.txt")){ Try to keep to what you might find in a text book.

    TIMTOWTDI - if(!open(MY_HANDLE, "file.txt")){ die "Cannot open the file\n"; } is pretty much exactly* the same as open MY_HANDLE, "file.txt" or die "Cannot open the file\n";, but the former might be much more familiar to someone coming from a language such as C.

    Personally I'd just have pointed out that generally the three-argument open and lexical filehandles have several advantages over the two-argument open and bareword filehandles, and that it's usually nicer to include the filename and $! in the error message.

    * Update: One difference is that if introduces a new scope, which would become relevant when using lexical filehandles. But as currently written, they're the same.

Re^2: Find a sequence in a multifasta files and motifs
by rebkirl (Acolyte) on Jun 28, 2019 at 10:08 UTC
    Thanks for your suggestions. I fixed the regex mistake