Dear All,
I need to use external program from my scirpt.
code = "intersectBed -a %s -b /database/Refseq_Gene2.bed -wa -wb|cut -f
4,8|uniq > tmp.tmp1"%("gene5.tmp.bed")
code2 = "intersectBed -a %s -b /database/Refseq_Gene2.bed -wa -wb|cut -f
4,8|uniq > tmp.tmp2"%("gene3.tmp.bed")
proc = []
p = subprocess.Popen(code,shell=True)
proc.append(p)
time.sleep(1) # seconds
p = subprocess.Popen(code2,shell=True)
proc.append(p)
time.sleep(1)
print
>>sys.stderr,'-------------------------------------------------------------------------'
print >>sys.stderr,"Waiting for Star Fusion Annotate to finish running..."
for p in proc:
p.communicate()
print
>>sys.stderr,'-------------------------------------------------------------------------'
What append I don't habve any error however the file are truncated.
So I try to use subprocess.call
p = subprocess.call(shlex.split(code),stdout = subprocess.PIPE, stderr =
subprocess.STDOUT, shell = False)
but with p.comunicate I have this error:
('\n***** ERROR: Unrecognized parameter: -wb|cut *****\n***** ERROR:
Unrecognized parameter: > *****\n***** ERROR: Unrecognized parameter: tmp.tmp1
*****\n\nTool: bedtools intersect (aka intersectBed)\nVersion:
v2.21.0-5-g479a2fc\nSummary: Report overlaps between two feature
files.\n\nUsage: bedtools intersect [OPTIONS] -a <bed/gff/vcf> -b
<bed/gff/vcf>\n\n\t\tNote: -b may be followed with multiple databases and/or
\n\t\twildcard (*) character(s). \nOptions: \n\t-abam\tThe A input file is in
BAM format. Output will be BAM as well.\n\n\t-ubam\tWrite uncompressed BAM
output. Default writes compressed BAM.\n\n\t-bed\tWhen using BAM input (-abam),
write output as BED. The default\n\t\tis to write output in BAM when using
-abam.\n\n\t-wa\tWrite the original entry in A for each
overlap.\n\n\t-wb\tWrite the original entry in B for each overlap.\n\t\t-
Useful for knowing _what_ A overlaps. Restricted by -f and
-r.\n\n\t-loj\tPerform a "left outer join". That is, for each feature in
A\n\t\treport each overlap with B. If no overlaps are found, \n\t\treport a
NULL feature for B.\n\n\t-wo\tWrite the original A and B entries plus the
number of base\n\t\tpairs of overlap between the two features.\n\t\t- Overlaps
restricted by -f and -r.\n\t\t Only A features with overlap are
reported.\n\n\t-wao\tWrite the original A and B entries plus the number of
base\n\t\tpairs of overlap between the two features.\n\t\t- Overlapping
features restricted by -f and -r.\n\t\t However, A features w/o overlap are
also reported\n\t\t with a NULL B feature and overlap = 0.\n\n\t-u\tWrite the
original A entry _once_ if _any_ overlaps found in B.\n\t\t- In other words,
just report the fact >=1 hit was found.\n\t\t- Overlaps restricted by -f and
-r.\n\n\t-c\tFor each entry in A, report the number of overlaps with B.\n\t\t-
Reports 0 for A entries that have no overlap with B.\n\t\t- Overlaps restricted
by -f and -r.\n\n\t-v\tOnly report those entries in A that have _no overlaps_
with B.\n\t\t- Similar to "grep -v" (an homage).\n\n\t-f\tMinimum overlap
required as a fraction of A.\n\t\t- Default is 1E-9 (i.e., 1bp).\n\t\t- FLOAT
(e.g. 0.50)\n\n\t-r\tRequire that the fraction overlap be reciprocal for A and
B.\n\t\t- In other words, if -f is 0.90 and -r is used, this requires\n\t\t
that B overlap 90% of A and A _also_ overlaps 90% of B.\n\n\t-s\tRequire same
strandedness. That is, only report hits in B\n\t\tthat overlap A on the _same_
strand.\n\t\t- By default, overlaps are reported without respect to
strand.\n\n\t-S\tRequire different strandedness. That is, only report hits in
B\n\t\tthat overlap A on the _opposite_ strand.\n\t\t- By default, overlaps are
reported without respect to strand.\n\n\t-split\tTreat "split" BAM or BED12
entries as distinct BED intervals.\n\n\t-sorted\tUse the "chromsweep" algorithm
for sorted (-k1,1 -k2,2n) input.\n\n\t-g\tProvide a genome file to enforce
consistent chromosome sort order\n\t\tacross input files. Only applies when
used with -sorted option.\n\n\t-header\tPrint the header from the A file prior
to results.\n\n\t-nobuf\tDisable buffered output. Using this option will cause
each line\n\t\tof output to be printed as it is generated, rather than
saved\n\t\tin a buffer. This will make printing large output files
\n\t\tnoticeably slower, but can be useful in conjunction with\n\t\tother
software tools and scripts that need to process one\n\t\tline of bedtools
output at a time.\n\n\t-names\tWhen using multiple databases, provide an alias
for each that\n\t\twill appear instead of a fileId when also printing the DB
record.\n\n\t-filenames\tWhen using multiple databases, show each complete
filename\n\t\t\tinstead of a fileId when also printing the DB
record.\n\n\t-sortout\tWhen using multiple databases, sort the output DB
hits\n\t\t\tfor each record.\n\n\t-iobuf\tFollow with desired integer size of
read buffer.\n\t\tOptional suffixes K/M/G supported.\n\t\tNote: currently has
no effect with compressed files.\n\nNotes: \n\t(1) When a BAM file is used for
the A file, the alignment is retained if overlaps exist,\n\tand exlcuded if an
overlap cannot be found. If multiple overlaps exist, they are not\n\treported,
as we are only testing for one or more overlaps.\n\n',
None)
shlex.split(code)
Out[102]:
['intersectBed',
'-a',
'gene5.tmp.bed',
'-b',
'/home/maurizio/database/Refseq_Gene2.bed',
'-wa',
'-wb|cut',
'-f',
'4,8|uniq',
'>',
'tmp.tmp1']
So what can I do? which system do you suggest to my Problem?
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor