arrays - stripping a line with proper indent in python -


input:

$target: ensg00000097007|abl1 length: 3075 mirna : hsa-mir-203 length: 22  mfe: -30.5 kcal/mol p-value: 0.606919  position:  2745 target 5'   c             g     c 3'              gugguccuggaca   cac                  caccaggauuugu   gug     mirna  3' gau             aaa     5' 

i have strip last 2 lines , assign 2 arrays , read each character , obtain ouput shown down,

after stripping line should in format :

   caccaggauuugu   gug     gau             aaa      

and if line character read line1 should printed in lower case , if second line should in upper case

the final output of program should "gaucaccaggauuuguaaagug"

the code tried read did not strip lines in perfect alignment seen in input

here code used:

 import fileinput  import sys  sys import argv  script, filename = argv  file = open(filename)  og1 = "aguuccuuuguuuuggugacug"  pattern = "              "  pattern1 = "mirna  3'"  file = open(filename)  line in file:     if line.startswith(pattern):         n = file.next()         # print n[9:],#  bound mirna         in range(0, len(og1)):             print og1[i],         print "\n"          j in range(0,len(n)):             print n[j],' 

still further input problem

target: ensg00000142208|enst00000349310|akt1 length: 992 mirna : hsa-mir-125b-5p length: 22  mfe: -23.9 kcal/mol p-value: 0.610132  position  168 target 5' c     c               3'            cgcag   ggggu   aggga                guguu   uccca   ucccu     mirna  3'     caa     gag       5'   target: ensg00000142208|enst00000349310|akt1 length: 992 mirna : hsa-mir-149-3p length: 21  mfe: -36.6 kcal/mol p-value: 0.598318  position  798 target 5' c   uguc     agg        g 3'            cgc    gcccc   cccucccu                gug    cgggg   gggaggga     mirna  3' c   u        gca          5'   target: ensg00000142208|enst00000349310|akt1 length: 992 mirna : hsa-mir-185-5p length: 22  mfe: -27.8 kcal/mol p-value: 0.606550  position  733 target 5' c       cuccc   cagauga        c 3'            cgggagc     ccu       ucucucca                guccuug     gga       agagaggu     mirna  3'       ac                     5'   target: ensg00000142208|enst00000349310|akt1 length: 992 mirna : hsa-mir-199a-3p length: 22  mfe: -21.9 kcal/mol p-value: 0.611970  position  357 target 5' c      cc   ccu      u    c 3'            agccag   gc   gggcug cugu                uugguu   cg   ucugau gaca     mirna  3'      aca                  5'   target: ensg00000142208|enst00000349310|akt1 length: 992 mirna : hsa-mir-451a length: 21  mfe: -21.2 kcal/mol p-value: 0.612523  position  416 target 5' c      ucaacc           3'            cucagu      ugguggc                    gaguca      accauug         mirna  3' u      uu           ccaaa 5' 

file = open(filename)                                           segment in file.read().split("\n\ntarget"):                               interested_lines = segment.split('\n')[-3:-1]  #fetch last 2 lines      split1 = interested_lines[0].split()                                      split2 = interested_lines[1].split()[2:-1]                                in range(0,len(split1)<len(split2)):                                    split1.append("")                                                      req = ""                                                                  in range(0,len(split2)):                                                req += split2[i]+split1[i].lower()                                    j in range(i+1,len(split1)):                                              req += split1[j]                                                      print req 

output

aguguucaaucccagagucccu cgugucgggggcagggaggga aguccuugacggaaagagaggu auugguuacacgucugaugaca ugagucauuaccauugccaaa 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -