[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  =  

[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

[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

[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

Re: [Tutor] raw_input()

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

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 transmogribe...@gmail.com To: kumar s ps_pyt...@yahoo.com Cc: tutor@python.org Sent: Mon, March 15, 2010 7:19:24

[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

[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',

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 : a = [10,15,18,20,25,30,40] Hi Kumar

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

[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,last ... last

[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] looping problem

2006-09-23 Thread kumar s
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, 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

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

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 =

[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)

Re: [Tutor] files in a directory

2005-01-30 Thread kumar s
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 want. Hopefully it helps. -Jay On Sunday 30 January 2005 03:03 am, kumar s wrote: Hello. I wrote a parser

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

[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

[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

[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
+'\t'+cols[1]+'\t'+cols[2]) --- Danny Yoo [EMAIL PROTECTED] wrote: On Fri, 14 Jan 2005, kumar s wrote: for i in range(len(what)): ele = split(what[i],'\t') cor1 = ele[0] for k in range(len(my_report)): cols = split(my_report[k],'\t') cor

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

2005-01-13 Thread kumar s
[index]=' Try that. Argh, my head. You do some strange things to Python. Liam Clarke On Thu, 13 Jan 2005 10:56:00 -0800 (PST), kumar s [EMAIL PROTECTED] wrote: Dear group: My list looks like this: List name = probe_pairs Name=AFFX-BioB-5_at Cell1=96369 N

[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 this

[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

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

2005-01-11 Thread kumar s
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 option than what I have in my script. Could any one please help me

[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

[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 ). - Hit Hit_num1/Hit_num Hit_idgi|43442325|emb|BX956931.1|/Hit_id Hit_defDKFZp781D1095_r1 781 (synonym: hlcc4) Homo sapiens cDNA clone DKFZp781D1095 5', mRNA sequence./Hit_def

Re: [Tutor] Parsing a block of XML text

2004-12-31 Thread kumar s
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 250 KB ). [xml text cut] Hi Kumar, Just as a side note: have you looked at Biopython yet? http://biopython.org/ I

[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', '334:3',

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

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