[Tutor] Script for Parsing string sequences from a file

2011-04-15 Thread Spyros Charonis
Hello, I'm doing a biomedical degree and am taking a course on bioinformatics. We were given a raw version of a public database in a file (the file is in simple ASCII) and need to extract only certain lines containing important information. I've made a script that does not work and I am having tro

[Tutor] Deleting strings from a line

2011-04-26 Thread Spyros Charonis
Hello, I've written a script that scans a biological database and extracts some information. A sample of output from my script is as follows: LYLGILLSHAN AA3R_SHEEP26331 LYMGILLSHAN AA3R_HUMAN26431 MCLGILLSHANAA

[Tutor] Filtering out unique list elements

2011-05-03 Thread Spyros Charonis
Dear All, I have built a list with multiple occurrences of a string after some text processing that goes something like this: [cat, dog, cat, cat, cat, dog, dog, tree, tree, tree, bird, bird, woods, woods] I am wondering how to truncate this list so that I only print out the unique elements, i.e

[Tutor] triple-nested for loop not working

2011-05-04 Thread Spyros Charonis
Hello everyone, I have written a program, as part of a bioinformatics project, that extracts motif sequences (programmatically just strings of letters) from a database and writes them to a file. I have written another script to annotate the database file (in plaintext ASCII format) by replacing ev

[Tutor] Printing output from Python program to HTML

2011-05-10 Thread Spyros Charonis
Hello everyone, I have a Python script that extracts some text from a database file and annotates another file, writing the results to a new file. Because the files I am annotating are ASCII, I am very restricted as to how I can annotate the text, and I would like to instead write the results to H

Re: [Tutor] Printing output from Python program to HTML

2011-05-10 Thread Spyros Charonis
Thanks, very simple but I missed that because it was supposed be in HTML code! On Tue, May 10, 2011 at 1:16 PM, Spyros Charonis wrote: > Hello everyone, > > I have a Python script that extracts some text from a database file and > annotates another file, > writing the result

[Tutor] Problem with printing Python output to HTML Correctly

2011-05-10 Thread Spyros Charonis
Hello, I know I posted the exact same topic a few hours ago and I do apologize for this, but my script had a careless error, and my real issue is somewhat different. I have a Python script that extracts some text from a database file and annotates another file, writing the results to a new file.

Re: [Tutor] Problem with printing Python output to HTML Correctly

2011-05-10 Thread Spyros Charonis
Hi all, No need to post answers, I figured out where my mistake was. Spyros On Tue, May 10, 2011 at 5:11 PM, Spyros Charonis wrote: > Hello, > > I know I posted the exact same topic a few hours ago and I do apologize for > this, but my script had a careless error, and my real issue

Re: [Tutor] Problem with printing Python output to HTML Correctly

2011-05-10 Thread Spyros Charonis
newline = line.replace(item, annotation) # sys.stdout.write(newline) align_file_appmode.write(newline) motif_file.close() align_file_rmode.close() align_file_appmode.close() the line annotation = ""+item+"" added a span and set the color in CSS. On Tue, M

[Tutor] String Processing Query

2011-05-16 Thread Spyros Charonis
I have a file with the following contents: >from header1 abcdefghijkl mnopqrs tuvwxyz * >from header2 poiuytrewq lkjhgfdsa mnbvcxz * My string processing code goes as follows: file1=open('/myfolder/testfile.txt') scan = file1.readlines() string1 = ' ' for line in scan: if line.startswith('>

[Tutor] Indexing a List of Strings

2011-05-17 Thread Spyros Charonis
Greetings Python List, I have a motif sequence (a list of characters e.g. 'EAWLGHEYLHAMKGLLC') whose index I would like to return. The list contains 20 strings, each of which is close to 1000 characters long making it far too cumbersome to display an example. I would like to know if there is a way

[Tutor] STRING PROC

2011-05-20 Thread Spyros Charonis
Hello List, A quick string processing query. If I have an entry in a list such as ['>NAME\n'], is there a way to split it into two separate lines: > NAME ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.

[Tutor] Logical Structure of Snippet

2011-05-23 Thread Spyros Charonis
Hello List, I'm trying to read some sequence files and modify them to a particular format. These files are structured something like: >P1; ICA1_HUMAN AAEVDTG. (A very long sequence of letters) >P1;ICA1_BOVIN TRETG(A very long sequence of letters) >P1;ICA2_HUMAN WKH.(another sequence)

[Tutor] Concatenating multiple lines into one

2012-02-10 Thread Spyros Charonis
Dear python community, I have a file where I store sequences that each have a header. The structure of the file is as such: >sp|(some code) =>1st header AGGCGG MNKPLOI . . >sp|(some code) => 2nd header AA ... . .. I am looking to implement a logical structure t

Re: [Tutor] Concatenating multiple lines into one

2012-02-12 Thread Spyros Charonis
Thanks for all the help, Peter's and Hugo's methods worked well in concatenating multiple lines into a single data structure! S On Fri, Feb 10, 2012 at 5:30 PM, Mark Lawrence wrote: > On 10/02/2012 17:08, Peter Otten wrote: > >> Spyros Charonis wrote: >> >>

[Tutor] List Indexing Issue

2012-05-08 Thread Spyros Charonis
Hello python community, I'm having a small issue with list indexing. I am extracting certain information from a PDB (protein information) file and need certain fields of the file to be copied into a list. The entries look like this: ATOM 1512 N VAL A 222 8.544 -7.133 25.697 1.00 48.

[Tutor] Parsing data from a set of files iteratively

2012-05-18 Thread Spyros Charonis
Dear Python community, I have a set of ~500 files which I would like to run a script on. My script extracts certain information and generates several lists with items I need. For one of these lists, I need to combine the information from all 500 files into one super-list. Is there a way in which I

Re: [Tutor] Parsing data from a set of files iteratively

2012-05-19 Thread Spyros Charonis
' (calling my python program) 'homology_models[i]' (the file to run it on) the glob.glob routine returns a list of files, so maybe python does not allow the syntax "python (call interpreter)" "list entry" ? Many thanks. Spyros On Fri, May 18, 2012 at 7:5

Re: [Tutor] Parsing data from a set of files iteratively

2012-05-27 Thread Spyros Charonis
a diagnostic I included a print statement in the serialize function to see that the list that is generated for each of the 500 files. Short of some intricacy with the scopes of the program I may be missing, I am not sure why this is happening? Deos anybody have any ideas? Many thanks for your ti

Re: [Tutor] Parsing data from a set of files iteratively

2012-05-29 Thread Spyros Charonis
FINAL SOLUTION: ### LOOP OVER DIRECTORY location = '/Users/spyros/Desktop/3NY8MODELSHUMAN/HomologyModels' zdata = [] for filename in os.listdir(location): filename = os.path.join(location, filename) try: zdata.extend(extract_zcoord(filename)) except NameError: print "No such file!" except SyntaxEr

Re: [Tutor] Parsing data from a set of files iteratively

2012-05-30 Thread Spyros Charonis
On Wed, May 30, 2012 at 8:16 AM, Steven D'Aprano wrote: > On Wed, May 30, 2012 at 07:00:30AM +0100, Spyros Charonis wrote: > > FINAL SOLUTION: > > Not quite. You are making the mistake of many newbies to treat Python > exceptions as a problem to be covered up and hidden, i

[Tutor] indexing a list

2012-10-18 Thread Spyros Charonis
Hello pythoners, I have a string that I want to read in fixed-length windows. In [68]: SEQ Out[68]: 'MKAAVLTLAVLFLTGSQARHFWQQDEPPQSPWDRVKDLATVYVDVLKDSGRDYVSQFEGSALGKQLNLKLLDNWDSVTSTFSKLREQLGPVTQEFWDNLEKETEGLRQEMSKDLEEVKAKVQPYLDDFQKKWQEEMELYRQKVEPLRAELQEGARQKLHELQEKLSPLGEEMRDRARAHVDALRTHLAPYSDELRQ

[Tutor] Understanding a linear runtime implementation of anagram detection

2015-12-10 Thread Spyros Charonis
Dear All, I am learning about analysis of algorithms (python 2.7.6). I am reading a book (Problem solving with Algorithms and Data Structures) where Python is the language used for implementations. The author introduces algorithm analysis in a clear and understandable way, and uses an anagram dete

[Tutor] pickle.dump yielding awkward output

2013-02-03 Thread Spyros Charonis
Hello Pythoners, I am experiencing a strange result with the pickle module when using it to write certain results to a separate file. In short, I have a program that reads a file, finds lines which satisfy some criteria, and extracts those lines, storing them in a list. I am trying to write this

Re: [Tutor] pickle.dump yielding awkward output

2013-02-04 Thread Spyros Charonis
that I get from my code in a separate file, in human-readable format. On Mon, Feb 4, 2013 at 1:03 AM, Alan Gauld wrote: > On 03/02/13 19:26, Spyros Charonis wrote: > >> I am experiencing a strange result with the pickle module when using it >> to write certain results to a sep

[Tutor] Text Processing Query

2013-03-14 Thread Spyros Charonis
Hello Pythoners, I am trying to extract certain fields from a file that whose text looks like this: COMPND 2 MOLECULE: POTASSIUM CHANNEL SUBFAMILY K MEMBER 4; COMPND 3 CHAIN: A, B; COMPND 10 MOL_ID: 2; COMPND 11 MOLECULE: ANTIBODY FAB FRAGMENT LIGHT CHAIN; COMPND 12 CHAIN: D, F; COMPN

Re: [Tutor] Text Processing Query

2013-03-14 Thread Spyros Charonis
print line flag_FAB = 0 On Thu, Mar 14, 2013 at 4:33 PM, Mark Lawrence wrote: > On 14/03/2013 11:28, taserian wrote: > > Top posting fixed > > >> On Thu, Mar 14, 2013 at 6:56 AM, Spyros Charonis > <mailto:s.charo...@gmail.com>> wrote: >> >>

[Tutor] Arbitrary-argument set function

2013-10-01 Thread Spyros Charonis
Dear Pythoners, I am trying to extract from a set of about 20 sequences, the characters which are unique to each sequence. For simplicity, imagine I have only 3 "sequences" (words in this example) such as: s1='spam'; s2='scam', s3='slam' I would like the character that is unique to each seque

[Tutor] bubble sort function

2014-11-15 Thread Spyros Charonis
Dear group, I'm having a bit of trouble with understanding why my bubble sort implementation doesn't work. I've got the following function to perform a bubble sort operation on a list of numbers: def bubble_sort_ascending(unsorted): """ Sorts a list of numbers into ascending order """

Re: [Tutor] bubble sort function

2014-11-15 Thread Spyros Charonis
are that lists have sort() and reverse() methods. I'm in the process of learning a bit about data structures & algorithms using Python as my implementation language. On Sat, Nov 15, 2014 at 7:02 PM, Alan Gauld wrote: > On 15/11/14 16:46, Spyros Charonis wrote: > > def bubble_so

Re: [Tutor] bubble sort function

2014-11-16 Thread Spyros Charonis
n unsorted On Sun, Nov 16, 2014 at 4:50 AM, Steven D'Aprano wrote: > On Sat, Nov 15, 2014 at 04:46:26PM +, Spyros Charonis wrote: > > Dear group, > > > > > > I'm having a bit of trouble with understanding why my bubble sort > > implementation doesn