rebkirl has asked for the wisdom of the Perl Monks concerning the following question:
Dear all,
I am quite new to Perl scripting and I am trying to solve the following:Given a list of mutlifasta file (file.txt):
>JJ57 MKIKLVTVGDAKEEYLIQGINEYLKRLNSYAKRETIEVPDEKAPEKLSDAEMLQVKEKEGEYVFVLAI NGKQLSSEEFSKEIFQTGISGKSNLTFTTCFSLGLSDSVLQRIMKGEPYHKL >JJ22 MDQNGASGSHPNRASTRKGAHARERGATVSAMSANRSNIIDEMAKICEADRQTFAIARRTRNESQ FFGFRTASNKAIEITEAMEKRGAMFLTQSKATDQLNGWQPSDEPDKTSAESEPWFRGKQLSSEEFS KEIFQTGISGKSNLTFTTCFSLGLSDSVLQRIMKGEPYHKL >JJ41 MWKTVAPIFAAIFAVGLCGTFRTNTRKGEPTTKCFVFVHDTKARIYQCTFKTWSCPWLNNIVSAQF QFVTGANYKIVVKLVGELFTETALFNWSSPTTIFTGLGTLITADKTLDCDSNML
Given a user input (i.e. JJ22) as argument, I want to check if the input is present in the file.txt and count all the motifs MT.KA (M or T, any letter (.) followed by K or A) in the JJ22 sequence.
I tried (unsuccessfully) the following code:
#!/usr/bin/perl use warnings; use strict; if(!open(MY_HANDLE, "file.txt")){ die "Cannot open the file\n"; } @content = <MY_HANDLE>; close(MY_HANDLE); print("Type the input ID: "); my $id = <STDIN>; chomp($id); foreach $row(@content){ chomp($row); if (@id=$row =~ /([MT].[KA]+)/g) { $numID=scalar(@id); print(“@id,$numID\n”); }
Thank you a lot for your help
|
|---|