Sponsored Content
Top Forums Shell Programming and Scripting Conditional for every letter in alphabet Post 302924811 by DGPickett on Wednesday 12th of November 2014 12:55:57 PM
Old 11-12-2014
Code:
for i in "${arr[@]}"; do
if [[ $i =~ [A-Za-z].* ]]; then
j=$i
while [[ $j =~ ...* ]]
do
 j=${j%?}
done
 echo "$i starts with $j"
	else echo "$i does not start with a letter"
fi
done

Check for a letter using regex matching in bash, the find the first character for your output.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

What can i do to check that the input is all alphabet.. ?

What can i do to check that the input is all alphabet.. ? (4 Replies)
Discussion started by: XXXXXXXXXX
4 Replies

2. Programming

output the letters of the alphabet with the number of occurrences

hi, I'm trying to create a program that will read a file and then check the file for each letter of the alphabet and then output the letter and the number of times it appears in the file, into a new file... this is what i have so far but it's not working.. if anyone could help that would be nice!... (10 Replies)
Discussion started by: svd
10 Replies

3. Shell Programming and Scripting

To check if the first character is a alphabet or number

Hi, I need to find whether the first character in a line is a alphabet or a number. If its a number i should sort it numerically. If its a alphabet i should sort it based on the ASCII value.And if it is something other than alphabet or number then sort it based on ASCII value. The code i used... (2 Replies)
Discussion started by: ragavhere
2 Replies

4. UNIX for Dummies Questions & Answers

checking wether an input is using letters of the alphabet

afternoon forums. I need to get a way of testing as to wether an inputed character is part of the english alphabet. i have come up with the following code but its not working at all. until '] do echo This is not a Letter done any help would be beneficial to me. (1 Reply)
Discussion started by: strasner
1 Replies

5. Shell Programming and Scripting

Alphabet counting

I have a text file in the following format CCCCCGCCCCCCCCCCcCCCCCCCCCCCCCCC AAAATAAAAAAAAAAAaAAAAAAAAAAAAAAA TGTTTTTTTTTTTTGGtTTTTTTTTTTTTTTT TTTT-TTTTTTTTTCTtTTTTTTTTTTTTTTT Each row/line will have 32 letters and each line will only have multiple occurrences of 2 letters out of a pool... (1 Reply)
Discussion started by: Lucky Ali
1 Replies

6. Shell Programming and Scripting

last character is digit or alphabet!

Hello, I have to find out whether the last character is digit or alphabet. I manage to strip the last character but would need some help if there is one liner available to test the above. set x = WM echo $x | sed 's/.*\(.$\)/\1/' O/P M I would like a one liner code to test whether the... (1 Reply)
Discussion started by: dixits
1 Replies

7. Shell Programming and Scripting

Recode alphabet into numbers

I have a genotype.bim file where it contains information about SNPs and genotype. As a hypothetical example, let's say genotype.bim snp1 ... A G snp2 ... G T snp3 ... G T snp4 ... G A ... snpN ... C G where first column identifies each SNP and 5th and 6th column has genotype... (3 Replies)
Discussion started by: johnkim0806
3 Replies

8. Shell Programming and Scripting

Help with sort alphabet on specific column

Input file: POL B7U6K8 Avian_reticuloendotheliosis_virus POLB B7Z1W5 Homo_sapiens POLB H9G5Y0 Anolis_carolinensis POLD1 Q642R8 Xenopus_laevis POLD2 H0YZC7 Taeniopygia_guttata POLD3 F1P540 Gallus_gallus POLDIP3 Q5F4B6 Gallus_gallus POLE2 E1C2T8 Gallus_gallus... (3 Replies)
Discussion started by: perl_beginner
3 Replies

9. Shell Programming and Scripting

Replace specific letter in a file by other letter

Good afternoon all, I want to ask how to change some letter in my file with other letter in spesific line eg. data.txt 1 1 1 0 0 0 0 for example i want to change the 4th line with character 1. How could I do it by SED or AWK. I have tried to run this code but actually did not... (3 Replies)
Discussion started by: weslyarfan
3 Replies

10. UNIX for Beginners Questions & Answers

Shell Script - Alphabet in code

Hi e Hi everyone, I can't make this script work, #! /bin/bash declare -A crypt=( ="A" ="a" ="B" ="b" ="C" ="c" =' ' ='!' ) encode () { local word=$1 for ((i=0; i<${#word}; ++i)) ; do local char=${word:$i:1} printf %s' ' ${crypt} done ... (5 Replies)
Discussion started by: Pinguino
5 Replies
Bio::Tools::OddCodes(3pm)				User Contributed Perl Documentation				 Bio::Tools::OddCodes(3pm)

NAME
Bio::Tools::OddCodes - Object holding alternative alphabet coding for one protein sequence SYNOPSIS
# Take a sequence object from eg, an inputstream, and creates an # object for the purposes of rewriting that sequence in another # alphabet. These are abbreviated amino acid sequence alphabets, # designed to simplify the statistical aspects of analysing protein # sequences, by reducing the combinatorial explosion of the # 20-letter alphabet. These abbreviated alphabets range in size # from 2 to 8. # Creating the OddCodes object, eg: my $inputstream = Bio::SeqIO->new( '-file' => "seqfile", '-format' => 'Fasta'); my $seqobj = $inputstream->next_seq(); my $oddcode_obj = Bio::Tools::Oddcodes->new(-seq => $seqobj); # or: my $seqobj = Bio::PrimarySeq->new (-seq=>'[cut and paste a sequence here]', -alphabet => 'protein', -id => 'test'); my $oddcode_obj = Bio::Tools::OddCodes->new(-seq => $seqobj); # do the alternative coding, returning the answer as a reference to # a string my $output = $oddcode_obj->structural(); my $output = $oddcode_obj->chemical(); my $output = $oddcode_obj->functional(); my $output = $oddcode_obj->charge(); my $output = $oddcode_obj->hydrophobic(); my $output = $oddcode_obj->Dayhoff(); my $output = $oddcode_obj->Sneath(); my $output = $oddcode_obj->Stanfel(); # display sequence in new form, eg: my $new_coding = $$output; print " $new_coding"; DESCRIPTION
Bio::Tools::Oddcodes is a welterweight object for rewriting a protein sequence in an alternative alphabet. Eight of these are provided, ranging from the the 2-letter hydrophobic alphabet, to the 8-letter chemical alphabet. These are useful for the statistical analysis of protein sequences since they can partially avoid the combinatorial explosion produced by the full 20-letter alphabet (eg. 400 dimers, 8000 trimers etc.) The objects will print out a warning if the input sequence is not a protein. If you know what you are doing, you can silence the warning by setting verbose() to a negative value. See SYNOPSIS above for object creation code. REFERENCES
Stanfel LE(1996) A new approach to clustering the amino acids. J. theor. Biol. 183, 195-205. Karlin S, Ost F and Blaisdell BE(1989) Patterns in DNA and amino acid sequences and their statistical significance. Chapter 6 of: Mathematical Methods for DNA Sequences. Waterman MS (ed.) CRC Press, Boca Raton , FL. FEEDBACK
Mailing Lists User feedback is an integral part of the evolution of this and other Bioperl modules. Send your comments and suggestions preferably to one of 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
Derek Gatherer APPENDIX
The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _ structural Title : structural Usage : $output = $oddcode_obj->structural(); Function: turns amino acid sequence into 3-letter structural alphabet : A (ambivalent), E (external), I (internal) Example : a sequence ACDEFGH will become AAEEIAE Returns : Reference to the new sequence string Args : none functional Title : functional Usage : $output = $oddcode_obj->functional(); Function: turns amino acid sequence into 4-letter functional alphabet : A (acidic), C (basic), H (hydrophobic), P (polar) Example : a sequence ACDEFGH will become HPAAHHC Returns : Reference to the new sequence string Args : none hydrophobic Title : hydrophobic Usage : $output = $oddcode_obj->hydrophobic(); Function: turns amino acid sequence into 2-letter hydrophobicity alphabet : O (hydrophobic), I (hydrophilic) Example : a sequence ACDEFGH will become OIIIOII Returns : Reference to the new sequence string Args : none Dayhoff Title : Dayhoff Usage : $output = $oddcode_obj->Dayhoff(); Function: turns amino acid sequence into 6-letter Dayhoff alphabet Example : a sequence ACDEFGH will become CADDGCE : A (=C), C (=AGPST), D (=DENQ), : E (=HKR), F (=ILMV), G (=FWY) Returns : Reference to the new sequence string Args : none Sneath Title : Sneath Usage : $output = $oddcode_obj->Sneath(); Function: turns amino acid sequence into 7-letter Sneath alphabet Example : a sequence ACDEFGH will become CEFFHCF : A (=ILV), C (=AGP), D (=MNQ), E (=CST), : F (=DE), G (=KR), H (=FHWY) Returns : Reference to the new sequence string Args : none Stanfel Title : Stanfel Usage : $output = $oddcode_obj->Stanfel(); Function: turns amino acid sequence into 4-letter Stanfel alphabet Example : a sequence ACDEFGH will become AACCDAE : A (=ACGILMPSTV), C (=DENQ), D (=FWY), E (=HKR) Returns : Reference to the new sequence string Args : none chemical Title : chemical Usage : $output = $oddcode_obj->chemical(); Function: turns amino acid sequence into 8-letter chemical alphabet : A (acidic), L (aliphatic), M (amide), R (aromatic) : C (basic), H (hydroxyl), I (imino), S (sulphur) Example : a sequence ACDEFGH will become LSAARAC Returns : Reference to the new sequence string Args : none charge Title : charge Usage : $output = $oddcode_obj->charge(); Function: turns amino acid sequence into 3-letter charge alphabet Example : a sequence ACDEFGH will become NNAANNC : A (negative; NOT anode), C (positive; NOT cathode), N (neutral) Returns : Reference to the new sequence string Args : none perl v5.14.2 2012-03-02 Bio::Tools::OddCodes(3pm)
All times are GMT -4. The time now is 12:06 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy