Seqanswers Leaderboard Ad

Collapse

Announcement

Collapse
No announcement yet.
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Perl - how to get the last few elements in a string

    Hi folks,

    Could any one please tell me how to get the last few elements from a string using perl?

    for eg, $string= ATTGGCTACC;

    if I want to print the last 3 elements in the above string, how can I script it?


    Thank you,

    Pradhaun.

  • #2
    Why don't you try this: http://lmgtfy.com/?q=perl+substring

    Comment


    • #3
      $substring=substr($string,7,3);
      or $substring=substr($string,-3,3);

      Comment


      • #4
        thank you heiya!! It worked out!!
        Thank you so much!!

        Comment


        • #5
          The substr always seems alien to me, whereas simple regexes seem natural.

          my ($substring) =$string=~ /(...)$/;

          speaks to me "capture the last 3 characters before the end of the string and assign them to $substring. (Okay the parentheses around $substring, denoting that the characters themselves should be assigned to $substring, not just whether the test succeeded or not -- that is not very intuitive.)

          But if I want to only capture the last three bases if they are sequence characters, only a minor change is required:

          my ($substring)=$string=~/([ACGTacgtNn]{3})$/;

          But I have heard that substr is faster.

          --
          Phillip

          Comment


          • #6
            Thank you pmiguel! I tried your suggestion. It worked well! Thank you so much!

            -pradhaun

            Comment


            • #7
              Hi Pradhaun,

              Welcome to the world of regular expressions!
              Although I should caution you about the old perl joke:

              Say you have a problem and think "I will use regular expressions to solve that". Now, you have two problems...

              Also Rick though I should have shortened the line to:

              my ($substring)=$string=~/([ACGTN]{3})$/i;

              --
              Phillip

              Comment


              • #8
                How to estimate the total copy number of genes from FPKM values?

                Hello all,

                I am using Tophat and cufflinks to estimate the copy number of genes in an organism by comparing to its closely related organism genes. I got a bam and gtf file as a outputs from Tophat and Cufflinks . I tried to view the alignment (Tophat output) file as well as the gtf file in IGV. I can see the FPKM value for every single gene but My question is, how can I know whether these two organisms are closely related? Like for eg., "There are x number of same set of genes present in both the organisms" Or is there any way to know the overall FPKM or copy number?

                I am new to this kind of study, am not sure whether my thinking can be applicable or not. So I would appreciate if you can please provide your suggestions...

                Thank you,
                Pradhaun

                Comment


                • #9
                  Originally posted by pmiguel View Post
                  The substr always seems alien to me, whereas simple regexes seem natural.

                  my ($substring) =$string=~ /(...)$/;

                  speaks to me "capture the last 3 characters before the end of the string and assign them to $substring. (Okay the parentheses around $substring, denoting that the characters themselves should be assigned to $substring, not just whether the test succeeded or not -- that is not very intuitive.)

                  But if I want to only capture the last three bases if they are sequence characters, only a minor change is required:

                  my ($substring)=$string=~/([ACGTacgtNn]{3})$/;

                  But I have heard that substr is faster.

                  --
                  Phillip
                  I also think substring will work on really huge strings (like a chromosome length sequence), regex not so much, in my experience.

                  Comment


                  • #10
                    Originally posted by Pradhaun View Post
                    Hello all,

                    I am using Tophat and cufflinks to estimate the copy number of genes in an organism by comparing to its closely related organism genes. I got a bam and gtf file as a outputs from Tophat and Cufflinks . I tried to view the alignment (Tophat output) file as well as the gtf file in IGV. I can see the FPKM value for every single gene but My question is, how can I know whether these two organisms are closely related? Like for eg., "There are x number of same set of genes present in both the organisms" Or is there any way to know the overall FPKM or copy number?

                    I am new to this kind of study, am not sure whether my thinking can be applicable or not. So I would appreciate if you can please provide your suggestions...

                    Thank you,
                    Pradhaun
                    Maybe if you put your question into a new thread instead of an old thread about Perl programming then you will receive some meaningful comments. It would be interesting to see what other people have to say. My feeling is that there is too much variation in normal transcriptome studies to give a feel for relatedness. Not to mention the entirely fuzzy definition of 'related'.

                    Comment

                    Latest Articles

                    Collapse

                    • seqadmin
                      Recent Innovations in Spatial Biology
                      by seqadmin


                      Spatial biology is an exciting field that encompasses a wide range of techniques and technologies aimed at mapping the organization and interactions of various biomolecules in their native environments. As this area of research progresses, new tools and methodologies are being introduced, accompanied by efforts to establish benchmarking standards and drive technological innovation.

                      3D Genomics
                      While spatial biology often involves studying proteins and RNAs in their...
                      Yesterday, 07:30 PM
                    • seqadmin
                      Advancing Precision Medicine for Rare Diseases in Children
                      by seqadmin




                      Many organizations study rare diseases, but few have a mission as impactful as Rady Children’s Institute for Genomic Medicine (RCIGM). “We are all about changing outcomes for children,” explained Dr. Stephen Kingsmore, President and CEO of the group. The institute’s initial goal was to provide rapid diagnoses for critically ill children and shorten their diagnostic odyssey, a term used to describe the long and arduous process it takes patients to obtain an accurate...
                      12-16-2024, 07:57 AM

                    ad_right_rmr

                    Collapse

                    News

                    Collapse

                    Topics Statistics Last Post
                    Started by seqadmin, 12-30-2024, 01:35 PM
                    0 responses
                    21 views
                    0 likes
                    Last Post seqadmin  
                    Started by seqadmin, 12-17-2024, 10:28 AM
                    0 responses
                    41 views
                    0 likes
                    Last Post seqadmin  
                    Started by seqadmin, 12-13-2024, 08:24 AM
                    0 responses
                    55 views
                    0 likes
                    Last Post seqadmin  
                    Started by seqadmin, 12-12-2024, 07:41 AM
                    0 responses
                    40 views
                    0 likes
                    Last Post seqadmin  
                    Working...
                    X