Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 How to over ride maximum string length
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
stringer




PostPosted: Mon Nov 16, 2015 8:14 pm   Post subject: How to over ride maximum string length

I am having trouble with the maximum string length condition of Turing.

I have a file that has stretches of around 400 characters without any blank spaces.
When I read in the file, Turing comes back with a string too large error.

I am not sure how to get around this restriction.
The file I am trying to work on is large.
The program itself should be fairly simple.

It is just that I have no idea how to work around the 255 maximum length of a string.

Any suggestions would be greatly appreciated.
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Mon Nov 16, 2015 9:48 pm   Post subject: RE:How to over ride maximum string length

At a high level -- if you have two strings that are 255 characters each, you have space for 510 characters.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
stringer




PostPosted: Mon Nov 16, 2015 10:04 pm   Post subject: Re: How to over ride maximum string length

Yes, the problem that I was having was that when I read in a string it read in the whole 500 characters in one go. I was getting a string overflow error.

I read somewhere on the forum that you can read in a character at a time. I think that'll do it. The records are punctuated with colons instead of spaces.

I have written a program that simply puts a space after a colon. Now there will not be a string overflow.

This is great!
We paid quite a bit of money to get this VCF file for a family member. It contains their exome variants.

Decided to polish off my Turing skills and see how I could unlock the information in the file.
There are over 60,000 variants. Turing will make it much easier to find the really interesting variants.
stringer




PostPosted: Mon Nov 16, 2015 11:01 pm   Post subject: Re: How to over ride maximum string length

That was just amazing!
Problem solved!

Simple problem, though it could have really been tough to figure it out.
I just read in a character at a time using two loops with a string of 255 length.
When I added in a space whenever semicolons and another special character appeared in the file, the strings were now all chopped down to size!

Now I can simply use get statements with all the strings that remain without overflow errors!
Then I could manipulate the fields of the exome records to find the variants that are really interesting.

Thank you!
TokenHerbz




PostPosted: Wed Nov 18, 2015 10:42 pm   Post subject: RE:How to over ride maximum string length

now make a function to automagically handle any sized string Smile
stringer




PostPosted: Wed Nov 18, 2015 10:48 pm   Post subject: Re: How to over ride maximum string length

Ohhh! This is frustrating!

I got the file in the "right" format.
I could choose the genetic fields that I wanted to investigate everything was beautiful.

HOWEVER, when I went online to run the modified VCF file, the online program reported that the format was wrong!
The documentation says something that the file needs to be tab delimited.
I have no idea what that means.
My Turing reference mentions in passing tabs, though I have no idea what I should do now.

What is the "tab" character?
Wonder whether the online program would be thrown off if there were an extra space along with a tab character.

I, for one vote, for computers that can learn what you want to do and then do it for you.
A learnable computer!
stringer




PostPosted: Wed Nov 18, 2015 10:57 pm   Post subject: Re: How to over ride maximum string length

Perhaps I should go through one of these SNP records and find out exactly what characters are involved.

Could just grab one character at a time and find out what it is. Perhaps a looped ord command?
stringer




PostPosted: Wed Nov 18, 2015 11:28 pm   Post subject: Re: How to over ride maximum string length

So that looks to be what they are doing.

A tab character "9" is popping up before all the new fields.
There does not appear to be a "blank" character reported.

Now I need to know what to do to insert these "tab" characters.
The program then might work.
Still not sure whether any possible "blank" might throw it off.
Sponsor
Sponsor
Sponsor
sponsor
stringer




PostPosted: Wed Nov 18, 2015 11:45 pm   Post subject: Re: How to over ride maximum string length

Um, well that was very cool.

I just looped the single character get put also showing the ASCI character with an ord command and then put a bunch of chr(9) commands in the output.
Very pretty! Nice straight columns.

Looks like I am getting close to solving this one!
All I need to do now is add the tabs chr(9)s in the right place.
Just a little tricky because some of the fields are somewhat non-standard.
stringer




PostPosted: Thu Nov 19, 2015 12:59 am   Post subject: Re: How to over ride maximum string length

Awesome! Just Awesome!
Mutation Taster is now OK with the reformatted VCF file.

Adding in those chr(9) did the trick.
I was worried for a bit that the spaces would throw everything out.
Yet, when I made the last formatting change in the program everything fell into place and duplicated the original file.

Now I can submit VCF files with any conditions that I choose.
This will make finding a genetic variant of family importance soo much easier.

Thank you everyone!
TokenHerbz




PostPosted: Thu Nov 19, 2015 5:50 am   Post subject: RE:How to over ride maximum string length

question for you, if you have a sentence with say 10 spaces between words, will it capture that to?
stringer




PostPosted: Thu Nov 19, 2015 6:41 pm   Post subject: Re: How to over ride maximum string length

I am not sure about the 10 spaces in a sentence question.

The VCF file I started with was precisely formatted.
There were no extra spaces.

Even if there were extra spaces added by my busting up the super long strings,
when I went back with my get statement the spaces should just disappear.
I was starting to worry that the get statement might be padding the ends of the string with
extra blanks that would be incompatible with the VCF format.

Yet, in the end everything worked out excellent.

These sorts of frustrations really drove me away from computer science.
It is too bad that programming languages do not include a whole bunch of utility programs to avoid
such difficulties. For example, a get statement that would grab a sentence or a page at a time would
be great. I am not sure whether or not Turing has something like that. {A pixel based get statement: grab
everything including blanks from the first line.} Such utilities would allow computer languages to operate
at a higher level of abstraction.
Tony




PostPosted: Thu Nov 19, 2015 6:52 pm   Post subject: Re: How to over ride maximum string length

stringer @ Thu Nov 19, 2015 6:41 pm wrote:
These sorts of frustrations really drove me away from computer science.
It is too bad that programming languages do not include a whole bunch of utility programs to avoid
such difficulties.

The problem is Turing in specific. It's a toy language that was designed a long time ago for the purposes of introductory learning. Try Python or Ruby.

http://xkcd.com/353/
Posted Image, might have been reduced in size. Click Image to view fullscreen.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 13 Posts ]
Jump to:   


Style:  
Search: