473,394 Members | 1,709 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Problem with string comparison ?

Hi,

I want extract particular strings from large file(file size 600 Mb). I gave two kind of conditions for identify the position. first string comparison is working, but second one is not working. Please helpm in this. Thanks in advance.

Expand|Select|Wrap|Line Numbers
  1.  
  2. open(NGS,"<$ngs") || die "can't open file";
  3. open(RESULT,">$output") || die "can't open file";
  4.  
  5. @ngs_seq = <NGS>;
  6. $NGS_length = @ngs_seq;
  7.       $z=0;
  8.            for($j = 0; $j <= $NGS_length; $j++)
  9.               {
  10.  
  11.             $fastasymbl= substr($ngs_seq[$j], 1, 1);
  12.  
  13.              if($fastasymbl eq '>')#1st working
  14.                  {
  15.  
  16.                     ($a1, $b1, $c1, $d1, $e1, $f1)=split(/\|/, $ngs_seq[$j], 6);
  17.                    #chomp $b1;
  18.                   # $b1=~s/\s//g;
  19.  
  20.                   if($b1 eq 'A 0 1')#2nd not working
  21.                     {
  22.                        print "$b1\n";
  23.                        $z++;
  24.                      }
  25.  
  26.                    }
  27.                 }
  28.             print "\n total number of scaffolds: $z\n";
  29. close NGS; 
  30.  
Oct 13 '10 #1
3 1776
numberwhun
3,509 Expert Mod 2GB
To begin to help you, we are going to have to see the contents of the file referenced by $ngs.

Also, one suggestion, when doing a die statement, instead of just saying it couldn't open the file, you might want to tell 'why' it couldn't. I usually write my die statements like this:

Expand|Select|Wrap|Line Numbers
  1. open(NGS,"<$ngs") || die "can't open file $ngs: $!";
  2.  
Notice the $!. That will print out the last error that was issued, that way you know what was wrong. Also, I referenced the file you were trying to open ($ngs). That way, since you can potentially have many die statements, you will know 'where' the error took place in the script and what was effected.

Regards,

Jeff
Oct 13 '10 #2
Hi numberwhun,


Thanks for ur suggestion. I found the error was with the file only. it was in unicode. After changing to ANSI it's working.

When it was in unicode, looks normal but program reads space between each letter. I don't know why?
Oct 13 '10 #3
numberwhun
3,509 Expert Mod 2GB
For your reading enjoyment, go here.


Regards,

Jeff
Oct 13 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: ramin | last post by:
Hi, I would be greately thankful if somebody can give me some information about how string comparison is implemented in mysql. (Both in Physical and Application layer) How queries on string (for...
46
by: yadurajj | last post by:
Hello i am newbie trying to learn C..I need to know about string comparisons in C, without using a library function,...recently I was asked this in an interview..I can write a small program but I...
4
by: Peter Kirk | last post by:
Hi I am looking at some code which in many places performs string comparison using == instead of Equals. Am I right in assuming that this will in fact work "as expected" when it is strings...
1
by: bjjnova | last post by:
I have the following string comparison that is throwing an error I cannot find ( I will include my attempts to trace the error) In the line following the asterisks, written as I have below, a...
4
by: almurph | last post by:
Hi, Hope you can help me with this one. I'm looking for some nice string comparison algorithms. I want to be able to compare 2 strings (fairly smallish, less than 50 characters) and return a %...
9
by: Usman Jamil | last post by:
Hi I'm having a strange error while comparing two strings. Please check the code below. This is a simple string comparison code and works just fine on all of my machines. While debugging an...
14
by: Steve Bergman | last post by:
I'm looking for a module to do fuzzy comparison of strings. I have 2 item master files which are supposed to be identical, but they have thousands of records where the item numbers don't match in...
3
by: questionit | last post by:
Hi I have a string comparison code from VB. While (Not ((myString Like "??????") And (myString Like "00*"))) All i am wondering is if we can do the similar thing in C/C++ i.e using 'Like' ...
3
by: itmfl | last post by:
We are writing a program that multiplies two matrices of size n x m and m x n together. The matrices are stored in a file. The user provides the filename in the command line prompt. The file is...
10
by: lilly07 | last post by:
Hi, I have one column of strings in 1st file file and another file which consists of 5 clumns in each line and my basic objective is to find each item/line of 1st file is available in 3rd column of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.