Soldato
- Joined
- 24 Nov 2002
- Posts
- 16,378
- Location
- 38.744281°N 104.846806°W
I have a list of letters and nulls, e.g. "ABCDEF----ACDFG-GEDA--CADSFA"
The - are important, and I'd like a way to process these and, for each "-" group in the string, return a list of the start number and width.
E.g., for the above, this would be:
7,4
15,1
21,2
I.e., there is a 4 - long group at charcter 7 etc...
I have the following to process string character by character but am stuck from then on. I did to it itereatively, i.e. is the next character a -, is there next character a - etc.. but this crashed Apache.
Any tips would be appreciated.
EDIT - to clarify, I guess what I want to right is something that will read each character, then if that character is a -, count the number of - until the next nondash character, and record the start pos/width of that frist group, then continue reading to find more groups... Clear as mud!
The - are important, and I'd like a way to process these and, for each "-" group in the string, return a list of the start number and width.
E.g., for the above, this would be:
7,4
15,1
21,2
I.e., there is a 4 - long group at charcter 7 etc...
I have the following to process string character by character but am stuck from then on. I did to it itereatively, i.e. is the next character a -, is there next character a - etc.. but this crashed Apache.
PHP:
$length = strlen(trim($seqrow['sequence']));
$count = 0;
$str=trim($seqrow['sequence']);
while ($count < $length){
if ($str[$count] == '-'){
//process string character by character
$count = $count +1;
}
}
Any tips would be appreciated.
EDIT - to clarify, I guess what I want to right is something that will read each character, then if that character is a -, count the number of - until the next nondash character, and record the start pos/width of that frist group, then continue reading to find more groups... Clear as mud!

Last edited: