Sponsored Content
Full Discussion: Perl command in bash
Top Forums Shell Programming and Scripting Perl command in bash Post 302939973 by durden_tyler on Tuesday 31st of March 2015 10:08:51 AM
Old 03-31-2015
Code:
$
$ cat -n set_header.pl
     1  #!/usr/bin/perl
     2  use strict;
     3
     4  # Accept the input and output files as parameters
     5  my $input_file = $ARGV[0];
     6  my $output_file = $ARGV[1];
     7
     8  # Set the header columns to be added to the left
     9  # and to the right of the header in the input file
    10  my @left =  (
    11                   "Index",
    12                   "Chromosome Position",
    13                   "Gene",
    14                   "Inheritance",
    15                   "RNA Accession",
    16                   "Chr",
    17                   "Coverage",
    18                   "Score",
    19                   "A(#F,#R)",
    20                   "C(#F,#R)",
    21                   "G(#F,#R)",
    22                   "T(#F,#R)",
    23                   "Ins(#F,#R)",
    24                   "Del(#F,#R)",
    25                   "SNP db_xref",
    26                   "Mutation Call",
    27                   "Mutant Allele Frequency",
    28                   "Amino Acid Change"
    29              );
    30  my @right = (
    31                  "HP",
    32                  "SPLICE",
    33                  "Pseudogene",
    34                  "Classification",
    35                  "HGMD",
    36                  "Disease",
    37                  "Sanger",
    38                  "References"
    39              );
    40
    41  # Now open the input file, read the header line and sandwich it
    42  # between @left and @right arrays
    43  my $final_header;
    44  open (FH, "<", $input_file) or die "Can't open $input_file: $!";
    45  while (<FH>) {
    46      chomp;
    47      if ($. == 1) {
    48          $final_header = sprintf("%s\t%s\t%s\n", join("\t", @left), $_, join("\t",@right));
    49          last;
    50      }
    51  }
    52  close (FH) or die "Can't close $input_file: $!";
    53
    54  # Once the final header is set, print it to the output file
    55  open (FH, ">", $output_file) or die "Can't open $output_file: $!";
    56  print FH $final_header;
    57  close (FH) or die "Can't close $output_file: $!";
    58
$
$ perl set_header.pl del.txt.hg19_multianno.txt my_output.txt
$
$ sed 's/\t/\n/g' my_output.txt
Index
Chromosome Position
Gene
Inheritance
RNA Accession
Chr
Coverage
Score
A(#F,#R)
C(#F,#R)
G(#F,#R)
T(#F,#R)
Ins(#F,#R)
Del(#F,#R)
SNP db_xref
Mutation Call
Mutant Allele Frequency
Amino Acid Change
Chr
Start
End
Ref
Alt
Func.refGene
Gene.refGene
GeneDetail.refGene
ExonicFunc.refGene
AAChange.refGene
PopFreqMax
1000G2012APR_ALL
1000G2012APR_AFR
1000G2012APR_AMR
1000G2012APR_ASN
1000G2012APR_EUR
ESP6500si_ALL
ESP6500si_AA
ESP6500si_EA
CG46
common
clinvar
clinvarsubmit
clinvarreference
Otherinfo
HP
SPLICE
Pseudogene
Classification
HGMD
Disease
Sanger
References
$
$

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

passing variable from bash to perl from bash script

Hi All, I need to pass a variable to perl script from bash script, where in perl i am using if condition. Here is the cmd what i am using in perl FROM_DATE="06/05/2008" TO_DATE="07/05/2008" "perl -ne ' print if ( $_ >="$FROM_DATE" && $_ <= "$TO_DATE" ) ' filename" filename has... (10 Replies)
Discussion started by: arsidh
10 Replies

2. Shell Programming and Scripting

[Perl] Accessing array elements within a sed command in Perl script

I am trying to use a script to replace the header of each file, whose filename are stored within the array $test, using the sed command within a Perl script as follows: $count = 0; while ( $count < $#test ) { `sed -e 's/BIOGRF 321/BIOGRF 332/g' ${test} > 0`; `cat 0 >... (2 Replies)
Discussion started by: userix
2 Replies

3. Shell Programming and Scripting

Mixing Perl with Bash

I am fiddling with a little script that will issue a shutdown command if the temperature on the CPU goes above a certain level. I started writing the script in Bash, and then thought I would like to use Perl to extract the detailed bits, but I am not sure if this is really practical. Basically I... (2 Replies)
Discussion started by: kermit
2 Replies

4. Shell Programming and Scripting

combine two perl lines into a single perl command

Hi Everyone, i have a string 00:44:40 so: $tmp=~ s/://gi; $tmp=~s/({2})({2})({2})/$1*3600+$2*60+$3/e; the output is 2680. Any way to combine this two lines into a single line? Thanks (4 Replies)
Discussion started by: jimmy_y
4 Replies

5. Shell Programming and Scripting

Calling bash command in perl script

Hi, I have tried several times but failed, I need to call this script from the perl script. This one line script will be sent to /var/tmp/error Bash command: /usr/openv/netbackup/bin/admincmd/bperror -backstat -l -hoursago 12 |awk '{ print $19, $12, $14, $16}'|grep -vi default|sort >... (12 Replies)
Discussion started by: sQew
12 Replies

6. Shell Programming and Scripting

perl/unix: script in command line works but not in perl

so in unix this command works works and shows me a list of directories find . -name \*.xls -exec dirname {} \; | sort -u | > list.txt but when i try running a perl script to run this command my $query = 'find . -name \*.xls -exec dirname {} \; | sort -u | > list.txt';... (2 Replies)
Discussion started by: kpddong
2 Replies

7. AIX

Typing "bash" at the command line spawns two bash processes

Server: IBM p770 OS: AIX 6.1 TL5 SP1 When one of our develoeprs types "bash" on the command line to switch shells, it hangs. For some reason, two bash processes are created....the first bash process spawns a second bash process in the same console, causing a hang. Anyone have any idea what... (2 Replies)
Discussion started by: wjssj
2 Replies

8. UNIX for Dummies Questions & Answers

Running set options from the command line and bash command

I'm reading about debugging aids in bash and have come across the set command. It says in my little book that an addition to typing set you can also use them "on the command line when running a script..." and it lists this in a small table: set -o option Command Line... (5 Replies)
Discussion started by: Straitsfan
5 Replies

9. Shell Programming and Scripting

How to call a bash command from within a perl script?

In a bash script, one can call a perl command in the following manner, where "myperlcommand" is a perl command. perl -e 'myperlcommand(arguments)' perl -e 'print("UUUU"x4)' Now, how can one call a bash command from within a perl script? (Suppose that mybashcommand is a bash... (1 Reply)
Discussion started by: LessNux
1 Replies

10. Shell Programming and Scripting

How to run several bash commands put in bash command line?

How to run several bash commands put in bash command line without needing and requiring a script file. Because I'm actually a windows guy and new here so for illustration is sort of : $ bash "echo ${PATH} & echo have a nice day!" will do output, for example:... (4 Replies)
Discussion started by: abdulbadii
4 Replies
Bio::LiveSeq::Mutator(3pm)				User Contributed Perl Documentation				Bio::LiveSeq::Mutator(3pm)

NAME
Bio::LiveSeq::Mutator - Package mutating LiveSequences SYNOPSIS
# $gene is a Bio::LiveSeq::Gene object my $mutate = Bio::LiveSeq::Mutator->new('-gene' => $gene, '-numbering' => "coding" ); # $mut is a Bio::LiveSeq::Mutation object $mutate->add_Mutation($mut); # $results is a Bio::Variation::SeqDiff object my $results=$mutate->change_gene(); if ($results) { my $out = Bio::Variation::IO->new( '-format' => 'flat'); $out->write($results); } DESCRIPTION
This class mutates Bio::LiveSeq::Gene objects and returns a Bio::Variation::SeqDiff object. Mutations are described as Bio::LiveSeq::Mutation objects. See Bio::LiveSeq::Gene, Bio::Variation::SeqDiff, and Bio::LiveSeq::Mutation for details. FEEDBACK
User feedback is an integral part of the evolution of this and other Bioperl modules. Send your comments and suggestions preferably to the Bioperl mailing lists Your participation is much appreciated. bioperl-l@bioperl.org - General discussion http://bioperl.org/wiki/Mailing_lists - About the mailing lists Support Please direct usage questions or support issues to the mailing list: bioperl-l@bioperl.org rather than to the module maintainer directly. Many experienced and reponsive experts will be able look at the problem and quickly address it. Please include a thorough description of the problem with code and data examples if at all possible. Reporting Bugs report bugs to the Bioperl bug tracking system to help us keep track the bugs and their resolution. Bug reports can be submitted via the web: https://redmine.open-bio.org/projects/bioperl/ AUTHOR - Heikki Lehvaslaiho &; Joseph A.L. Insana Email: heikki-at-bioperl-dot-org insana@ebi.ac.uk, jinsana@gmx.net APPENDIX
The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _ gene Title : gene Usage : $mutobj = $obj->gene; : $mutobj = $obj->gene($objref); Function: Returns or sets the link-reference to a Bio::LiveSeq::Gene object. If no value has ben set, it will return undef Returns : an object reference or undef Args : a Bio::LiveSeq::Gene See Bio::LiveSeq::Gene for more information. numbering Title : numbering Usage : $obj->numbering(); Function: Sets and returns coordinate system used in positioning the mutations. See L<change_gene> for details. Example : Returns : string Args : string (coding [transcript number] | gene | entry) add_Mutation Title : add_Mutation Usage : $self->add_Mutation($ref) Function: adds a Bio::LiveSeq::Mutation object Example : Returns : Args : a Bio::LiveSeq::Mutation See Bio::LiveSeq::Mutation for more information. each_Mutation Title : each_Mutation Usage : foreach $ref ( $a->each_Mutation ) Function: gets an array of Bio::LiveSeq::Mutation objects Example : Returns : array of Mutations Args : See Bio::LiveSeq::Mutation for more information. mutation Title : mutation Usage : $mutobj = $obj->mutation; : $mutobj = $obj->mutation($objref); Function: Returns or sets the link-reference to the current mutation object. If the value is not set, it will return undef. Internal method. Returns : an object reference or undef DNA Title : DNA Usage : $mutobj = $obj->DNA; : $mutobj = $obj->DNA($objref); Function: Returns or sets the reference to the LiveSeq object holding the reference sequence. If there is no link, it will return undef. Internal method. Returns : an object reference or undef RNA Title : RNA Usage : $mutobj = $obj->RNA; : $mutobj = $obj->RNA($objref); Function: Returns or sets the reference to the LiveSeq object holding the reference sequence. If the value is not set, it will return undef. Internal method. Returns : an object reference or undef dnamut Title : dnamut Usage : $mutobj = $obj->dnamut; : $mutobj = $obj->dnamut($objref); Function: Returns or sets the reference to the current DNAMutation object. If the value is not set, it will return undef. Internal method. Returns : a Bio::Variation::DNAMutation object or undef See Bio::Variation::DNAMutation for more information. rnachange Title : rnachange Usage : $mutobj = $obj->rnachange; : $mutobj = $obj->rnachange($objref); Function: Returns or sets the reference to the current RNAChange object. If the value is not set, it will return undef. Internal method. Returns : a Bio::Variation::RNAChange object or undef See Bio::Variation::RNAChange for more information. aachange Title : aachange Usage : $mutobj = $obj->aachange; : $mutobj = $obj->aachange($objref); Function: Returns or sets the reference to the current AAChange object. If the value is not set, it will return undef. Internal method. Returns : a Bio::Variation::AAChange object or undef See Bio::Variation::AAChange for more information. exons Title : exons Usage : $mutobj = $obj->exons; : $mutobj = $obj->exons($objref); Function: Returns or sets the reference to a current array of Exons. If the value is not set, it will return undef. Internal method. Returns : an array of Bio::LiveSeq::Exon objects or undef See Bio::LiveSeq::Exon for more information. change_gene_with_alignment Title : change_gene_with_alignment Usage : $results=$mutate->change_gene_with_alignment($aln); Function: Returns a Bio::Variation::SeqDiff object containing the results of the changes in the alignment. The alignment has to be pairwise and have one sequence named 'QUERY', the other one is assumed to be a part of the sequence from $gene. This method offers a shortcut to change_gene and automates the creation of Bio::LiveSeq::Mutation objects. Use it with almost identical sequnces, e.g. to locate a SNP. Args : Bio::SimpleAlign object representing a short local alignment Returns : Bio::Variation::SeqDiff object or 0 on error See Bio::LiveSeq::Mutation, Bio::SimpleAlign, and Bio::Variation::SeqDiff for more information. create_mutation Title : create_mutation Usage : Function: Formats sequence differences from two sequences into Bio::LiveSeq::Mutation objects which can be applied to a gene. To keep it generic, sequence arguments need not to be Bio::LocatableSeq. Coordinate change to parent sequence numbering needs to be done by the calling code. Called from change_gene_with_alignment Args : Bio::PrimarySeqI inheriting object for the reference sequence Bio::PrimarySeqI inheriting object for the query sequence integer for the start position of the local sequence difference integer for the length of the sequence difference Returns : Bio::LiveSeq::Mutation object change_gene Title : change_gene Usage : my $mutate = Bio::LiveSeq::Mutator->new(-gene => $gene, numbering => "coding" ); # $mut is Bio::LiveSeq::Mutation object $mutate->add_Mutation($mut); my $results=$mutate->change_gene(); Function: Returns a Bio::Variation::SeqDiff object containing the results of the changes performed according to the instructions present in Mutation(s). The -numbering argument decides what molecule is being changed and what numbering scheme being used: -numbering => "entry" determines the DNA level, using the numbering from the beginning of the sequence -numbering => "coding" determines the RNA level, using the numbering from the beginning of the 1st transcript Alternative transcripts can be used by specifying "coding 2" or "coding 3" ... -numbering => "gene" determines the DNA level, using the numbering from the beginning of the 1st transcript and inluding introns. The meaning equals 'coding' if the reference molecule is cDNA. Args : Bio::LiveSeq::Gene object Bio::LiveSeq::Mutation object(s) string specifying a numbering scheme (defaults to 'coding') Returns : Bio::Variation::SeqDiff object or 0 on error _mutationpos2label Title : _mutationpos2label Usage : Function: converts mutation positions into labels Example : Returns : number of valid mutations Args : LiveSeq sequence object _set_DNAMutation Title : _set_DNAMutation Usage : Function: Stores DNA level mutation attributes before mutation into Bio::Variation::DNAMutation object. Links it to SeqDiff object. Example : Returns : Bio::Variation::DNAMutation object Args : Bio::Variation::SeqDiff object See Bio::Variation::DNAMutation and Bio::Variation::SeqDiff. _set_effects Title : _set_effects Usage : Function: Stores RNA and AA level mutation attributes before mutation into Bio::Variation::RNAChange and Bio::Variation::AAChange objects. Links them to SeqDiff object. Example : Returns : Args : Bio::Variation::SeqDiff object Bio::Variation::DNAMutation object See Bio::Variation::RNAChange, Bio::Variation::RNAChange, Bio::Variation::SeqDiff, and Bio::Variation::DNAMutation. _untranslated Title : _untranslated Usage : Function: Stores RNA change attributes before mutation into Bio::Variation::RNAChange object. Links it to SeqDiff object. Example : Returns : Args : Bio::Variation::SeqDiff object Bio::Variation::DNAMutation object See Bio::Variation::RNAChange, Bio::Variation::SeqDiff and Bio::Variation::DNAMutation for details. perl v5.14.2 2012-03-02 Bio::LiveSeq::Mutator(3pm)
All times are GMT -4. The time now is 05:57 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy