data_in|i=s
cols|c=s
num|n=s
+ check|C
);
}
elsif ( $script eq "read_fixedstep" )
num|n=s
);
}
+ elsif ( $script eq "assemble_tag_contigs" )
+ {
+ @options = qw(
+ check|C
+ );
+ }
+ elsif ( $script eq "calc_fixedstep" )
+ {
+ @options = qw(
+ check|C
+ );
+ }
elsif ( $script eq "format_genome" )
{
@options = qw(
{
@options = qw(
cols|c=s
+ check|C
no_stream|x
data_out|o=s
compress|Z
use_score|u
visibility|V=s
color|c=s
- chunk_size|C=s
+ check|C
);
}
# print STDERR Dumper( \%options );
- $real = "beg|end|word_size|wrap|chunk_size|tile_size|len|prefix_length|mismatches|offset|num|skip|cpus|window_size|step_size";
+ $real = "beg|end|word_size|wrap|tile_size|len|prefix_length|mismatches|offset|num|skip|cpus|window_size|step_size";
foreach $opt ( keys %options )
{
{
$data_in = Maasha::Common::read_open( $file );
- while ( $bed_entry = Maasha::UCSC::BED::bed_entry_get( $data_in, $cols, 1 ) )
+ while ( $bed_entry = Maasha::UCSC::BED::bed_entry_get( $data_in, $cols, $options->{ 'check' } ) )
{
$record = Maasha::UCSC::BED::bed2biopiece( $bed_entry );
{
$strand = $record->{ 'STRAND' } || '+';
- Maasha::UCSC::BED::bed_entry_put( $bed_entry, $fh_out, $cols, 1 );
+ Maasha::UCSC::BED::bed_entry_put( $bed_entry, $fh_out, $cols, $options->{ 'check' } );
}
}
$fh_in = Maasha::Filesys::file_read_open( $tag_file );
- while ( $bed_entry = Maasha::UCSC::BED::bed_entry_get( $fh_in, $cols ) )
+ while ( $bed_entry = Maasha::UCSC::BED::bed_entry_get( $fh_in, $cols, $options->{ 'check' } ) )
{
if ( $record = Maasha::UCSC::BED::bed2biopiece( $bed_entry ) ) {
put_record( $record, $out );
while ( $record = get_record( $in ) )
{
if ( $bed_entry = Maasha::UCSC::BED::biopiece2bed( $record, $cols ) ) {
- Maasha::UCSC::BED::bed_entry_put( $bed_entry, $fh_out, $cols, 1 );
+ Maasha::UCSC::BED::bed_entry_put( $bed_entry, $fh_out, $cols, $options->{ 'check' } );
}
}
$record = Maasha::UCSC::psl2record( $record ) if $record->{ 'tBaseInsert' }; # Dirty addition to allow Affy data from MySQL to be dumped
if ( $bed_entry = Maasha::UCSC::BED::biopiece2bed( $record, $cols ) ) {
- Maasha::UCSC::BED::bed_entry_put( $bed_entry, $fh, $cols, 1 );
+ Maasha::UCSC::BED::bed_entry_put( $bed_entry, $fh, $cols, $options->{ 'check' } );
}
put_record( $record, $out ) if not $options->{ 'no_stream' };
$columns = $record->{ "BED_COLS" };
if ( $entry = Maasha::UCSC::BED::biopiece2bed( $record, $columns ) ) {
- Maasha::UCSC::BED::bed_entry_put( $entry, $fh_out, $columns, 1 );
+ Maasha::UCSC::BED::bed_entry_put( $entry, $fh_out, $columns, $options->{ 'check' } );
}
}
elsif ( $record->{ "REC_TYPE" } eq "PATSCAN" and $record->{ "CHR" } )
$columns = 6;
if ( $entry = Maasha::UCSC::BED::biopiece2bed( $record, $columns ) ) {
- Maasha::UCSC::BED::bed_entry_put( $entry, $fh_out, $columns, 1 );
+ Maasha::UCSC::BED::bed_entry_put( $entry, $fh_out, $columns, $options->{ 'check' } );
}
}
elsif ( $record->{ "REC_TYPE" } eq "BLAST" and $record->{ "S_ID" } =~ /^chr/ )
$record->{ "SCORE" } = $record->{ "BIT_SCORE" } * 1000;
if ( $entry = Maasha::UCSC::BED::biopiece2bed( $record, $columns ) ) {
- Maasha::UCSC::BED::bed_entry_put( $entry, $fh_out, $columns, 1 );
+ Maasha::UCSC::BED::bed_entry_put( $entry, $fh_out, $columns, $options->{ 'check' } );
}
}
elsif ( $record->{ "REC_TYPE" } eq "VMATCH" and $record->{ "S_ID" } =~ /^chr/i )
$columns = 6;
if ( $entry = Maasha::UCSC::BED::biopiece2bed( $record, $columns ) ) {
- Maasha::UCSC::BED::bed_entry_put( $entry, $fh_out, $columns, 1 );
+ Maasha::UCSC::BED::bed_entry_put( $entry, $fh_out, $columns, $options->{ 'check' } );
}
}
next if $options->{ "max_hits" } and $count_list->[ $fields[ 5 ] ] > $options->{ 'max_hits' };
$fields[ 1 ] = $index_files->[ $i ]; # S_ID
+ $fields[ 9 ] = int $fields[ 9 ];
$fields[ 9 ] = $count_list->[ $fields[ 5 ] ] if $options->{ "count" }; # SCORE
$fields[ 5 ] = $seq_names[ $fields[ 5 ] ]; # Q_ID
Maasha::Common::error( qq(Bad BED entry - chromEnd must be greater than chromStart - not "$bed->[ chromStart ] > $bed->[ chromEnd ]") );
}
- return if @{ $bed } == 3;
+ return if $cols == 3;
if ( $bed->[ name ] =~ /\s/ ) {
Maasha::Common::error( qq(Bad BED entry - no white space allowed in name field: "$bed->[ name ]") );
}
- return if @{ $bed } == 4;
+ return if $cols == 4;
if ( $bed->[ score ] =~ /\D/ ) {
Maasha::Common::error( qq(Bad BED entry - score must be a whole number - not "$bed->[ score ]") );
Maasha::Common::error( qq(Bad BED entry - score must be between 0 and 1000 - not "$bed->[ score ]") );
}
- return if @{ $bed } == 5;
+ return if $cols == 5;
if ( $bed->[ strand ] ne '+' and $bed->[ strand ] ne '-' ) {
Maasha::Common::error( qq(Bad BED entry - strand must be + or - not "$bed->[ strand ]") );
}
- return if @{ $bed } == 6;
+ return if $cols == 6;
if ( $bed->[ thickStart ] =~ /\D/ ) {
Maasha::Common::error( qq(Bad BED entry - thickStart must be a whole number - not "$bed->[ thickStart ]") );
Maasha::Common::error( qq(Bad BED entry - thickEnd must be less than chromEnd - not "$bed->[ thickEnd ] > $bed->[ chromEnd ]") );
}
- return if @{ $bed } == 8;
+ return if $cols == 8;
if ( $bed->[ itemRgb ] !~ /^(0|\d{1,3},\d{1,3},\d{1,3},?)$/ ) {
Maasha::Common::error( qq(Bad BED entry - itemRgb must be 0 or in the form of 255,0,0 - not "$bed->[ itemRgb ]") );
}
- return if @{ $bed } == 9;
+ return if $cols == 9;
if ( $bed->[ blockCount ] =~ /\D/ ) {
Maasha::Common::error( qq(Bad BED entry - blockCount must be a whole number - not "$bed->[ blockCount ]") );
#!/usr/bin/python
-import os, string, sys, getopt, Args
+import os, string, sys, getopt, Args, optparse
record_delimiter = "\n---\n"
rec = ''
eof_flag = False
while not self.eo_buffer:
+ #print "STDIN.ISATTY :", self.in_stream.isatty()
+
+ if self.in_stream.isatty():
+ eof_flag = True
+
if eof_flag:
if self.buffer == '':
self.eo_buffer = True
###########################################
def print_usage(self, opt):
+ #print opt
bp_dir = os.environ['BP_DIR']
usage_path = bp_dir + os.path.sep + "bp_usage" + os.path.sep + "lowercase_seq.wiki"
os.system("print_usage -i %s %s" % (usage_path, opt))
# main
-"""
-print "############"
-print len(sys.argv)
-print sys.argv
-print "############"
-"""
-
-
lc_seq = Lowercase_seq()
-a = Args.Args('Usage: %(progname)s [-a value] [-b value] [-c] word [file...]')
-
-a.opt['-I'] = '' # input file
-a.opt['-O'] = '' # output file
-a.getopt('I:O:?:v') # get user supplied option values
-
-#print >> sys.stderr, a.opt
+try:
+ opts, args = getopt.getopt(sys.argv[1:], "I:O:?vx", ["stream_in=", "stream_out=", "help", "verbose", "no_stream"])
+except getopt.GetoptError, err:
+ # print help information and exit:
+ print str(err) # will print something like "option -a not recognized"
+ lc_seq.print_usage("")
+ sys.exit(2)
-word = a.shift() # get the first of the remaining arguments
- # use a.pop() to get the last instead
-if not word == None:
- sys.stderr.write("Unknown argument %s\n" % (word))
- sys.exit(1)
-if sys.stdin.isatty():
- lc_seq.print_usage('')
+if len(opts)==0:
+ lc_seq.print_usage("")
sys.exit(1)
-#for line in a: # iterate over the contents of all remaining arguments (file names)
-# if a.lineno == 1:
-# print 'starting new file:', a.infile
-# a.warning(line.rstrip())
-
-#print 'Options:', a.opt
-#print 'Word:', word
-#print 'Total number of lines:', a.linesum
-
-
-if a.opt.has_key('-?'):
- lc_seq.print_usage('-?')
- sys.exit(1)
-else:
- try:
- lc_seq.open_streams(a.opt['-I'], a.opt['-O'])
- except:
- sys.stderr.write("%s\n" % ("IOError"))
+stream_in = ""
+stream_out = ""
+verbose = False
+for o, a in opts:
+ if o in ("-I", "--stream_in"):
+ stream_in = a
+ elif o in ("-O", "--stream_out"):
+ stream_out = a
+ elif o == "-?":
+ lc_seq.print_usage("")
+ sys.exit(1)
+ elif o == "--help":
+ lc_seq.print_usage("-?")
sys.exit(1)
+ elif o in ("-v", "--verbose"):
+ verbose = True
+ #else:
+ # assert False
+ # print_usage()
+
+try:
+ lc_seq.open_streams(stream_in, stream_out)
+except:
+ sys.stderr.write("%s\n" % ("IOError"))
+ sys.exit(1)
while True: