#!/usr/bin/perl
use strict;
use lib "/opt/ensembl/modules";
use lib "/opt/ensembl-variation/modules";
use Bio::EnsEMBL::Registry;

my $chromo=$ARGV[0];
my $position=int($ARGV[1]);
my $reference_base=$ARGV[2];
my $seqenced_base=$ARGV[3];

# get registry
my $reg = 'Bio::EnsEMBL::Registry';
$reg->load_registry_from_db(-host => 'ensembldb.ensembl.org',-user => 'anonymous');

my $vfa = $reg->get_adaptor('human', 'variation', 'variationfeature');
my $sa = $reg->get_adaptor('human', 'core', 'slice');

# get a slice for the new feature to be attached to
my $slice = $sa->fetch_by_region('chromosome', $chromo);

# create a new VariationFeature object
my $new_vf = Bio::EnsEMBL::Variation::VariationFeature->new(
  -start => $position,
  -end => $position,
  -slice => $slice,           # the variation must be attached to a slice
  -allele_string => "$reference_base/$seqenced_base",    # the first allele should be the reference allele
  -strand => 1,
  -map_weight => 1,
  -adaptor => $vfa,           # we must attach a variation feature adaptor
  -variation_name => 'newSNP',
);

# get the consequence types
foreach my $con (@{$new_vf->get_all_TranscriptVariations}) {
	if (defined $con->pep_allele_string) {
		my $aa_change=$con->pep_allele_string;
		print "AA change: $aa_change\n";
	}
	foreach my $string (@{$con->consequence_type}) {
		my $sid=$con->transcript->stable_id;
		print "$sid\t$string\n";
	}
}