#!/usr/local/ensembl/bin/perl -w 

use strict;
use Bio::EnsEMBL::DBSQL::DBAdaptor;
use Getopt::Long;


#  SETTING THE DEFAULT VALUES FOR DB-CONNECTION ETC
my %opt = ( 
           dbhost => 'ensembldb.ensembl.org',
           dbname => 'homo_sapiens_core_58_37c',
           dbuser => 'anonymous',
           dbpass => '',
           dbport => '5306',
          );


&GetOptions(
            'dbhost=s' => \$opt{dbhost},
            'dbname=s' => \$opt{dbname},
            'dbuser=s' => \$opt{dbuser},
            'dbpass=s' => \$opt{dbpass},
            'dbport=i' => \$opt{dbport},
           );

&GetOptions(\%opt, 
            'dbhost=s',
            'dbname=s',
            'dbuser=s',
            'dbpass=s',
            'dbport=i',
           );

my $dba = Bio::EnsEMBL::DBSQL::DBAdaptor->new(
					      -dbname => $opt{dbname},
					      -user => $opt{dbuser},
					      -pass => $opt{dbpass},
					      -host => $opt{dbhost},
					      -port => $opt{dbport},
					     );



my $slice_adaptor = $dba->get_SliceAdaptor(); 
#get gene MLH1
my $slice = $slice_adaptor->fetch_by_gene_stable_id( 'ENSG00000076242', 150000);
my $unmasked_seq   = $slice->seq();
my $softmasked_seq = $slice->get_repeatmasked_seq( undef, 1 );
my $softmasked_length = $softmasked_seq ->length();
my $sst = $slice->start();
my $sen = $slice->end();
my $chr = $slice->seq_region_name();
my $id = "MLH1";
print "\>$id||$chr\:$sst\-$sen||Seq_length\:$softmasked_length\n"; 
my $str = $softmasked_seq->seq(); 
$str =~s/(.{1,60})/$1\n/g;
print $str ; 
