perl - Change the character length of single line strings using regex -


after "text" itemprop = "text">

I have a GenBank file with a \ N (at least one that contains single lines of wire with 60 bases The scene is extracted) How to modify the sequence using Perl, it uses 120 lines using regescs for each line and does not bioparlate. Original format:

  1 agatggcggc gctgaggggt cttgggggct ctaggccggc cacctactgg tttgcagcgg 61 agacgacgca tggggcctgc gcaataggag tacgctgcct gggaggcgtg actagaagcg 121 gaagtagttg tgggcgcctt tgcaaccgcc tgggacgccg ccgagtggtc tgtgcaggtt 181 cgcgggtcgc tggcgggggt cgtgagggag tgcgccggga gcggagatat ggagggagat 241 ggttcagacc cagagcctcc agatgccggg gaggacagca agtccgagaa tggggagaat 301 gcgcccatct actgcatctg ccgcaaaccg gacatcaact gcttcatgat cgggtgtgac 361 aactgcaatg agtggttcca tggggactgc atccggatca ctgagaagat ggccaaggcc 421 atccgggagt ggtactgtcg ggagtgcaga gagaaagacc ccaagctaga gattcgctat 481 cggcacaaga agtcacggga gcgggatggc aatgagcggg acagcagtga gccccgggat  

I only managed to make them In the wire with a length of 60 characters, still trying to figure out how Missed elongate 120 characters

  my line @ = & lt; $ FH_IN & gt ;; My $ line foreach (@lines) {if ($ line = ~ m / (^ \ s * \ d + \ s) [acgt] {10} \ s /) {$ line = ~ s / $ 1 //; $ Line = ~ s / / g; Print $ line; }  

}

Examples of input:

  agatggcggcgctgaggggtcttgggggctctaggccggccacctactggtttgcagcgg agacgacgcatggggcctgcgcaataggagtacgctgcctgggaggcgtgactagaagcg gaagtagttgtgggcgcctttgcaaccgcctgggacgccgccgagtggtctgtgcaggtt cgcgggtcgctggcgggggtcgtgagggagtgcgccgggagcggagatatggagggagat ggttcagacccagagcctccagatgccggggaggacagcaagtccgagaatggggagaat gcgcccatctactgcatctgccgcaaaccggacatcaactgcttcatgatcgggtgtgac aactgcaatgagtggttccatggggactgcatccggatcactgagaagatggccaaggcc atccgggagtggtactgtcgggagtgcagagagaaagaccccaagctagagattcgctat  
.

There are 60 bases for each single line string

update (still not deliver seq lines with 120 bases long):

  My @ seq_60; My $ line foreach (@lines) {if ($ line = ~ m / (^ \ s * \ d + \ s) [acgt] {10} \ s /) {$ line = ~ s / $ 1 //; $ Line = ~ s / / g; Push (@ seq_60, line $); }} My @ output; (; $ Position & lt; @ seq_60, my $ position = 0 $ position + = 2) {push (. @output, $ seq_60 [$ status] $ seq_60 [$ status + 1]); } Print @ output;  

How about:

  s / (^ | \ N) (<^ \ n] {60}) \ n / $ 1 $ 2 / g  

In action:

  strict use; Use warnings; Use 5.014; My $ str = q / agatggcggcgctgaggggtcttgggggctctaggccggccacctactggtttgcagcgg agacgacgcatggggcctgcgcaataggagtacgctgcctgggaggcgtgactagaagcg gaagtagttgtgggcgcctttgcaaccgcctgggacgccgccgagtggtctgtgcaggtt cgcgggtcgctggcgggggtcgtgagggagtgcgccgggagcggagatatggagggagat ggttcagacccagagcctccagatgccggggaggacagcaagtccgagaatggggagaat gcgcccatctactgcatctgccgcaaaccggacatcaactgcttcatgatcgggtgtgac aactgcaatgagtggttccatggggactgcatccggatcactgagaagatggccaaggcc atccgggagtggtactgtcgggagtgcagagagaaagaccccaagctagagattcgctat /; $ Str = ~ s / (^ | \ n) ([^ \ n] {60}) \ n / $ 1 $ 2 / g; Say $ str;  

Output:

  agatggcggcgctgaggggtcttgggggctctaggccggccacctactggtttgcagcggagacgacgcatggggcctgcgcaataggagtacgctgcctgggaggcgtgactagaagcg gaagtagttgtgggcgcctttgcaaccgcctgggacgccgccgagtggtctgtgcaggttcgcgggtcgctggcgggggtcgtgagggagtgcgccgggagcggagatatggagggagat ggttcagacccagagcctccagatgccggggaggacagcaagtccgagaatggggagaatgcgcccatctactgcatctgccgcaaaccggacatcaactgcttcatgatcgggtgtgac aactgcaatgagtggttccatggggactgcatccggatcactgagaagatggccaaggccatccgggagtggtactgtcgggagtgcagagagaaagaccccaagctagagattcgctat  

Clarification:

  (^ | \ n): Group 1, start of string or line breaks (: Start Group 2 [^ \ n] {60}: Whatever is not a line Edit as per the comment:   

Join rows from the udhi: for P <

  my @out; (my $ i = 0; $ i & lt; @ar; $ I + = 2) {Chomp (in $ [$ i]); push @ out, $ [$ i] in $. [$ I + 1]; $  

Comments

Popular posts from this blog

winforms - C# Form - Property Change -

javascript - amcharts makechart not working -

java - Algorithm negotiation fail SSH in Jenkins -