[Bioperl-l] Printing string fragments?

Andreas Kahari ak at ebi.ac.uk
Wed Mar 10 07:52:04 EST 2004


On Wed, Mar 10, 2004 at 01:32:25PM +0100, Gyoergy Abrusan wrote:
> Dear All,
> 
> I would like to ask how can I print out certain fragments of strings.
> my data are in the format:
> 
> >seqname1#uninteresting_information
> ATCGTACGTGCGAGACGT......
> >seqname2#.....
> ATGTCATG....
> 
> I wrote a script that makes some statistics on the nucleotide sequences.
> I would like to print the results out as:
> 
> seqname1    results
> seqname2    results
> 
> at the moment I can print them out only as:
> 
> >seqname1#uninteresting_information     results
> >seqname2#uninteresting_information     results
> 
> Because the scriprt prints out the entire seqname-sting.
> How can I print out parts of a string, say from symbol '>' to
> symbol '#'?

my $result = 'some result';
my $string = '>seqname1#uninteresting_information';

$string =~ /^>([^#]+)#/;    # See the perlre manual ("perldoc perlre")
my $seqname = $1;

print "$seqname\t$result\n";



Cheers,
Andreas

-- 
| {} |      Andreas Kähäri                                |][][|
|{}{}|      EMBL, European Bioinformatics Institute       |[][]|
| {} |      Wellcome Trust Genome Campus                  |][][|
|{}{}|      Hinxton, Cambridgeshire, CB10 1SD             |[][]|
| {} |      United Kingdom                                |][][|


More information about the Bioperl-l mailing list