Re: Mathematica is destroying my sanity....
- To: mathgroup at smc.vnet.net
- Subject: [mg53083] Re: Mathematica is destroying my sanity....
- From: David Bailey <dave at Remove_Thisdbailey.co.uk>
- Date: Thu, 23 Dec 2004 07:58:12 -0500 (EST)
- References: <cqbhb8$4kv$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Todd Allen wrote: > Hi everyone (and Happy Holidays!) > > I am trying to parse a 450 Mb text file for > certain important information and then would like to > save the smaller, parsed information in a suitable > file for later importation and futher analysis. I > have made some progress, but have stumbled yet again. > > Below is the situation: > > In[1]:= > SetDirectory["D:\\"] > In[2]:= > blastn=OpenRead["Cpara-SelfBlast120804(2).txt"] > In[3]:= > subblastn=ReadList[blastn,Record,RecordSeparators\[Rule]{{"Value"},{">"}}]; > In[7]:= > temp1=Table[StringSplit[subblastn[[i]]],{i,1,Length[subblastn]}]; > In[9]:= > temp2=Table[Partition[temp1[[i]],3],{i,1,Length[temp1]}]; > > > ***The output for temp2 is a nicely organized set of > sublists: > > Out[10]= > {{CEST-01-A-01,1120,0.0},{CEST-17-A-06,985,0.0},{CEST-04-E-04,52, > > 3e-07},{CEST-28-H-03,50,1e-06},{CEST-46-G-10,48,5e-06},{CEST-37-B-11,48, > > 5e-06},{CEST-21-D-05,48,5e-06},{CEST-21-A-11,48,5e-06},{CEST-21-A-10,48, > > 5e-06},{CEST-19-G-12,48,5e-06},{CEST-13-F-07,48,5e-06},{CEST-10-E-05,48, > > 5e-06},{CEST-04-E-08,48,5e-06},{CEST-60-C-12,46,2e-05},{CEST-59-D-02,46, > > 2e-05},{CEST-29-A-06,46,2e-05},{CEST-26-H-10,46,2e-05},{CEST-25-F-11,46, > > 2e-05},{CEST-20-C-11,46,2e-05},{CEST-19-F-10,46,2e-05},{CEST-11-E-06,46, > 2e-05}} > > ****At this point, I want to save the data and > organized structure of the data currently contained in > temp2. > > I have tried numerous variations, with the following > being the best (yet still undesirable) result: > > Export["subparseBlastN", temp2, "List"] (* to save > data *) > > In[45]:= > tempsub=Import["subparseBlastN","Table"]; > > ****The result of the new import in "tempsub" looks > awful and really messes up the data organization for > me: > > Out[47]= > {{{"CEST-01-A-01",,"1120",,"0.0"},,{"CEST-17-A-06",,"985",,"0.0"},,{"CEST-04-\ > E-04",,"52",,"3e-07"},,{"CEST-28-H-03",,"50",,"1e-06"},,{"CEST-46-G-10",,"48",\ > ,"5e-06"},,{"CEST-37-B-11",,"48",,"5e-06"},,{"CEST-21-D-05",,"48",,"5e-06"},,{\ > "CEST-21-A-11",,"48",,"5e-06"},,{"CEST-21-A-10",,"48",,"5e-06"},,{"CEST-19-G-\ > 12",,"48",,"5e-06"},,{"CEST-13-F-07",,"48",,"5e-06"},,{"CEST-10-E-05",,"48",,\ > "5e-06"},,{"CEST-04-E-08",,"48",,"5e-06"},,{"CEST-60-C-12",,"46",,"2e-05"},,{\ > "CEST-59-D-02",,"46",,"2e-05"},,{"CEST-29-A-06",,"46",,"2e-05"},,{"CEST-26-H-\ > 10",,"46",,"2e-05"},,{"CEST-25-F-11",,"46",,"2e-05"},,{"CEST-20-C-11",,"46",,\ > "2e-05"},,{"CEST-19-F-10",,"46",,"2e-05"},,{"CEST-11-E-06",,"46",,"2e-05"}}} > > (1) Is there a way to export my original "nice" > looking list (the temp2 list), so that it will import > in exactly the same? > > (2) Even though the Head of each element in both the > "temp2" and "tempsub" lists are Strings, why does > Mathematica put extra quotation marks around the newly > imported list items and not the original list items? > > > Whew, I am outta breath. Any thoughts or suggestions > where I might find useful information? As > always,thank you to the numerous people who have > helped me out in the past. This is an excellent forum > for learning Mathematica. > > Best regards, > Todd > > > > > > > __________________________________ > Do you Yahoo!? > Take Yahoo! Mail with you! Get it on your mobile phone. > http://mobile.yahoo.com/maildemo > Hi, If you REALLY want to control the contents of the file you create, why not write yourself a function that uses OpenWrite to get a stream and then use functions like Write/WriteString/ToString to lay it all out exactly as you desire? I suggest you 'practice' on a mini-file, but as you work, be careful to time your code, because different methods might run at significantly different speeds, and you don't want a surprise when you scale it back up to the real problem. David Bailey dbaileyconsultancy.co.uk