Sponsored Content
Top Forums Shell Programming and Scripting Cut output to same byte position Post 302097257 by ghostdog74 on Wednesday 22nd of November 2006 09:51:06 PM
Old 11-22-2006
If you have Python, an alternative
Sample input:
-------------------
111333 444TTTLKOP
122333 444DDDLKOP
422333 4445DDLTlR


Code:
#!/usr/bin/python
start1,end1 = 3,6 #position 4-6
start2,end2 = 14,17 #position 15-17
for lines in open("test.txt"):
        lines = list(lines.strip())
        lines[start1:end1] = " " * (end1 - start1) #sub space at positoin 4-5
        lines[start2:end2] = " " * (end2 - start2)
        print ''.join(lines)

output:
Code:
111     444TTT   P
122     444DDD   P
422     4445DD   R

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

byte count and cut command

1. Is there a way to count the number of bytes of a variable? example: abc@yahoo.com is 13 bytes 2. Cut command only allows one byte for delimiter example: cut -f1 -d'.' delimited by period. Is there a way to have two or more characters in the delimiter field? thanks in adavance. :) (4 Replies)
Discussion started by: hemangjani
4 Replies

2. Shell Programming and Scripting

Cut position as a variable

Hi All, I wish to cut an input by using the below command but i would want to have the cut position as a variable. For eg, the position number is 11 now and i wish that this number is being assigned to a variable before putting into the cut function. Can this be done ? Can any expert help?... (1 Reply)
Discussion started by: Raynon
1 Replies

3. Shell Programming and Scripting

Check if 2 files are identical byte-to-byte?

In my server migration requirement, I need to compare if one file on old server is exactly the same as the corresponding file on the new server. For diff and comm, the inputs need to be sorted. But I do not want to disturb the content of the file and need to find byte-to-byte match. Please... (4 Replies)
Discussion started by: krishmaths
4 Replies

4. Shell Programming and Scripting

Remove a byte(Last byte from the last line)

Hi All Can anyone please suggest me how to remove the last byte from a falt file .This is from the last line's last BYTE. Please suggest me something. Thank's and regards Vinay (1 Reply)
Discussion started by: vinayrao
1 Replies

5. Shell Programming and Scripting

Perl- Output file is always 0 byte

Hi all, I am new to perl programming. However i have a script that connects to the database and spools that into an output file. Strange thing is that sometimes this script works and sometimes the ouput spool file is always 0 byte. I have verified the sql query and the query always returns... (5 Replies)
Discussion started by: amit1_x
5 Replies

6. Shell Programming and Scripting

Cut multiple data based on character position

How to extract multiple data based on character position. I need to fetch from 7-9 and 22-26 and there is no delimiter for 22-26 since it is part of the column. The file may have more than 1000 character long.I managed to pull any one but not both for example test data 12345 zxc vbnmlk... (1 Reply)
Discussion started by: zooby
1 Replies

7. Shell Programming and Scripting

How to cut line from certain position?

Hi Gurus, I want to cut my file from 27th charactor to the end of line. can anybody give some unix command to do this. Thanks in advance (3 Replies)
Discussion started by: ken6503
3 Replies

8. UNIX for Beginners Questions & Answers

Cut two individual position and summ

Hi All, I am having a huge file file. I need to cut the below column and do the below calculation I did the below command and able to do on full databased no on the individual based any help on doing each row by row cut -c 52-56 myfile | awk '{total = total + $1}END{print total}'... (7 Replies)
Discussion started by: arunkumar_mca
7 Replies

9. UNIX for Beginners Questions & Answers

Print byte position of extended ascii character

Hello, I am on AIX. When I encounter extended ascii characters and special characters on a file I need to print.. Byte position, actual character and line number. Is there a simple command that can give me the above result ? Thanks in advance (38 Replies)
Discussion started by: rosebud123
38 Replies

10. Shell Programming and Scripting

Cut command with dynamic passing of delimiter and position values

Hi All, We have a requirement of picking nth position value by using cut command. value would be delimited by any symbols. We have to pass delimited value and postition to get the value in a string. ex. echo "A,B,C,D,E" |cut -d "," -f3 echo "A|B|C|D|E"|cut -d "|" -f2 Kindly frame the... (5 Replies)
Discussion started by: KK230689
5 Replies
Bio::Graphics::Feature(3pm)				User Contributed Perl Documentation			       Bio::Graphics::Feature(3pm)

NAME
Bio::Graphics::Feature - A simple feature object for use with Bio::Graphics::Panel SYNOPSIS
use Bio::Graphics::Feature; # create a simple feature with no internal structure $f = Bio::Graphics::Feature->new(-start => 1000, -stop => 2000, -type => 'transcript', -name => 'alpha-1 antitrypsin', -desc => 'an enzyme inhibitor', ); # create a feature composed of multiple segments, all of type "similarity" $f = Bio::Graphics::Feature->new(-segments => [[1000,1100],[1500,1550],[1800,2000]], -name => 'ABC-3', -type => 'gapped_alignment', -subtype => 'similarity'); # build up a gene exon by exon $e1 = Bio::Graphics::Feature->new(-start=>1,-stop=>100,-type=>'exon'); $e2 = Bio::Graphics::Feature->new(-start=>150,-stop=>200,-type=>'exon'); $e3 = Bio::Graphics::Feature->new(-start=>300,-stop=>500,-type=>'exon'); $f = Bio::Graphics::Feature->new(-segments=>[$e1,$e2,$e3],-type=>'gene'); DESCRIPTION
This is a simple Bio::SeqFeatureI-compliant object that is compatible with Bio::Graphics::Panel. With it you can create lightweight feature objects for drawing. All methods are as described in Bio::SeqFeatureI with the following additions: The new() Constructor $feature = Bio::Graphics::Feature->new(@args); This method creates a new feature object. You can create a simple feature that contains no subfeatures, or a hierarchically nested object. Arguments are as follows: -seq_id the reference sequence -start the start position of the feature -end the stop position of the feature -stop an alias for end -name the feature name (returned by seqname()) -type the feature type (returned by primary_tag()) -primary_tag the same as -type -source the source tag -score the feature score (for GFF compatibility) -desc a description of the feature -segments a list of subfeatures (see below) -subtype the type to use when creating subfeatures -strand the strand of the feature (one of -1, 0 or +1) -phase the phase of the feature (0..2) -id an alias for -name -seqname an alias for -name -display_id an alias for -name -display_name an alias for -name (do you get the idea the API has changed?) -primary_id unique database ID -url a URL to link to when rendered with Bio::Graphics -configurator an object (like a Bio::Graphics::FeatureFile) that knows how to configure the graphical representation of the object based on its type. -attributes a hashref of tag value attributes, in which the key is the tag and the value is an array reference of values -factory a reference to a feature factory, used for compatibility with more obscure parts of Bio::DB::GFF The subfeatures passed in -segments may be an array of Bio::Graphics::Feature objects, or an array of [$start,$stop] pairs. Each pair should be a two-element array reference. In the latter case, the feature type passed in -subtype will be used when creating the subfeatures. If no feature type is passed, then it defaults to "feature". Non-SeqFeatureI methods A number of new methods are provided for compatibility with Ace::Sequence, which has a slightly different API from SeqFeatureI: attributes() An alternative interface to get_tag_values. Pass the name of an attribute to get the value(s) of that attribute: $expression_level = $gene->attributes('expression'); Call attributes() without any arguments to get a hash of all attributes: %attributes = $gene->attributes; url() Get/set the URL that the graphical rendering of this feature will link to. add_segment(@segments) Add one or more segments (a subfeature). Segments can either be Feature objects, or [start,stop] arrays, as in the -segments argument to new(). The feature endpoints are automatically adjusted. my @features = get_SeqFeatures('type1','type2','type3'...) Get the subfeatures of this feature. If an optional list of types is provided, then only returns subfeatures with the indicated primary_tag. (This is an extension of the Bio::SeqFeatureI interface). $feature->add_hit($hit) For nucleotide alignments, add a feature that is a "hit" on the feature. $hit = $feature->hit Return the hit. segments() An alias for get_SeqFeatures(). get_all_SeqFeatures() Alias for get_SeqFeatures() merged_segments() Another alias for sub_SeqFeature(). stop() An alias for end(). name() An alias for seqname(). exons() An alias for sub_SeqFeature() (you don't want to know why!) configurator() Get/set the configurator that knows how to adjust the graphical representation of this feature based on its type. Currently the only configurator that will work is Bio::Graphics::FeatureFile. factory Title : factory Usage : $factory = $obj->factory([$new_factory]) Function: Returns the feature factory from which this feature was generated. Mostly for compatibility with weird dependencies in gbrowse. Returns : A feature factory Args : None display_name Title : display_name Usage : $id = $obj->display_name or $obj->display_name($newid); Function: Gets or sets the display id, also known as the common name of the Seq object. The semantics of this is that it is the most likely string to be used as an identifier of the sequence, and likely to have "human" readability. The id is equivalent to the LOCUS field of the GenBank/EMBL databanks and the ID field of the Swissprot/sptrembl database. In fasta format, the >(S+) is presumed to be the id, though some people overload the id to embed other information. Bioperl does not use any embedded information in the ID field, and people are encouraged to use other mechanisms (accession field for example, or extending the sequence object) to solve this. Notice that $seq->id() maps to this function, mainly for legacy/convenience issues. Returns : A string Args : None or a new id accession_number Title : accession_number Usage : $unique_biological_key = $obj->accession_number; Function: Returns the unique biological id for a sequence, commonly called the accession_number. For sequences from established databases, the implementors should try to use the correct accession number. Notice that primary_id() provides the unique id for the implemetation, allowing multiple objects to have the same accession number in a particular implementation. For sequences with no accession number, this method should return "unknown". Returns : A string Args : None alphabet Title : alphabet Usage : if( $obj->alphabet eq 'dna' ) { /Do Something/ } Function: Returns the type of sequence being one of 'dna', 'rna' or 'protein'. This is case sensitive. This is not called <type> because this would cause upgrade problems from the 0.5 and earlier Seq objects. Returns : a string either 'dna','rna','protein'. NB - the object must make a call of the type - if there is no type specified it has to guess. Args : none Status : Virtual desc Title : desc Usage : $seqobj->desc($string) or $seqobj->desc() Function: Sets or gets the description of the sequence Example : Returns : The description Args : The description or none location Title : location Usage : my $location = $seqfeature->location() Function: returns a location object suitable for identifying location of feature on sequence or parent feature Returns : Bio::LocationI object Args : none location_string Title : location_string Usage : my $string = $seqfeature->location_string() Function: Returns a location string in a format recognized by gbrowse Returns : a string Args : none This is a convenience function used by the generic genome browser. It returns the location of the feature and its subfeatures in the compact form "start1..end1,start2..end2,...". Use $seqfeature->location()->toFTString() to obtain a standard GenBank/EMBL location representation. configurator Title : configurator Usage : my $configurator = $seqfeature->configurator([$new_configurator]) Function: Get/set an object that provides configuration information for this feature Returns : configurator object Args : new configurator object (optional) A configurator object provides hints to the Bio::Graphics::Feature as to how to display itself on a canvas. Currently this stores the Bio::Graphics::FeatureFile and descendents. url Title : url Usage : my $url = $seqfeature->url([$new_url]) Function: Get/set the URL associated with this feature Returns : a URL string Args : new URL (optional) Features link to URLs when displayed as a clickable image map. This field holds that information. make_link Title : make_link Usage : my $url = $seqfeature->make_link() Function: Create a URL for the feature Returns : a URL string Args : none This method will invoke the configurator in order to turn the feature into a link. Used by Bio::Graphics::Panel to create imagemaps. SEE ALSO
Bio::Graphics::Panel,Bio::Graphics::Glyph, Bio::Graphics::FeatureBase GD AUTHOR
Lincoln Stein <lstein@cshl.edu>. Copyright (c) 2001 Cold Spring Harbor Laboratory This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See DISCLAIMER.txt for disclaimers of warranty. perl v5.14.2 2012-02-20 Bio::Graphics::Feature(3pm)
All times are GMT -4. The time now is 06:01 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy