Message Boards Message Boards

0
|
6446 Views
|
1 Reply
|
0 Total Likes
View groups...
Share
Share this post:

How would one use output containing an escaped character as input?

Posted 10 years ago
Hello,

        I'm rather new to Mathematica.  My goal is to import a list of strings that are enclosed in single quotes, replace the single quotes as double quotes, and use the output in the GenomeData function.  I have successfully completed the first two tasks, but am encountering difficulty on the third.  The GenomeData function requires the form GenomeData["gene"], however upon providing my generated input for the "gene" argument I am greeted with an error that states I am inputting GenomeData[\"gene\"].  This is because I've used escape backslash (\") to insert the " character at the beginning and end of the gene string.  This is peculiar to me because the front end outputs \"gene\" as  "gene", but the program itself notices this and won't accept this output as input into another function.  Has anyone had this issue or know how to get around it?
POSTED BY: kylelaster2012
I am guessing you have a stirng that happens to have the \" character in it. This is unnecesary and won't work. Try the following
 In[6]:= GenomeData["SCNN1A"]//Short
 
 Out[6]//Short= CCGGCCAGCGGGCGGGCTCCCCAGCCAGGCCGC\[Ellipsis] TAGGCAGGAGCTCAATAAATGTTTGTTGCATGAA
 
 In[3]:= a = "SCNN1A"
 Out[3]= SCNN1A
 
 In[4]:= FullForm[a]
 Out[4]//FullForm= "SCNN1A"

In[8]:= GenomeData[a]//Short
Out[8]//Short= CCGGCCAGCGGGCGGGCTCCCCAGCCAGGCCGC\[Ellipsis] TAGGCAGGAGCTCAATAAATGTTTGTTGCATGAA

In[5]:= b = "\"SCNN1A\""
Out[5]= "SCNN1A"

In[10]:= FullForm[b]

Out[10]//FullForm= "\"SCNN1A\""

In[9]:= GenomeData[b]//Short
During evaluation of In[9]:= GenomeData::notent: "\"SCNN1A\"" is not a known entity, class, or tag for GenomeData. Use GenomeData[] for a list of entities. >>
Out[9]//Short= GenomeData["SCNN1A"]

You can often identify issues like this with the FullForm function. At any rate, I would suggest not change the single quotes into double quotes, but removing them entirely.
POSTED BY: Jason Grigsby
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract