Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

  • ecea61e
  • /
  • scripts
  • /
  • normalize_processed_filter.pl
Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
content badge
swh:1:cnt:91a0d50e0296dada22d8cb40ccbcf2c8012eced3
directory badge
swh:1:dir:c5e796b659dfb63409b0c926433acfcd260b7e8a

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
normalize_processed_filter.pl
#!usr/bin/perl -w -s

#11/2/09
#per-sample count per million normalization on processed mapping output data
#06/12/2013
#
#input file format:
#SampleID \t chromosome \t Coordinate \t L_read \t R_read \t Total_reads \n
#04/09/2015
#Adjusted the cutoff to 3


if (!@ARGV){
  print "\nUsage: perl $0 <input.txt>\n";
  exit;
}


open IN, "$ARGV[0]";
open OUT, ">$ARGV[0]_filter_cpm.txt";

my $logfile;
if ($ARGV[0]=~/(\w+\.scarf)/){
   $logfile=$1.".log";
}

open LOG,">>$logfile";
print LOG "SampleID\tRawReadsAfterFiltered\tCoverage\tScale factor\n";
#print OUT "SampleID\tLocation\tCPM-normalized count\n";

#read file into 2D hash
my $data; # $data->{sampleID}->{location} = count
my $sample;

while (my $line = <IN>){
  chomp $line;
  my @temp = split /\s+/, $line;
  $data->{$temp[0]}->{$temp[1]} = $temp[4];
}


  my @sites;
  my @counts;
  my @norm_counts;
  foreach my $chromosome (keys %$data){ 
    foreach my $location (keys %{$data->{$chromosome}}){  #for each location within that sampleID
      if ($data->{$chromosome}->{$location}>=3){
        push (@sites, $location);
        push (@counts, $data->{$chromosome}->{$location});
      }
    }
  }
  my $sum=0;
  my $coverage=scalar @sites;
  for (my $i=0; $i<scalar @sites; $i++){
    $sum = $sum+$counts[$i];
  }
  my $scale_factor = 1000000/$sum;
  print LOG "$ARGV[0]\t$sum\t$coverage\t$scale_factor\n";
  foreach my $chromosome (keys %$data){ 
    foreach my $location (keys %{$data->{$chromosome}}){  #for each location within that sampleID
              if ($data->{$chromosome}->{$location}>5){
                  print OUT"$chromosome\t$location\t".$data->{$chromosome}->{$location}*$scale_factor."\n";
              }
    }
  }

close LOG;

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API