[Tutor] substitute using re.sub

2017-10-25 Thread kumar s via Tutor
Hi group, I am trying to substitute in the following way and i cannot. Could you point out whats wrong in what i am doing.  >>> z'.|D' >>> re.sub(z,'1',z)'111' I just want only  '1' and not '111'.  I want:>>> re.sub(z,'1',z)'1' re.sub is repeatedly inserting 3 times because z has .|D . How can I

[Tutor] count numbers only in the string

2012-03-06 Thread kumar s
Hi : I have some strings with both alpha-numeric strings. I want to add all the numbers in that string and leave characters and special characters.  1A0G19 5G0C25^C52 0G2T3T91 44^C70 How can I count only the numbers in the above.  1 A 0 G 19       =    1+0+19 = 20 5 G 0 C 25 ^C 52  =   5+0+2

[Tutor] counting elements in list

2010-09-15 Thread kumar s
Hi group: I have a list: k = ['T', 'C', 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'C', 'T', 'T', 'T', 'C', 'T', 'T', 'T', 'C', 'C', 'T', 'T', 'T', 'C', 'T', 'T', 'T', 'T', 'T', 'T'] the allowed elements are A or T or G or C. List can have any number of A or T or G or C My aim is to get a string o

[Tutor] help with loops

2010-03-25 Thread kumar s
Dear group: I need some tips/help from experts. I have two files tab-delimted. One file is 4K lines. The other files is 40K lines. I want to search contents of a file to other and print those lines that satisfy. File 1: chr X Y chr18337733 8337767 NM_001042682_cds_0_0_

Re: [Tutor] raw_input()

2010-03-15 Thread kumar s
thanks Benno. supplying 3.6 GB file is over-kill for the script. This is the reason I chose to input lines on fly. thanks Kumar - Original Message From: Benno Lang To: kumar s Cc: tutor@python.org Sent: Mon, March 15, 2010 7:19:24 PM Subject: Re: [Tutor] raw_input() On 16

Re: [Tutor] raw_input()

2010-03-15 Thread kumar s
", line 2, in second = raw_input() EOFError: EOF when reading a line How to notify that at EOF break and suppress exception. thanks - Original Message From: kumar s To: tutor@python.org Sent: Mon, March 15, 2010 6:52:26 PM Subject: [Tutor] raw_input() Dear group: I have a larg

[Tutor] raw_input()

2010-03-15 Thread kumar s
Dear group: I have a large file 3GB. Each line is a tab delim file. example lines of it: 585 chr1433 433 rs56289060 0 + - - -/C genomic insertion unknown 0 0 unknown between 1 585 chr1491 492 rs55998931 0

[Tutor] (no subject)

2010-01-07 Thread kumar s
dear tutors: I have two files. I want to take coordiates of an row in fileA and find if they are in the range of coordinates in fileB. If they are, I want to be able to map else, pass. thanks kumar file a: name loc x y a 4 4081159640811620 b 4

[Tutor] dealing with nested list values in a dictionary

2007-05-24 Thread kumar s
Dear group, unfortunately my previous post got tagged as 'homework' mail and got no responses. In short, I have a dictionary structure as depicted below. I want to go over every key and print the key,value pairs in a more sensible way. I have written a small piece of code. May I request tuto

[Tutor] please help formating

2007-05-22 Thread kumar s
hi group, i have a data obtained from other student(over 100K) lines that looks like this: (39577484, 39577692) [['NM_003750']] (107906, 108011) [['NM_002443']] (113426, 113750) [['NM_138634', 'NM_002443']] (106886, 106991) [['NM_138634', 'NM_002443']] (100708, 100742) [['NM_138634', 'NM_002443']]

Re: [Tutor] extracting numbers from a list

2006-10-18 Thread kumar s
correctly in terms of exons, transcripts. If not I would be happy to send you a pdf file with a figure. Thanks again. --- Danny Yoo <[EMAIL PROTECTED]> wrote: > > > On Mon, 16 Oct 2006, kumar s wrote: > > > I have a simple question to ask tutors: > > > > list A

Re: [Tutor] extracting numbers from a list

2006-10-17 Thread kumar s
In continuation to : Re: [Tutor] extracting numbers from a list hello list I have coordinates for exons (chunks of sequence). For instance: 10 - 50 A 10 - 20 B 35 - 50 B 60 - 70 A 60 - 70 B 80 - 100 A 80 - 100 B (The above coordinates and names are easier than in dat) Here my aim is to c

[Tutor] extracting numbers from a list

2006-10-16 Thread kumar s
hi : I have a simple question to ask tutors: list A : a = [10,15,18,20,25,30,40] I want to print 10 15 (first two elements) 16 18 (16 is last number +1) 19 20 21 25 26 30 31 40 >>> fx = a[0] >>> fy = a[1] >>> b = a[2:] >>> ai = iter(b) >>> last = ai.next() >>> for j in ai: ... print fy+1,l

Re: [Tutor] looping problem

2006-09-23 Thread kumar s
ay be it is just mental block.. thats the reason I seek help on forum. Thanks --- jim stockford <[EMAIL PROTECTED]> wrote: > > keep a counter in your loop. is this a homework > question? > > On Sep 23, 2006, at 8:34 AM, kumar s wrote: > > > hi, > > > &g

[Tutor] looping problem

2006-09-23 Thread kumar s
hi, the reason could be that I did not quite understand the concept of looping I have a list of 48 elements I want to create another two lists , listA and listB I want to loop through the list with 48 elements and select element with index 0,3,6,9,12 ..etc into listA select elements with

Re: [Tutor] Append function

2005-02-01 Thread kumar s
Hi Kent, Thank you for your suggestion. I keep getting IOError permission denied every time I try the tips that you provided. I tried to lookup on this error and did not get reasonable answer. Is this error something to do with Windows OS? Any suggestions. Thank you K >>> allColumns = [readC

Re: [Tutor] Append function

2005-02-01 Thread kumar s
Hi Danny: I have ~50 files in this format: File1: 680:209 3006.3 266:123 250.5 62:393 117.3 547:429 161.5 341:311 546.5 132:419 163.3 98:471 306.3 File 2: 266:123 168.0 62:393 119.3 547:429 131.0 341:311 162.3 132:419 149.5 98:471 85.0 289:215 207.0 75:553 517.0 I am generating these fi

[Tutor] Append function

2005-01-30 Thread kumar s
Hello: In append function instead of appending one below the other can I append one next to other. I have a bunch of files where the first column is always the same. I want to collect all those files, extract the second columns by file wise and write the first column, followed by the other colum

Re: [Tutor] TypeError: can only concatenate list (not "str") to list

2005-01-30 Thread kumar s
>nmr = nmrows[i] > pbr = cols[0] > print nmrow[i] +'\t'+cols[0] nmr = str(nmrows[i]) pbr = cols[0] print nmrow[i]+'\t'+cols[0] will print what you want. k --- Srinivas Iyyer <[EMAIL PROTECTED]> wrote: > Hello group, > I am trying to print rows from two lists together: > > how can i deal with

Re: [Tutor] files in a directory

2005-01-30 Thread kumar s
lob() lets you > grab a whole list of files > matching the wildcard just like if you typed "ls > *.dml" or whatever into a > command prompt. There wasn't too much info about > specifically how you needed > this to work, so this is a rough sketch of what you &

[Tutor] files in a directory

2005-01-30 Thread kumar s
Hello. I wrote a parser to parse spot intensities. The input to this parser i am giving one single file f1 = open('my_intensity_file.dml','r') int = f1.read().split('\n') my_vals = intParser(int) intParser return a list f2 = open('myvalues.txt','w') for line in my_vals: f2.write(line)

[Tutor] Cluster algorithms

2005-01-26 Thread kumar s
Hi: I am still trying to learn the OOPs side of python. however, things/circumstances dont seems to stop until I finish my practise and attaing higher understanding. may be, i am being pushed by circumstances into the stream and i am being tested if I can swim efficiently while I struggle with ba

[Tutor] Selecting text

2005-01-18 Thread kumar s
Dear group: I have two lists: 1. Lseq: >>> len(Lseq) 30673 >>> Lseq[20:25] ['NM_025164', 'NM_025164', 'NM_012384', 'NM_006380', 'NM_007032','NM_014332'] 2. refseq: >>> len(refseq) 1080945 >>> refseq[0:25] ['>gi|10047089|ref|NM_014332.1| Homo sapiens small muscle protein, X-linked (SMPX), mRNA'

Re: [Tutor] Faster procedure to filter two lists . Please help

2005-01-14 Thread kumar s
intr = what_dict[cor] my_final_report.append(cols[0]+'\t'+intr+'\t'+cols[1]+'\t'+cols[2]) --- Danny Yoo <[EMAIL PROTECTED]> wrote: > > > On Fri, 14 Jan 2005, kumar s wrote: > > > >>>for i in rang

[Tutor] Faster procedure to filter two lists . Please help

2005-01-14 Thread kumar s
Hi group: I have two lists a. 'my_report' and b. 'what'. In list 'what', I want to take 6649 (element1: 164:623\t6649) and write to a new list ( although I printed the result, my intension is to list.append(result). I took column 1 value of element 1 in what, which is 164:623 and checked in col

Re: [Tutor] Regular expression re.search() object . Please help

2005-01-13 Thread kumar s
hy are you deleting the object key? > > > > > >>> for i in range(len(probe_pairs)): > > > key = re.match(name1,probe_pairs[i]) > > > del key > > > print probe_pairs[i] > > > > Here's the easy way. Assuming t

[Tutor] Regular expression re.search() object . Please help

2005-01-13 Thread kumar s
Dear group: My list looks like this: List name = probe_pairs Name=AFFX-BioB-5_at Cell1=96369 N control AFFX-BioB-5_at Cell2=96370 N control AFFX-BioB-5_at Cell3=441 3 N control AFFX-BioB-5_at Cell4=441 4 N control AFFX-BioB-5_

Re: [Tutor] How to create a key-value pairs with alternative elements in a list ... please help.

2005-01-12 Thread kumar s
Thanks for this trick. Can I call this as category thermo-NUKE of list functions. -K --- Jeff Shannon <[EMAIL PROTECTED]> wrote: > kumar s wrote: > > > Problem: > > How do i capture every alternative element in list > a: > > > > I am unable to pump the

[Tutor] How to create a key-value pairs with alternative elements in a list ... please help.

2005-01-12 Thread kumar s
Dear group, I am frustrated to ask some questions on topics that I thought covered well. my logic is not correct. I have a simple list: >>> a ['a', 'apple', 'b', 'boy', 'c', 'cat'] I want to create a dictionary: dict = {'a':'apple', 'b':'boy', 'c':'cat'} my way of doing thi

Re: [Tutor] please help: conditional statement and printing element

2005-01-11 Thread kumar s
5 0 483:409 25 0 25 0 354:323 25 0 25 0 624:69 25 0 25 0 350:239 25 0 Is this a correct approach? Thanks K. --- kumar s <[EMAIL PROTECTED]> wrote: > Dear group, > For some reason my brain cannot think of any other

[Tutor] please help: conditional statement and printing element

2005-01-11 Thread kumar s
Dear group, For some reason my brain cannot think of any other option than what I have in my script. Could any one please help me in suggesting. What I have : (File name : psl) 22 2 457:411 25 0 25 0 457:411 25 0 25 0 457:411 25 0 25 0

[Tutor] Something is wrong in file input output functions.

2005-01-10 Thread kumar s
Dear group, I have written a small piece of code that takes a file and selects the columns that I am interested in and checks the value of the column on a condition (value that eqauls 25) and then write it the to another file. Code: import sys from string import split import string print "enter

Re: [Tutor] Parsing a block of XML text

2004-12-31 Thread kumar s
Hsp text node: Element node: Hsp_num text node:2 text node: --- Danny Yoo <[EMAIL PROTECTED]> wrote: > > > On Fri, 31 Dec 2004, kumar s wrote: > > > I am trying to parse BLAST output (Basic Local > Alignment Search Tool, > > size around more than 2

[Tutor] Parsing a block of XML text

2004-12-31 Thread kumar s
Dear group: I am trying to parse BLAST output (Basic Local Alignment Search Tool, size around more than 250 KB ). - 1 gi|43442325|emb|BX956931.1| DKFZp781D1095_r1 781 (synonym: hlcc4) Homo sapiens cDNA clone DKFZp781D1095 5', mRNA sequence. BX956931 693 - - 1 1164.13 58

[Tutor] Parsing a block of XML text

2004-12-31 Thread kumar s
Dear group: I am trying to parse BLAST output (Basic Local Alignment Search Tool, size around more than 250 KB ). - 1 gi|43442325|emb|BX956931.1| DKFZp781D1095_r1 781 (synonym: hlcc4) Homo sapiens cDNA clone DKFZp781D1095 5', mRNA sequence. BX956931 693 - - 1 1164.13 58

Re: [Tutor] O.T.

2004-12-29 Thread kumar s
30, Married, will soon be a dad., Live in Baltimore, U.S.A. and I am a Ph.D. student I lived in Denmark and Israel in the past as a part of my research life. Will finish my Ph.D., in Bioinformatics. Got introduced to computers at the age of 25 :-( and more happy it is not 52 :-) Programming l

[Tutor] How to substitute an element of a list as a pattern for re.compile()

2004-12-29 Thread kumar s
Hi Group: I have Question: How can I substitute an object as a pattern in making a pattern. >>> x = 30 >>> pattern = re.compile(x) My situation: I have a list of numbers that I have to match in another list and write them to a new file: List 1: range_cors >>> range_cors[1:5] ['161:378',

Re: [Tutor] Difference between for i in range(len(object)) andfor i in object

2004-12-12 Thread kumar s
Thank you for clearing up some mist here. In fact I was depressed by that e-mail because there are not many tutorials that clearly explains the issues that one faces while trying to code in python. Also, due to lack of people who are proficient in python around our univ. campus in baltimore, i am

[Tutor] Difference between for i in range(len(object)) and for i in object

2004-12-09 Thread kumar s
Dear group, My Tab delimited text looks like this: HG-U95Av2 32972_at432 117 HG-U95Av2 32972_at499 631 HG-U95Av2 32972_at12 185 HG-U95Av2 32972_at326 83 HG-U95Av2 32972_at62 197 I want to capture: co

Re: [Tutor] Please help matching elements from two lists and printing them

2004-12-08 Thread kumar s
g processing. As you asked I am all parsing out the pieces for a tab-delimitted text. I can get the values as CSV instead of tab delimitted. But what is the way using CSV to deal with this situation. thanks Kumar --- Bob Gailer <[EMAIL PROTECTED]> wrote: > At 02:51 PM 12/8/2004,

[Tutor] Please help matching elements from two lists and printing them

2004-12-08 Thread kumar s
Dear group, I have two tables: First table: spot_cor: 432 117 499 631 10 0 326 83 62 197 0 0 37 551 Second table: spot_int 0 0 98 1 0 5470 2 0 113 3 0 5240

Re: [Tutor] Printing two elements in a list

2004-12-07 Thread kumar s
d build a dict that maps '399:559' to the > full record. Looking up '399:559' in the dictionary > would be much, much faster than searching the > entire list. > > If you have multiple entries for '399:559' you could > have the dict map to a list. > >

[Tutor] Printing two elements in a list

2004-12-07 Thread kumar s
Dear group, I have two lists names x and seq. I am trying to find element of x in element of seq. I find them. However, I want to print element in seq that contains element of x and also the next element in seq. So I tried this piece of code and get and error that str and int cannot be conca

[Tutor] Removing a row from a tab delimitted text

2004-12-06 Thread kumar s
Dear group, I have a file, with Name identifier followed by two columns with numbers. Here is how my file looks: Name=3492_at Cell1=481 13 (The space between (481 and 13 is tab) Cell1=481 13 Cell1=481 13 Name=1001_at Cell1=481 13 Cell2=481 12 Cell1=481 13 Cell1=481 13 Cell2=481 12 Name=1002_a

[Tutor] Finding a part of an element in a list

2004-12-06 Thread kumar s
Dear Group, I have a list that is: List1 = ['Tyres','windsheild','A\CUnit','Model=Toyota_Corolla'] In other list I have : List2= ['Corolla','Accord','Camry'] I want to see if Corolla is there in list 1: The code: for i in range(len(List1)): if i in range(len(List2): print i

[Tutor] Can i define anywhere on file object function for reading a range of lines?

2004-12-05 Thread kumar s
Dear group, For instance I have a text that looks like following: Segment:Page 21 x x . x Segment:Page 22 .

[Tutor] How to select particular lines from a text

2004-12-04 Thread kumar s
Dear group, This is continuation to my previous email with sugject line "Python regular expression". My text file although, looks like .ini file, but it is not. It is a chip definition file from Gene chip. it is a huge file with over 340,000 lines. I have particular set of question in general

[Tutor] Python regular expression

2004-12-03 Thread kumar s
Dear group, I have a file with 645,984 lines. This file is composedcompletely of bocks. For e.g. [Unit111] Name=NONE Direction=2 NumAtoms=16 NumCells=32 UnitNumber=111 UnitType=3 NumberBlocks=1 [Unit111_Block1] Name=31318_at BlockNumber=1 NumAtoms=16 NumCells=32 StartPosition=0 StopPosition=1