Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I have two files. A 'sequence' file, which looks like this.
>ONE IRLA >TWO REFT >THREE HTED
and a set of correponding 'co-ordinate' files. The name of the co-ordinate file that corresponds to a particular sequence in the sequence file is highlighted by '>' a line above the actual sequence. Each of these files is made up of entries. Each entry is numbered. Some co-ordinate files start with entry number 1 but not all. The one below (the co-ordinate file named 'ONE'), for example, starts with an entry numbered 12.
12 14.620 35.834 -16.759 1.00 11.04 13 15.922 36.983 -19.044 1.00 11.22 14 14.326 37.148 -21.240 1.00 11.40 15 11.528 38.248 -23.343 1.00 12.44
This corresponds to the first sequence in the sequence file
IRLA
I need to assign each letter in that sequence with the corresponding entry in the corresponding co-ordinate file. You read the sequence file from left to right with each letter needing to be mapped to an numbered entry in the co-ordinate file. So .. for the first letter 'R' in the sequence, it has to be mapped to entry number 13 in the co-ordinate file - the second letter in the sequence 'R', it corresponds to the second entry in the co-ordinate file, which in this case is entry 13. The resulting text file should look like this
I 12 R 13 L 14 A 15
I'm not sure what the best way of going about writing a perl script for this is. Any advice/hints much appreciated. The real examples are obviously far larger than the test case presented here

In reply to mapping data between files by Angharad

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (6)
As of 2024-04-23 13:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found