use Maasha::Common;
use Maasha::KISS::IO;
use Maasha::Biopieces;
+use Maasha::Fasta;
use Maasha::Filesys;
+use constant {
+ SEQ_NAME => 0,
+ SEQ => 1,
+};
+
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-my ( $data_dir, $user, $options, $path, $in, $out, $tmp_dir, %fh_hash, $fh_out, $record, $entry, $key, @dirs, $dir, $dst_dir, @nums, $num );
+my ( $data_dir, $user, $options, $path, $in, $out, $tmp_dir, %fh_hash, $fh_out, $record, $entry, $key, @dirs, $dir, $dst_dir, @nums, $num, $contig_dir );
$data_dir = Maasha::Biopieces::biopiecesrc( "KISS_DATA_DIR" );
$user = Maasha::Biopieces::biopiecesrc( "KISS_USER" );
{ long => 'clade', short => 'c', type => 'string', mandatory => 'yes', default => undef, allowed => undef, disallowed => undef },
{ long => 'genome', short => 'g', type => 'string', mandatory => 'yes', default => undef, allowed => undef, disallowed => undef },
{ long => 'assembly', short => 'a', type => 'string', mandatory => 'yes', default => undef, allowed => undef, disallowed => undef },
- { long => 'track_name', short => 't', type => 'string', mandatory => 'yes', default => undef, allowed => undef, disallowed => undef },
+ { long => 'track_name', short => 't', type => 'string', mandatory => 'no', default => undef, allowed => undef, disallowed => undef },
{ long => 'no_stream', short => 'x', type => 'flag', mandatory => 'no', default => undef, allowed => undef, disallowed => undef },
]
);
-$options->{ 'track_name' } =~ tr/ /_/;
+$in = Maasha::Biopieces::read_stream( $options->{ "stream_in" } );
+$out = Maasha::Biopieces::write_stream( $options->{ "stream_out" } );
-$path = join "/", $data_dir, "Users/", $options->{ 'user' }, $options->{ 'clade' }, $options->{ 'genome' }, $options->{ 'assembly' };
+if ( $options->{ 'track_name' } )
+{
+ $options->{ 'track_name' } =~ tr/ /_/;
-Maasha::Common::error( qq(Path not found: "$path") ) if not -d $path;
+ $path = join "/", $data_dir, "Users/", $options->{ 'user' }, $options->{ 'clade' }, $options->{ 'genome' }, $options->{ 'assembly' };
-$in = Maasha::Biopieces::read_stream( $options->{ "stream_in" } );
-$out = Maasha::Biopieces::write_stream( $options->{ "stream_out" } );
+ Maasha::Common::error( qq(Path not found: "$path") ) if not -d $path;
-$tmp_dir = Maasha::Biopieces::get_tmpdir();
+ $tmp_dir = Maasha::Biopieces::get_tmpdir();
-while ( $record = Maasha::Biopieces::get_record( $in ) )
-{
- if ( $entry = Maasha::KISS::IO::biopiece2kiss( $record ) )
+ while ( $record = Maasha::Biopieces::get_record( $in ) )
{
- if ( not exists $fh_hash{ $entry->{ 'S_ID' } } ) {
- $fh_hash{ $entry->{ 'S_ID' } } = Maasha::Filesys::file_write_open( "$tmp_dir/$entry->{ 'S_ID' }" );
- }
+ if ( $entry = Maasha::KISS::IO::biopiece2kiss( $record ) )
+ {
+ if ( not exists $fh_hash{ $entry->{ 'S_ID' } } ) {
+ $fh_hash{ $entry->{ 'S_ID' } } = Maasha::Filesys::file_write_open( "$tmp_dir/$entry->{ 'S_ID' }" );
+ }
- $fh_out = $fh_hash{ $entry->{ 'S_ID' } };
+ $fh_out = $fh_hash{ $entry->{ 'S_ID' } };
- Maasha::KISS::IO::kiss_entry_put( $entry, $fh_out );
- }
+ Maasha::KISS::IO::kiss_entry_put( $entry, $fh_out );
+ }
- Maasha::Biopieces::put_record( $record, $out ) if not $options->{ "no_stream" };
-}
+ Maasha::Biopieces::put_record( $record, $out ) if not $options->{ "no_stream" };
+ }
-foreach $key ( keys %fh_hash )
-{
- close $fh_hash{ $key };
+ foreach $key ( keys %fh_hash )
+ {
+ close $fh_hash{ $key };
- $dst_dir = Maasha::Filesys::dir_create_if_not_exists( "$path/$key" );
- $dst_dir = Maasha::Filesys::dir_create_if_not_exists( "$dst_dir/Tracks" );
+ $dst_dir = Maasha::Filesys::dir_create_if_not_exists( "$path/$key" );
+ $dst_dir = Maasha::Filesys::dir_create_if_not_exists( "$dst_dir/Tracks" );
- @dirs = Maasha::Filesys::ls_dirs( $dst_dir );
+ @dirs = Maasha::Filesys::ls_dirs( $dst_dir );
- foreach $dir ( @dirs )
- {
- $dir = ( split "/", $dir )[ -1 ];
+ foreach $dir ( @dirs )
+ {
+ $dir = ( split "/", $dir )[ -1 ];
- if ( $dir =~ /^(\d+)/ ) {
- push @nums, $1;
+ if ( $dir =~ /^(\d+)/ ) {
+ push @nums, $1;
+ }
}
- }
- @nums = sort { $a <=> $b } @nums;
+ @nums = sort { $a <=> $b } @nums;
+
+ $num = $nums[ -1 ] || 0;
+
+ $num += 10;
+
+ $dst_dir = "$dst_dir/$num" . "_$options->{ 'track_name' }";
- $num = $nums[ -1 ] || 0;
+ Maasha::Filesys::dir_create( $dst_dir );
- $num += 10;
+ Maasha::Filesys::file_copy( "$tmp_dir/$key", "$dst_dir/track_data.kiss" );
- $dst_dir = "$dst_dir/$num" . "_$options->{ 'track_name' }";
+ Maasha::KISS::IO::kiss_index( "$dst_dir/track_data.kiss" );
- Maasha::Filesys::dir_create( $dst_dir );
+ unlink "$tmp_dir/$key";
+ }
+}
+else
+{
+ $path = join "/", $data_dir, "Users/", $options->{ 'user' }, $options->{ 'clade' };
- Maasha::Filesys::file_copy( "$tmp_dir/$key", "$dst_dir/track_data.kiss" );
+ Maasha::Common::error( qq(Path not found: "$path") ) if not -d $path;
- Maasha::KISS::IO::kiss_index( "$dst_dir/track_data.kiss" );
+ $dst_dir = Maasha::Filesys::dir_create( "$path/$options->{ 'genome' }" );
+ $dst_dir = Maasha::Filesys::dir_create( "$dst_dir/$options->{ 'assembly' }" );
- unlink "$tmp_dir/$key";
+ while ( $record = Maasha::Biopieces::get_record( $in ) )
+ {
+ if ( $entry = Maasha::Fasta::biopiece2fasta( $record ) )
+ {
+ $entry->[ SEQ_NAME ] = ( split " ", $entry->[ SEQ_NAME ] )[ 0 ];
+ $contig_dir = Maasha::Filesys::dir_create( "$dst_dir/$entry->[ SEQ_NAME ]" );
+ $contig_dir = Maasha::Filesys::dir_create( "$contig_dir/Sequence" );
+
+ $fh_out = Maasha::Filesys::file_write_open( "$contig_dir/sequence.txt" );
+ print $fh_out $entry->[ SEQ ];
+ close $fh_out;
+ }
+ }
}
Maasha::Biopieces::close_stream( $in );
# Returns a list.
- my ( $draw_metrics, @tracks, @features, $feat, $elem, $file, $surface, $cr, @html, @img );
+ my ( $draw_metrics, @tracks, $i, @features, $feat, $elem, $file, $surface, $cr, @html, @img );
$draw_metrics = {
IMG_WIDTH => 1200,
TRACK_OFFSET => 20,
TRACK_SPACE => 20,
RULER_FONT_SIZE => 10,
- RULER_COLOR => 'black',
+ RULER_COLOR => [ 0, 0, 0 ],
SEQ_FONT_SIZE => 10,
- SEQ_COLOR => 'black',
+ SEQ_COLOR => [ 0, 0, 0, ],
FEAT_WIDTH => 5,
+ FEAT_COLOR => [ 0, 1, 0 ],
};
push @features, [ Maasha::KISS::Track::track_ruler( $draw_metrics, $cookie ) ];
@tracks = Maasha::KISS::Track::path_tracks( $cookie );
- map { push @features, [ Maasha::KISS::Track::track_feature( $_, $draw_metrics, $cookie ) ] } @tracks;
+ for ( $i = 0; $i < @tracks; $i++ )
+ {
+ push @features, [ Maasha::KISS::Track::track_feature( $tracks[ $i ], $draw_metrics, $cookie ) ];
+
+ $draw_metrics->{ 'FEAT_COLOR' } = [ 0, 0, 1 ];
+ }
$file = "fisk.png";
{
foreach $elem ( @{ $feat } )
{
- next if not $elem->{ 'type' } eq 'line';
+ next if $elem->{ 'type' } eq 'text';
push @img, Maasha::XHTML::area(
href => "www.dmi.dk",