473,597 Members | 2,835 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to print out a part of the line?

Hi all,

I was wondering if it's possible to print out only a part of a line? The problem is I have an array with one motif in different variants, like this:
small_motif_a CGTCGCACAGC
small_motif_b CGTCGCACGAC
small_motif_c CGTCGCCCAGC
But in my output I only want the variant, without the nucleotide motif. Is that possible?
Like this: small_motif_a 811 821
(positions will be find by the script)
Expand|Select|Wrap|Line Numbers
  2. $pos= $pos + length($`)+1;
  3.         $pos2= $pos + length($&)-1;
  4.     print OUTFILE "$_\t $pos\t $pos2\n";
  5.     $refseq= $';
  6.         $temp=1;
  7.         $found=$found+1;    
Oct 21 '10 #1
2 2433
70 Recognized Expert New Member
Yes, it is possible to only print part of a line, and there are various ways to do so. One way is to use split as follows:

Expand|Select|Wrap|Line Numbers
  1. use strict;
  2. use warnings;
  4. while (<DATA>) {
  5.     my $motif = (split)[0];
  6.     print "$motif\n";
  7. }
  9. __DATA__
  10. small_motif_a CGTCGCACAGC
  11. small_motif_b CGTCGCACGAC
  12. small_motif_c CGTCGCCCAGC
This prints out:

Expand|Select|Wrap|Line Numbers
  1. small_motif_a
  2. small_motif_b
  3. small_motif_c
I have no idea how you determine your position values. Can you elaborate?
Oct 21 '10 #2
looks like my reply wasn't published
your suggestion worked great thank you very much
Oct 21 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

by: robert.spam.me.senseless | last post by:
This is probably a real n00b question, but I can't find an answer on the www and my javascript book doesn't have anything about it. How do you print part of an html page using the javascript print() function? Is it possible to put the printable area inside a <div></div> block and print it, or can you use a hidden style then print it? Is there a site on the www which has some information?
by: Patrick De Ridder | last post by:
How can I turn what I want to print 90 degrees using the logic below? Please tell me the code with which to make the modification. Many thanks, Patrick. using System.ComponentModel; using System.Drawing; using System.Drawing.Printing; using System.IO;
by: Ryan Gregg | last post by:
I'm working on a project where I need to be able to print a single line at a time to a dot matrix printer. Essentially we have a log printer and each time an event occurs on the system I need to have the printer print a line that relates to what the event was. From what I can see of the printer model in .Net, it's mostly document based. Is there any way to have it print a single line to the printer (and have the printer actually output...
by: Rob T | last post by:
I have a small VB program that has a printing module...very simple....and works great. However, If I try to print to a generic printer, I get the following error: "The data area passed to a system call is too small". I found the following article, that I assume is similar to my problem, which is of little help: http://support.microsoft.com/default.aspx?scid=kb;en-us;822779 Any suggestions?
by: melanieab | last post by:
Hi, When the print button is clicked, I save a snapshot of the screen to a bitmap file. Graphics currentTab = this.CreateGraphics(); Size s = this.Size; Bitmap memoryImage = new Bitmap(s.Width - 10, s.Height - 36, currentTab); Graphics memoryGraphics = Graphics.FromImage(memoryImage); IntPtr dc1 = currentTab.GetHdc(); IntPtr dc2 = memoryGraphics.GetHdc(); BitBlt(dc2, 0, 0, this.ClientRectangle.Width, this.ClientRectangle.Height,
by: Ant | last post by:
Hi all, I've got a problem here which has me stumped. I've got a python script which does some text processing on some files and writes it back out to the same file using the fileinput module with inplace set to True. The script needs to run from Windows, but the files need to be written with Unix line endings. Is there any way of doing this without having to post-process the file
by: Digital Puer | last post by:
Hi, I am interested in catching exceptions and printing the line number and file name of where the exception occurred, like what is done in Java. For example, when vector's at() accesses beyond its size and throws an exception, I would like to have the file and line information available. Any ideas how I can do this?
by: patelxxx | last post by:
When I running the following .cgi script, not sure why each print statement is not printing on a new line, even after entering \n. Browser=IE6 See Perl code below: #!C:/perl/bin/perl.exe -w print "Content-type:text/html\n\n"; use CGI qw(:standard);
by: Brett | last post by:
I have an ASP.NET page that displays work orders in a GridView. In that GridView is a checkbox column. When the user clicks a "Print" button, I create a report, using the .NET Framework printing classes, for each of the checked rows in the GridView. This works fine in the Visual Studio 2005 development environment on localhost. But, when I move the page to the web server, I get the error "Settings to access printer...
by: ekasII | last post by:
l__trace = "<my path\file_with_two_lines.txt> if __name__=='__main__': l__open = open(l__trace,'r') for l__line in l__open.readlines(): (head,tail) = os.path.split(l__line) if head: print head + "\\" + tail + "_new" # <----Problem
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.