<commit_before>#!/software/bin/perl -w


=head1 NAME

sam2bed.pl

=head1 SYNOPSIS

 sam2bed.pl [ file.sam[.gz] ]+

=head1 DESCRIPTION

This script loads converts sam(inc gzipped) format files to a bed format files.
Unampped reads are filtered as appropriate and the MAPQ score is used as the bed score.


=head1 LICENSE

  Copyright (c) 1999-2009 The European Bioinformatics Institute and
  Genome Research Limited.  All rights reserved.

  This software is distributed under a modified Apache license.
  For license details, please see:
    http://www.ensembl.org/info/about/code_licence.html

=head1 CONTACT

  Please email comments or questions to the public Ensembl
  developers list at <<EMAIL>>.

  Questions may also be sent to the Ensembl help desk at
  <<EMAIL>>.


=cut


use warnings;
use strict;
use Pod::Usage;
use Getopt::Long;
use Bio::EnsEMBL::Funcgen::Utils::EFGUtils qw(get_file_format is_gzipped open_file);


# To do
# Utilise Bio::DB::Sam
# Add filters on quality etc. See IDs code
# Add GetOpt::long support:
#     -No zip output?
#     -submit to farm

#It works using bwa output. Not sure if it is fully SAM compliant!
#This does not use the Binary format!

my ($on_farm, @files);

my @tmp_args = @ARGV;

GetOptions (
			"on_farm"    => \$on_farm,
			"files=s{,}" => \@files,
			'man'        => sub { pos2usage(-exitval => 0, -verbose => 2); },
			'help'       => sub { pos2usage(-exitval => 0, -message => "Params are:\t@tmp_args"); }
		   ) or pod2usage( -exitval => 1,
						   -message => "Params are:\t@tmp_args"
						 );


print "sam2bed.pl @tmp_args\n" if $on_farm;

#Not implemented option functions yet

if (! @files){
  pod2usage( -exitval => 1,
			 -message => "You must supply some sam filenames to convert");
}


if((scalar(@files) > 1) &&
   ! $on_farm){
  die("You must supply the -on_farm flag if you want to run on more than one file");
  
}

foreach my $file(@files){
  
  if($on_farm){
	my $bsub_cmd = "bsub -q normal -J sam2bed:$file ".$ENV{'EFG_SRC'}."/scripts/miscellaneous/sam2bed.pl -files $file";
	system($bsub_cmd);
	next;
  }<commit_msg>added lsf -e -o files<commit_after>#!/software/bin/perl -w


=head1 NAME

sam2bed.pl

=head1 SYNOPSIS

 sam2bed.pl [ file.sam[.gz] ]+

=head1 DESCRIPTION

This script loads converts sam(inc gzipped) format files to a bed format files.
Unampped reads are filtered as appropriate and the MAPQ score is used as the bed score.


=head1 LICENSE

  Copyright (c) 1999-2009 The European Bioinformatics Institute and
  Genome Research Limited.  All rights reserved.

  This software is distributed under a modified Apache license.
  For license details, please see:
    http://www.ensembl.org/info/about/code_licence.html

=head1 CONTACT

  Please email comments or questions to the public Ensembl
  developers list at <<EMAIL>>.

  Questions may also be sent to the Ensembl help desk at
  <<EMAIL>>.


=cut


use warnings;
use strict;
use Pod::Usage;
use Getopt::Long;
use Bio::EnsEMBL::Funcgen::Utils::EFGUtils qw(get_file_format is_gzipped open_file);


# To do
# Utilise Bio::DB::Sam
# Add filters on quality etc. See IDs code
# Add GetOpt::long support:
#     -No zip output?
#     -submit to farm

#It works using bwa output. Not sure if it is fully SAM compliant!
#This does not use the Binary format!

my ($on_farm, @files);

my @tmp_args = @ARGV;

GetOptions (
			"on_farm"    => \$on_farm,
			"files=s{,}" => \@files,
			'man'        => sub { pos2usage(-exitval => 0, -verbose => 2); },
			'help'       => sub { pos2usage(-exitval => 0, -message => "Params are:\t@tmp_args"); }
		   ) or pod2usage( -exitval => 1,
						   -message => "Params are:\t@tmp_args"
						 );


print "sam2bed.pl @tmp_args\n" if $on_farm;

#Not implemented option functions yet

if (! @files){
  pod2usage( -exitval => 1,
			 -message => "You must supply some sam filenames to convert");
}


if((scalar(@files) > 1) &&
   ! $on_farm){
  die("You must supply the -on_farm flag if you want to run on more than one file");
  
}

foreach my $file(@files){
  
  if($on_farm){
	

	my $bsub_cmd = "bsub -q normal -J sam2bed:$file -o ${file}.sam2bed.out -e ${file}.sam2bed.err ".$ENV{'EFG_SRC'}."/scripts/miscellaneous/sam2bed.pl -files $file";
	system($bsub_cmd);
	next;
  }
{'fraction_non_alphanumeric': 0.12798110979929161, 'fraction_numerical': 0.013695395513577333, 'mean_word_length': 3.4683544303797467, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '647002', 'n_tokens_mistral': 1601, 'n_tokens_neox': 1461, 'n_words': 494}