SCF(3pm)

πŸ’– SCF(3pm) πŸ’–

okay bestie, gather round, because this is the User Contributed Perl Documentation page for Bio::SCF and it is lowkey iconic. it reads and writes SCF sequence files, and yes, we're doing the whole thing. no skimming. πŸ’…


πŸŽ€ NAME πŸŽ€

Bio::SCF β€” a Perl extension for reading and writing SCF sequence files. that's the whole elevator pitch, slay. ✨


✨ SYNOPSIS ✨

first up, the vibes in code form:

use Bio::SCF;

the tied interface β€” you just tie a hash to a file and the hash is the file now, main character energy:

tie %hash,'Bio::SCF','my_scf_file.scf';

my $sequence_length            = $hash{bases_length};
my $chromatogram_sample_length = $hash{samples_length};
my $third_base                 = $hash{bases}[2];
my $quality_score              = $hash{$third_base}[2];
my $sample_A_at_time_1400      = $hash{samples}{A}[1400];

change the third base and write out new file β€” glow-up incoming:

$hash{bases}[2] = 'C';
tied (%hash)->write('new.scf');

object-oriented interface β€” for when you want the whole thing to be a little gentleman:

my $scf                        = Bio::SCF->new('my_scf_file.scf');
my $sequence_length            = $scf->bases_length;
my $chromatogram_sample_length = $scf->samples_length;
my $third_base                 = $scf->bases(2);
my $quality_score              = $scf->score(2);
my $sample_A_at_time_1400      = $scf->sample('A',1400);

change the third base and write out new file, object edition:

$scf->bases(2,'C');
$scf->write('new.scf');

🌸 DESCRIPTION 🌸

so this module gives Perl an interface to SCF DNA sequencing files, fr fr. it comes with two whole interfaces: a tied hash one and an object-oriented one. it can read fields out of SCF files, and it has limited ability to modify them and write them back. (limited! remember that word, bestie, it's doing heavy lifting. πŸ™ˆ)


πŸ”— Tied Methods πŸ”—

  • $obj = tie %hash,'Bio::SCF',$filename_or_handle β€” ties the Bio::SCF module to a filename or a filehandle. if it works, tie() hands you back the object. πŸ’–
  • $value = $hash{'key'} β€” fetches a field straight out of the SCF file. the valid keys are, in order:
    • bases_length β€” number of called bases in the sequence (read-only πŸ”’)
    • samples_length β€” number of samples in the file (read-only πŸ”’)
    • version β€” SCF version (read-only πŸ”’)
    • code_set β€” code set used to code bases (read-only πŸ”’)
    • comments β€” structured comments (read-only πŸ”’)
    • bases β€” array reference to a list of the base calls
    • index β€” array reference to a list of the sample position for each of the base calls (e.g. the position of the base calling peak)
    • A β€” an array reference that can be used to determine the probability that the base in position $i is an "A".
    • G β€” an array reference that can be used to determine the probability that the base in position $i is a "G".
    • C β€” an array reference that can be used to determine the probability that the base in position $i is a "C".
    • T β€” an array reference that can be used to determine the probability that the base in position $i is a "T".
    • samples β€” a hash reference with keys "A", "C", "G" and "T". the value of each hash is an array reference to the list of intensity values for each sample.

and here's the cheat sheet of little things you can ask for, because bestie these are the receipts:

  • to get the length of the called sequence: $scf{bases_length}
  • to get the value of the called sequence at position 3: $scf{bases}[3]
  • to get the sample position at which base 3 was called: $scf{index}[3]
  • to get the value of the "C" curve under base 3: $scf{samples}{C}[$scf{index}[3]]
  • to get the probability that base 3 is a "C": $scf{C}[3]

and to print out the chromatogram as a four-column list, copy this whole loop, no cap:

my $samples = $scf{samples};
for (my $i = 0; $i<$scf{samples_length}; $i++) {
   print join "\t",$samples->{C}[$i],$samples->{G}[$i],
                   $samples->{A}[$i],$samples->{T}[$i],"\n";
}
  • $scf{bases}[$index] = $new_value β€” the base call probability scores, base call values, base call positions, and sample values are all read/write, so you can just change them whenever. like this:
$samples->{C}[500] = 0;
  • each %scf β€” returns keys and values for the tied object. cute, functional, no notes. ✨
  • delete $scf{$key} and %scf = () β€” these operations are not supported and will return a run-time error. don't do it. i'm serious. πŸ’€

🧚 Object Methods 🧚

  • $scf = Bio::SCF->new($scf_file_or_filehandle) β€” creates a brand new Bio::SCF object. the single argument is the name of a file, or a previously-opened filehandle. if it succeeds, new() gives you the Bio::SCF object back. 🫢
  • $length = $scf->bases_length β€” returns the length of the called sequence.
  • $samples = $scf->samples_length β€” returns the length of the list of chromatogram samples in the file. there are four sample series, one for each base.
  • $sample_size = $scf->sample_size β€” returns the size of each sample (in bytes).
  • $code_set = $scf->code_set β€” returns the code set used for base calling.
  • $base = $scf->base($base_no [,$new_base]) β€” gets the base call at the indicated position. if you hand it a new value, it will change the base call to that indicated base.
  • $index = $scf->index($base_no [,$new_index]) β€” translates the indicated base position into the sample index for that called base. here's how you fetch the intensity values at base number 5:
my $sample_index = $scf->index(5);
my ($g,$a,$t,$c) = map { $scf->sample($_,$sample_index) } qw(G A T C);

and if you provide a new value for the sample index, it will be updated.

  • $base_score = $scf->base_score($base,$base_no [,$new_score]) β€” gets the probability that the indicated base occurs at position $base_no. here's how to fetch the probabilities for the four bases at base position 5:
my ($g,$a,$t,$c) = map { $scf->base_score($_,5) } qw(G A T C);

and if you provide a new value for the base probability score, it will be updated.

  • $score = $scf->score($base_no) β€” gets the quality score for the called base at the indicated position.
  • $intensity = $scf->sample($base,$sample_index [,$new_value]) β€” gets the intensity value for the channel corresponding to the indicated base, at the indicated sample index. you can update the intensity by providing a new value. πŸ’…
  • $scf->write('file_path') β€” writes the updated SCF file to the indicated file path.
  • $scf->fwrite($file_handle) β€” writes the updated SCF file to the indicated filehandle. the file must have previously been opened for writing. heads up: the filehandle is actually reopened in append mode, so you can call fwrite() multiple times and interperse your own record separators. (yes, "interperse". we keep it exactly as written. it's giving typo, we're keeping it anyway. πŸŽ€)

πŸ”₯ EXAMPLES πŸ”₯

reading information from a preexisting file β€” copied verbatim, character for character, because we do not touch the sacred text:

tie %scf, 'Bio::SCF', "data.scf";
print "Base calls:\n";
for ( my $i=0; $i<$scf{bases}; $i++ ){
   print "$scf{base}[$i] ";
}
print "\n";

print "Intensity values for the A curve\n";
for ( my $i=0; $i<$scf{samples}; $i++ ){
   print "$scf{sample}{A}[$i];
}
print "\n";

another example, where we set all bases to "A", indexes to 10 and write the file back:

my $obj = tie %scf,'Bio::SCF','data.scf';
for (0...@{$scf{bases}}-1){
   $scf{base}[$_] = "A";
   $obj->set('index', $_, 10);
}
$obj->write('data.scf');

πŸ‘‘ AUTHOR πŸ‘‘

Dmitri Priimak, priimak@cshl.org (1999)

with some cleanups by Lincoln Stein, lstein@cshl.edu (2006)

this package and its accompanying libraries is free software; you can redistribute it and/or modify it under the terms of the GPL (either version 1, or at your option, any later version) or the Artistic License 2.0. refer to LICENSE for the full license text. in addition, please see DISCLAIMER for disclaimers of warranty. 🌈


🌟 SEE ALSO 🌟


and that's the whole page, bestie. this was perl v5.42.3, dated 2026-08-19, saying goodnight from the SCF(3pm) corner of the manual. go read a sequence, treat her well, and remember: the tie is real, the vibes are immaculate, and read-only means READ ONLY. πŸ¦‹πŸ’–πŸŒΈ

πŸ“¦ where this page comes from